- Notifications
You must be signed in to change notification settings - Fork2
convos-chat/linkembedder
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
LinkEmbedder - Embed / expand oEmbed resources and other URL / links
use LinkEmbedder;my $embedder = LinkEmbedder->new(force_secure => 1);# In some cases, you have to set a proper user_agent to get complete# pages. This is done automatically by $embedder->serve()$embedder->ua->transactor->name("Mozilla...");$embedder->get_p("https://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 orsimply to extract information about the URL.
This module replacesMojolicious::Plugin::LinkEmbedder.
Go tohttps://thorsen.pm/linkembedder to see a demo of how it works.
These web pages are currently supported:
Instagram need some additional JavaScript. Please look athttps://github.com/jhthorsen/linkembedder/blob/master/examples/embedder.pl andhttps://www.instagram.com/developer/embedding/for more information.
Twitter need some additional JavaScript. Please look athttps://github.com/jhthorsen/linkembedder/blob/master/examples/embedder.pl andhttps://dev.twitter.com/web/javascript/initializationfor more information.
HTML
Any web page will be parsed, and "og:", "twitter:", meta tags and othersignificant 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.
$bool = $self->force_secure;$self = $self->force_secure(1);This attribute will translate any unknown http link to https.
This attribute is EXPERIMENTAL. Feeback appreciated.
$ua = $self->ua;Holds aMojo::UserAgent object.
$hash_ref = $self->url_to_link;Holds a mapping between host names andlink class to use.
$self = $self->get_p($url, sub { my ($self, $link) = @_ });Same as"get_p", but takes a callback instead of returning aMojo::Promise.
$promise = $self->get_p($url)->then(sub { my $link = shift });Used to construct a newLinkEmbedder::Link object and retrieve informationabout the URL.
$self = $self->serve(Mojolicious::Controller->new, $url);Used as a helper forMojolicious web applications to reply to an oEmbedrequest. Will also set"name" in Mojo::UserAgent::Transactor for"ua" ifthe incoming request contains a "User-Agent" header.
Note that inMojolicious 9.11 and later, you must define the format for yourroute to serve with extension .html, .json or .jsonp.
Jan Henning Thorsen
This program is free software, you can redistribute it and/or modify it underthe terms of the Artistic License version 2.0.
About
Embed / expand oEmbed resources and other URL / links
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.