line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Facebook::InstantArticle::Figure; |
2
|
2
|
|
|
2
|
|
806
|
use Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
11
|
|
3
|
2
|
|
|
2
|
|
10571
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
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
|
|
6
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
3
|
|
|
|
|
8
|
my $gen = XML::Generator->new( ':pretty' ); |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
224
|
my @comments_likes = (); |
66
|
3
|
100
|
|
|
|
97
|
push( @comments_likes, 'fb:comments' ) if ( $self->enable_comments ); |
67
|
3
|
100
|
|
|
|
106
|
push( @comments_likes, 'fb:likes' ) if ( $self->enable_likes ); |
68
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
7
|
my %attrs = (); |
70
|
|
|
|
|
|
|
|
71
|
3
|
100
|
|
|
|
8
|
if ( @comments_likes ) { |
72
|
1
|
|
|
|
|
10
|
$attrs{'data-feedback'} = join( ' ', @comments_likes ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
3
|
100
|
|
|
|
90
|
if ( length $self->presentation ) { |
76
|
1
|
|
|
|
|
26
|
$attrs{'data-mode'} = $self->presentation; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
3
|
100
|
|
|
|
20
|
if ( $self->isa('Facebook::InstantArticle::Figure::Image') ) { |
|
|
50
|
|
|
|
|
|
80
|
2
|
50
|
|
|
|
56
|
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
|
|
|
|
35
|
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; |