LinkEmbedder - Embed / expand oEmbed resources and other URL / links
use LinkEmbedder; my $embedder = LinkEmbedder->new; $embedder->get_p("http://xkcd.com/927")->then(sub { my $link = shift; print $link->html; })->wait;
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:
http://imgur.com/
Example: http://home.thorsen.pm/demo/link-embedder?url=http://imgur.com/gallery/ohL3e
https://instagram.com/
Example: http://home.thorsen.pm/demo/link-embedder?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.
https://appear.in/
Example: http://home.thorsen.pm/demo/link-embedder?url=https://appear.in/link-embedder-demo
https://gist.github.com
Example: http://home.thorsen.pm/demo/link-embedder?url=https://gist.github.com/jhthorsen/3738de6f44f180a29bbb
https://github.com
Example: http://home.thorsen.pm/demo/link-embedder?url=https://github.com/jhthorsen/linkembedder/blob/master/t/basic.t
https://ix.io
Example: http://home.thorsen.pm/demo/link-embedder?url=http://ix.io/fpW
https://maps.google.com
Example: http://home.thorsen.pm/demo/link-embedder?url=https%3A%2F%2Fwww.google.no%2Fmaps%2Fplace%2FOslo%2C%2BNorway%2F%4059.8937806%2C10.645035…m4!1s0x46416e61f267f039%3A0x7e92605fd3231e9a!8m2!3d59.9138688!4d10.7522454
https://metacpan.org
Example: http://home.thorsen.pm/demo/link-embedder?url=https://metacpan.org/pod/Mojolicious
https://paste.fedoraproject.org/
Example: http://home.thorsen.pm/demo/link-embedder?https://paste.fedoraproject.org/paste/9qkGGjN-D3fL2M-bimrwNQ
http://paste.opensuse.org
Example: http://home.thorsen.pm/demo/link-embedder?url=http://paste.opensuse.org/2931429
http://paste.scsys.co.uk
Example: http://home.thorsen.pm/demo/link-embedder?url=http://paste.scsys.co.uk/557716
http://pastebin.com
Example: http://home.thorsen.pm/demo/link-embedder?url=https://pastebin.com/V5gZTzhy
https://www.spotify.com/
Example: http://home.thorsen.pm/demo/link-embedder?url=spotify:track:0aBi2bHHOf3ZmVjt3x00wv
https://ted.com
Example: http://home.thorsen.pm/demo/link-embedder?url=https://www.ted.com/talks/jill_bolte_taylor_s_powerful_stroke_of_insight
https://travis-ci.org
Example: http://home.thorsen.pm/demo/link-embedder?url=https://travis-ci.org/Nordaaker/convos/builds/47421379
https://twitter.com
Example: http://home.thorsen.pm/demo/link-embedder?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.
https://vimeo.com
Example: http://home.thorsen.pm/demo/link-embedder?url=https://vimeo.com/154038415
https://youtube.com
Example: http://home.thorsen.pm/demo/link-embedder?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DOspRE1xnLjE
https://www.xkcd.com/
Example: http://home.thorsen.pm/demo/link-embedder?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.
Example: http://home.thorsen.pm/demo/link-embedder?url=http://www.aftenposten.no/kultur/Kunstig-intelligens-ma-ikke-lenger-trenes-av-mennesker-617794b.html
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.
$ua = $self->ua;
Holds a Mojo::UserAgent object.
$hash_ref = $self->url_to_link;
Holds a mapping between host names and link class to use.
$self = $self->get_p($url, sub { my ($self, $link) = @_ });
Same as "get_p", but takes a callback instead of returning a Mojo::Promise.
$promise = $self->get_p($url)->then(sub { my $link = shift });
Used to construct a new LinkEmbedder::Link object and retrieve information about the URL.
$self = $self->serve(Mojolicious::Controller->new, $url);
Used as a helper for Mojolicious web applications to reply to an oEmbed request.
Jan Henning Thorsen
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
To install LinkEmbedder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm LinkEmbedder
CPAN shell
perl -MCPAN -e shell install LinkEmbedder
For more information on module installation, please visit the detailed CPAN module installation guide.