line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Facebook::InstantArticle::Embed; |
2
|
2
|
|
|
2
|
|
11
|
use Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
12
|
|
3
|
2
|
|
|
2
|
|
11536
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
17
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Facebook::InstantArticle::BaseElement'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'content' => ( |
8
|
|
|
|
|
|
|
isa => 'Str', |
9
|
|
|
|
|
|
|
is => 'rw', |
10
|
|
|
|
|
|
|
required => 0, |
11
|
|
|
|
|
|
|
default => '', |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'source' => ( |
15
|
|
|
|
|
|
|
isa => 'Str', |
16
|
|
|
|
|
|
|
is => 'rw', |
17
|
|
|
|
|
|
|
required => 0, |
18
|
|
|
|
|
|
|
default => '', |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'width' => ( |
22
|
|
|
|
|
|
|
isa => 'Int', |
23
|
|
|
|
|
|
|
is => 'rw', |
24
|
|
|
|
|
|
|
required => 0, |
25
|
|
|
|
|
|
|
default => 0, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'height' => ( |
29
|
|
|
|
|
|
|
isa => 'Int', |
30
|
|
|
|
|
|
|
is => 'rw', |
31
|
|
|
|
|
|
|
required => 0, |
32
|
|
|
|
|
|
|
default => 0, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
around BUILDARGS => sub { |
36
|
|
|
|
|
|
|
my $orig = shift; |
37
|
|
|
|
|
|
|
my $class = shift; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
if ( @_ == 1 && !ref $_[0] ) { |
40
|
|
|
|
|
|
|
return $class->$orig( content => $_[0] ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
|
|
|
|
|
|
return $class->$orig( @_ ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'is_valid' => ( |
48
|
|
|
|
|
|
|
isa => 'Bool', |
49
|
|
|
|
|
|
|
is => 'ro', |
50
|
|
|
|
|
|
|
lazy => 1, |
51
|
|
|
|
|
|
|
default => sub { |
52
|
|
|
|
|
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return ( length $self->content || length $self->source ) ? 1 : 0; |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has 'as_xml_gen' => ( |
59
|
|
|
|
|
|
|
isa => 'Object', |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
lazy => 1, |
62
|
|
|
|
|
|
|
builder => '_build_as_xml_gen', |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _build_as_xml_gen { |
66
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
3
|
my $gen = XML::Generator->new( ':pretty' ); |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
76
|
my %attrs = (); |
71
|
1
|
50
|
|
|
|
30
|
$attrs{ src } = $self->source if ( length $self->source ); |
72
|
1
|
50
|
|
|
|
28
|
$attrs{ width } = $self->width if ( $self->width ); |
73
|
1
|
50
|
|
|
|
28
|
$attrs{ height } = $self->height if ( $self->height ); |
74
|
|
|
|
|
|
|
|
75
|
1
|
50
|
|
|
|
31
|
return $gen->figure( |
76
|
|
|
|
|
|
|
{ class => 'op-interactive' }, |
77
|
|
|
|
|
|
|
$gen->iframe( |
78
|
|
|
|
|
|
|
( keys %attrs ? \%attrs : undef ), |
79
|
|
|
|
|
|
|
\$self->content, |
80
|
|
|
|
|
|
|
), |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |