line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Text::PasteScsysCoUk; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojolicious::Plugin::LinkEmbedder::Link::Text::PasteScsysCoUk - paste.scsys.co.uk 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
|
|
595
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
20
|
1
|
|
|
1
|
|
154
|
use Mojo::Util (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
377
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 media_id |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$str = $self->media_id; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has media_id => sub { |
31
|
|
|
|
|
|
|
shift->url->path =~ m!^/?(\d+)! ? $1 : ''; |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 provider_name |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
|
sub provider_name {'scsys.co.uk'} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 learn |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub learn { |
47
|
0
|
|
|
0
|
1
|
|
my ($self, $c, $cb) = @_; |
48
|
0
|
0
|
|
|
|
|
my $raw_url = $self->raw_url or return $self->SUPER::learn($c, $cb); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$self->ua->get( |
51
|
|
|
|
|
|
|
$raw_url, |
52
|
|
|
|
|
|
|
sub { |
53
|
0
|
|
|
0
|
|
|
my ($ua, $tx) = @_; |
54
|
0
|
0
|
|
|
|
|
$self->{text} = Mojo::Util::xml_escape($tx->res->body) if $tx->success; |
55
|
0
|
|
|
|
|
|
$self->$cb; |
56
|
|
|
|
|
|
|
}, |
57
|
0
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 raw_url |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub raw_url { |
65
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
66
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
Mojo::URL->new("http://paste.scsys.co.uk/$media_id?tx=on"); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Jan Henning Thorsen |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |