line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Text::Pastebin; |
2
|
1
|
|
|
1
|
|
441
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has media_id => sub { |
5
|
|
|
|
|
|
|
shift->url->path =~ m!^/?(\w+)! ? $1 : ''; |
6
|
|
|
|
|
|
|
}; |
7
|
|
|
|
|
|
|
|
8
|
0
|
|
|
0
|
1
|
|
sub provider_name {'pastebin.com'} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub learn { |
11
|
0
|
|
|
0
|
1
|
|
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 raw_url { |
25
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
26
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
Mojo::URL->new('http://pastebin.com/raw.php')->query(i => $media_id); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=encoding utf8 |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Mojolicious::Plugin::LinkEmbedder::Link::Text::Pastebin - pastebin.com link |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
This class inherit from L. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 OUTPUT HTML |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This is an example output: |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$txt |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 media_id |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$str = $self->media_id; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 provider_name |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 learn |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 raw_url |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AUTHOR |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Jan Henning Thorsen |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |