line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Text::Ix; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojolicious::Plugin::LinkEmbedder::Link::Text::Ix - ix.io link |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This class inherit from L. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 OUTPUT HTML |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This is an example output: |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$txt |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
430
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 media_id |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$str = $self->media_id; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has media_id => sub { |
30
|
|
|
|
|
|
|
shift->url->path =~ m!^/?(\w+)! ? $1 : ''; |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 provider_name |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
sub provider_name {'ix.io'} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 learn |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub learn { |
46
|
0
|
|
|
0
|
1
|
|
my ($self, $c, $cb) = @_; |
47
|
0
|
0
|
|
|
|
|
my $raw_url = $self->raw_url or return $self->SUPER::learn($c, $cb); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$self->ua->get( |
50
|
|
|
|
|
|
|
$raw_url, |
51
|
|
|
|
|
|
|
sub { |
52
|
0
|
|
|
0
|
|
|
my ($ua, $tx) = @_; |
53
|
0
|
0
|
|
|
|
|
$self->{text} = Mojo::Util::xml_escape($tx->res->body) if $tx->success; |
54
|
0
|
|
|
|
|
|
$self->$cb; |
55
|
|
|
|
|
|
|
}, |
56
|
0
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 pretty_url |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Returns a pretty version of the L. The default is to return a cloned |
62
|
|
|
|
|
|
|
version of L. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub pretty_url { |
67
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
68
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return $self->SUPER::pretty_url; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
Mojo::URL->new("http://ix.io/$media_id/"); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 raw_url |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub raw_url { |
78
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
79
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
Mojo::URL->new("http://ix.io/$media_id"); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Jan Henning Thorsen |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |