line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Video::Ted; |
2
|
1
|
|
|
1
|
|
2335
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text::HTML'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has media_id => sub { |
5
|
|
|
|
|
|
|
my $self = shift; |
6
|
|
|
|
|
|
|
my $media_id = $self->url->path->[-1]; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$media_id =~ s!\.html$!!; |
9
|
|
|
|
|
|
|
$media_id; |
10
|
|
|
|
|
|
|
}; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
0
|
|
sub provider_name {'Ted'} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub learn { |
15
|
0
|
|
|
0
|
0
|
|
my ($self, $c, $cb) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
0
|
|
|
|
|
if ($self->media_id) { |
18
|
0
|
|
|
|
|
|
$self->$cb; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else { |
21
|
0
|
|
|
|
|
|
$self->SUPER::learn($c, $cb); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub to_embed { |
28
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
29
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return $self->SUPER::to_embed; |
30
|
0
|
|
|
|
|
|
my %args = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$self->_iframe( |
33
|
|
|
|
|
|
|
src => "//embed.ted.com/talks/$media_id.html", |
34
|
|
|
|
|
|
|
class => 'link-embedder video-ted', |
35
|
|
|
|
|
|
|
width => $args{width} || 560, |
36
|
0
|
|
0
|
|
|
|
height => $args{height} || 315 |
|
|
|
0
|
|
|
|
|
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |