line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Text::Twitter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojolicious::Plugin::LinkEmbedder::Link::Text::Twitter - twitter.com link |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This class inherit from L. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
502
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 media_id |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$str = $self->media_id; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Example C<$str>: "/username/status/123456789". |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 provider_name |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has media_id => sub { |
28
|
|
|
|
|
|
|
my $self = shift; |
29
|
|
|
|
|
|
|
my $path = $self->url->path; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return $1 if $path =~ m!^/(\w+/status/\w+)/?$!; |
32
|
|
|
|
|
|
|
return $1 if $path =~ m!^/(\w+/status/\w+)/photo/\w+/?$!; |
33
|
|
|
|
|
|
|
return ''; |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
1
|
|
sub provider_name {'Twitter'} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 to_embed |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Returns the HTML code for javascript embedding this tweet. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub to_embed { |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return $self->SUPER::to_embed; |
49
|
0
|
|
|
|
|
|
my %args = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $self->tag( |
52
|
|
|
|
|
|
|
div => class => 'link-embedder text-twitter', |
53
|
|
|
|
|
|
|
sub { |
54
|
|
|
|
|
|
|
join( |
55
|
|
|
|
|
|
|
'', |
56
|
|
|
|
|
|
|
$self->tag( |
57
|
|
|
|
|
|
|
blockquote => class => 'twitter-tweet', |
58
|
|
|
|
|
|
|
lang => $args{lang} || 'en', |
59
|
|
|
|
|
|
|
data => {conversation => $args{conversation} || 'none'}, |
60
|
|
|
|
|
|
|
sub { |
61
|
0
|
|
|
|
|
|
$self->tag(a => href => "https://twitter.com/$media_id", "Loading $media_id..."); |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
0
|
0
|
|
|
), |
|
|
|
0
|
|
|
|
|
64
|
|
|
|
|
|
|
'' |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 AUTHOR |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Jan Henning Thorsen |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |