NAME
LinkEmbedder - Embed / expand oEmbed resources and other URL / links
SYNOPSIS
use LinkEmbedder;
my $embedder = LinkEmbedder->new;
$embedder->get_p("http://xkcd.com/927")->then(sub {
my $link = shift;
print $link->html;
})->wait;
DESCRIPTION
LinkEmbedder is a module that can expand an URL into a rich HTML snippet or simply to extract information about the URL.
Note that this module is currently EXPERIMENTAL. It will replace Mojolicious::Plugin::LinkEmbedder when it gets stable.
These web pages are currently supported:
-
Example: https://app.thorsen.pm/linkembedder?url=http://imgur.com/gallery/ohL3e
-
Example: https://app.thorsen.pm/linkembedder?url=https://www.instagram.com/p/BSRYg_Sgbqe/
Instagram need some additional JavaScript. Please look at https://github.com/jhthorsen/linkembedder/blob/master/examples/embedder.pl and https://www.instagram.com/developer/embedding/ for more information.
-
Example: https://app.thorsen.pm/linkembedder?url=https://appear.in/link-embedder-demo
-
Example: https://app.thorsen.pm/linkembedder?url=https://gist.github.com/jhthorsen/3738de6f44f180a29bbb
-
Example: https://app.thorsen.pm/linkembedder?url=http://ix.io/fpW
-
Example: https://app.thorsen.pm/linkembedder?url=https://metacpan.org/pod/Mojolicious
https://paste.fedoraproject.org/
Example: https://app.thorsen.pm/linkembedder?https://paste.fedoraproject.org/paste/9qkGGjN-D3fL2M-bimrwNQ
-
Example: https://app.thorsen.pm/linkembedder?url=http://paste.opensuse.org/2931429
-
Example: https://app.thorsen.pm/linkembedder?url=http://paste.scsys.co.uk/557716
-
Example: https://app.thorsen.pm/linkembedder?url=https://pastebin.com/V5gZTzhy
-
Example: https://app.thorsen.pm/linkembedder?url=spotify:track:0aBi2bHHOf3ZmVjt3x00wv
-
Example: https://app.thorsen.pm/linkembedder?url=https://travis-ci.org/Nordaaker/convos/builds/47421379
-
Example: https://app.thorsen.pm/linkembedder?url=https://twitter.com/jhthorsen/status/786688349536972802
Twitter need some additional JavaScript. Please look at https://github.com/jhthorsen/linkembedder/blob/master/examples/embedder.pl and https://dev.twitter.com/web/javascript/initialization for more information.
-
Example: https://app.thorsen.pm/linkembedder?url=https://vimeo.com/154038415
-
Example: https://app.thorsen.pm/linkembedder?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DOspRE1xnLjE
-
Example: https://app.thorsen.pm/linkembedder?url=http://xkcd.com/927
HTML
Any web page will be parsed, and "og:", "twitter:", meta tags and other significant elements will be used to generate a oEmbed response.
Images
URLs that looks like an image is automatically converted into an img tag.
Video
URLs that looks like a video resource is automatically converted into a video tag.
ATTRIBUTES
ua
$ua = $self->ua;
Holds a Mojo::UserAgent object.
url_to_link
$hash_ref = $self->url_to_link;
Holds a mapping between host names and link class to use.
METHODS
get
$self = $self->get_p($url, sub { my ($self, $link) = @_ });
Same as "get_p", but takes a callback instead of returning a Mojo::Promise.
get_p
$promise = $self->get_p($url)->then(sub { my $link = shift });
Used to construct a new LinkEmbedder::Link object and retrieve information about the URL.
serve
$self = $self->serve(Mojolicious::Controller->new, $url);
Used as a helper for Mojolicious web applications to reply to an oEmbed request.
AUTHOR
Jan Henning Thorsen
COPYRIGHT AND LICENSE
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.