line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Facebook::InstantArticle::Figure; |
2
|
2
|
|
|
2
|
|
1784
|
use Moose; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
3
|
2
|
|
|
2
|
|
14564
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
38
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Facebook::InstantArticle::BaseElement'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'source' => ( |
8
|
|
|
|
|
|
|
isa => 'Str', |
9
|
|
|
|
|
|
|
is => 'rw', |
10
|
|
|
|
|
|
|
required => 1, |
11
|
|
|
|
|
|
|
default => '', |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'caption' => ( |
15
|
|
|
|
|
|
|
isa => 'Str', |
16
|
|
|
|
|
|
|
is => 'rw', |
17
|
|
|
|
|
|
|
required => 0, |
18
|
|
|
|
|
|
|
default => '', |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'enable_comments' => ( |
22
|
|
|
|
|
|
|
isa => 'Bool', |
23
|
|
|
|
|
|
|
is => 'rw', |
24
|
|
|
|
|
|
|
required => 0, |
25
|
|
|
|
|
|
|
default => 0, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'enable_likes' => ( |
29
|
|
|
|
|
|
|
isa => 'Bool', |
30
|
|
|
|
|
|
|
is => 'rw', |
31
|
|
|
|
|
|
|
required => 0, |
32
|
|
|
|
|
|
|
default => 0, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has 'presentation' => ( |
36
|
|
|
|
|
|
|
isa => 'Str', |
37
|
|
|
|
|
|
|
is => 'rw', |
38
|
|
|
|
|
|
|
required => 0, |
39
|
|
|
|
|
|
|
default => '', |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has 'is_valid' => ( |
43
|
|
|
|
|
|
|
isa => 'Bool', |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
lazy => 1, |
46
|
|
|
|
|
|
|
default => sub { |
47
|
|
|
|
|
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
return ( $self->source =~ m,^https?://.+, ) ? 1 : 0; |
50
|
|
|
|
|
|
|
}, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has 'as_xml_gen' => ( |
54
|
|
|
|
|
|
|
isa => 'Object', |
55
|
|
|
|
|
|
|
is => 'ro', |
56
|
|
|
|
|
|
|
lazy => 1, |
57
|
|
|
|
|
|
|
builder => '_build_as_xml_gen', |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _build_as_xml_gen { |
61
|
3
|
|
|
3
|
|
8
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
3
|
|
|
|
|
15
|
my $gen = XML::Generator->new( ':pretty' ); |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
320
|
my @comments_likes = (); |
66
|
3
|
100
|
|
|
|
202
|
push( @comments_likes, 'fb:comments' ) if ( $self->enable_comments ); |
67
|
3
|
100
|
|
|
|
210
|
push( @comments_likes, 'fb:likes' ) if ( $self->enable_likes ); |
68
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
6
|
my %attrs = (); |
70
|
|
|
|
|
|
|
|
71
|
3
|
100
|
|
|
|
9
|
if ( @comments_likes ) { |
72
|
1
|
|
|
|
|
4
|
$attrs{'data-feedback'} = join( ' ', @comments_likes ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
3
|
100
|
|
|
|
160
|
if ( length $self->presentation ) { |
76
|
1
|
|
|
|
|
32
|
$attrs{'data-mode'} = $self->presentation; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
3
|
100
|
|
|
|
30
|
if ( $self->isa('Facebook::InstantArticle::Figure::Image') ) { |
|
|
50
|
|
|
|
|
|
80
|
2
|
50
|
|
|
|
136
|
return $gen->figure( |
|
|
50
|
|
|
|
|
|
81
|
|
|
|
|
|
|
( keys %attrs ? \%attrs : undef ), |
82
|
|
|
|
|
|
|
$gen->img( { src => $self->source } ), |
83
|
|
|
|
|
|
|
( length $self->caption ? $gen->figcaption(\$self->caption) : undef ), |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
elsif ( $self->isa('Facebook::InstantArticle::Figure::Video') ) { |
87
|
1
|
50
|
|
|
|
38
|
return $gen->figure( |
|
|
50
|
|
|
|
|
|
88
|
|
|
|
|
|
|
( keys %attrs ? \%attrs : undef ), |
89
|
|
|
|
|
|
|
$gen->video( |
90
|
|
|
|
|
|
|
$gen->source( { src => $self->source } ), |
91
|
|
|
|
|
|
|
), |
92
|
|
|
|
|
|
|
( length $self->caption ? $gen->figcaption(\$self->caption) : undef ), |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |