line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Text::Ix; |
2
|
1
|
|
|
1
|
|
2474
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has media_id => sub { |
5
|
|
|
|
|
|
|
shift->url->path =~ m!^/?(\w+)! ? $1 : ''; |
6
|
|
|
|
|
|
|
}; |
7
|
|
|
|
|
|
|
|
8
|
0
|
|
|
0
|
0
|
|
sub provider_name {'ix.io'} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub learn { |
11
|
0
|
|
|
0
|
0
|
|
my ($self, $c, $cb) = @_; |
12
|
0
|
0
|
|
|
|
|
my $raw_url = $self->raw_url or return $self->SUPER::learn($c, $cb); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$self->ua->get( |
15
|
|
|
|
|
|
|
$raw_url, |
16
|
|
|
|
|
|
|
sub { |
17
|
0
|
|
|
0
|
|
|
my ($ua, $tx) = @_; |
18
|
0
|
0
|
|
|
|
|
$self->{text} = Mojo::Util::xml_escape($tx->res->body) if $tx->success; |
19
|
0
|
|
|
|
|
|
$self->$cb; |
20
|
|
|
|
|
|
|
}, |
21
|
0
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub pretty_url { |
25
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
26
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return $self->SUPER::pretty_url; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
Mojo::URL->new("http://ix.io/$media_id/"); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub raw_url { |
32
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
33
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
Mojo::URL->new("http://ix.io/$media_id"); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |