| 1 | package LinkEmbedder::Link::Twitter; | ||
| 2 | use Mojo::Base 'LinkEmbedder::Link'; | ||
| 3 | |||
| 4 | use Mojo::Util; | ||
| 5 | |||
| 6 | has provider_name => 'Twitter'; | ||
| 7 | has provider_url => sub { Mojo::URL->new('https://twitter.com') }; | ||
| 8 | |||
| 9 | sub learn_p { | ||
| 10 | my $self = shift; | ||
| 11 | my $path = $self->url->path; | ||
| 12 | return $self->SUPER::learn_p(@_) unless @$path >= 3 and $path->[1] eq 'status'; | ||
| 13 | |||
| 14 | $self->author_name($path->[0]); | ||
| 15 | $self->author_url($self->provider_url->clone->path("/$path->[0]")); | ||
| 16 | $self->template([__PACKAGE__, 'twitframe.html.ep']); | ||
| 17 | $self->url($self->provider_url->clone->path("/$path->[0]/status/$path->[2]")); | ||
| 18 | $self->type('rich'); | ||
| 19 | return Mojo::Promise->resolve($self); | ||
| 20 | } | ||
| 21 | |||
| 22 | 1; | ||
| 23 | |||
| 24 | __DATA__ |