line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Text::Pastebin; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojolicious::Plugin::LinkEmbedder::Link::Text::Pastebin - pastebin.com 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
|
|
454
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
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 {'pastebin.com'} |
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 raw_url |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub raw_url { |
64
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
65
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
Mojo::URL->new('http://pastebin.com/raw.php')->query(i => $media_id); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 AUTHOR |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Jan Henning Thorsen |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |