| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::Feed::Format::Atom; |
|
2
|
28
|
|
|
28
|
|
134086
|
use strict; |
|
|
28
|
|
|
|
|
66
|
|
|
|
28
|
|
|
|
|
791
|
|
|
3
|
28
|
|
|
28
|
|
147
|
use warnings; |
|
|
28
|
|
|
|
|
57
|
|
|
|
28
|
|
|
|
|
1261
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.53'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
28
|
|
|
28
|
|
143
|
use base qw( XML::Feed ); |
|
|
28
|
|
|
|
|
57
|
|
|
|
28
|
|
|
|
|
2471
|
|
|
8
|
28
|
|
|
28
|
|
20900
|
use XML::Atom::Feed; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use XML::Atom::Util qw( iso2dt ); |
|
10
|
|
|
|
|
|
|
use List::Util qw( first ); |
|
11
|
|
|
|
|
|
|
use DateTime::Format::W3CDTF; |
|
12
|
|
|
|
|
|
|
use HTML::Entities; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use XML::Atom::Entry; |
|
15
|
|
|
|
|
|
|
XML::Atom::Entry->mk_elem_accessors(qw( lat long ), ['http://www.w3.org/2003/01/geo/wgs84_pos#']); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use XML::Atom::Content; |
|
18
|
|
|
|
|
|
|
use XML::Feed::Entry::Format::Atom; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub identify { |
|
21
|
|
|
|
|
|
|
my $class = shift; |
|
22
|
|
|
|
|
|
|
my $xml = shift; |
|
23
|
|
|
|
|
|
|
my $tag = $class->_get_first_tag($xml); |
|
24
|
|
|
|
|
|
|
return ($tag eq 'feed'); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub init_empty { |
|
29
|
|
|
|
|
|
|
my ($feed, %args) = @_; |
|
30
|
|
|
|
|
|
|
$args{'Version'} ||= '1.0'; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$feed->{atom} = XML::Atom::Feed->new(%args); |
|
33
|
|
|
|
|
|
|
$feed; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub init_string { |
|
37
|
|
|
|
|
|
|
my $feed = shift; |
|
38
|
|
|
|
|
|
|
my($str) = @_; |
|
39
|
|
|
|
|
|
|
if ($str) { |
|
40
|
|
|
|
|
|
|
$feed->{atom} = XML::Atom::Feed->new(Stream => $str) |
|
41
|
|
|
|
|
|
|
or return $feed->error(XML::Atom::Feed->errstr); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
$feed; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub format { 'Atom' } |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub title { shift->{atom}->title(@_) } |
|
49
|
|
|
|
|
|
|
sub link { |
|
50
|
|
|
|
|
|
|
my $feed = shift; |
|
51
|
|
|
|
|
|
|
if (@_) { |
|
52
|
|
|
|
|
|
|
$feed->{atom}->add_link({ rel => 'alternate', href => $_[0], |
|
53
|
|
|
|
|
|
|
type => 'text/html', }); |
|
54
|
|
|
|
|
|
|
} else { |
|
55
|
|
|
|
|
|
|
my $l = first { !defined $_->rel || $_->rel eq 'alternate' } $feed->{atom}->link; |
|
56
|
|
|
|
|
|
|
$l ? $l->href : undef; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _rel_link { |
|
61
|
|
|
|
|
|
|
my $feed = shift; |
|
62
|
|
|
|
|
|
|
my $rel = shift; |
|
63
|
|
|
|
|
|
|
if (@_) { |
|
64
|
|
|
|
|
|
|
my $uri = shift; |
|
65
|
|
|
|
|
|
|
$feed->{atom}->add_link({type => "application/atom+xml", rel => $rel, href => $uri}); |
|
66
|
|
|
|
|
|
|
return $uri; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
else |
|
69
|
|
|
|
|
|
|
{ |
|
70
|
|
|
|
|
|
|
my $l; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
if ($rel eq 'self') { |
|
73
|
|
|
|
|
|
|
$l = first |
|
74
|
|
|
|
|
|
|
{ !defined $_->rel || $_->rel eq 'self' } |
|
75
|
|
|
|
|
|
|
$feed->{atom}->link; |
|
76
|
|
|
|
|
|
|
; |
|
77
|
|
|
|
|
|
|
} else { |
|
78
|
|
|
|
|
|
|
$l = first |
|
79
|
|
|
|
|
|
|
{ !defined $_->rel || $_->rel eq $rel } |
|
80
|
|
|
|
|
|
|
$feed->{atom}->link; |
|
81
|
|
|
|
|
|
|
; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
return $l ? $l->href : undef; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub self_link { shift->_rel_link( 'self', @_ ) } |
|
89
|
|
|
|
|
|
|
sub first_link { shift->_rel_link( 'first', @_ ) } |
|
90
|
|
|
|
|
|
|
sub last_link { shift->_rel_link( 'last', @_ ) } |
|
91
|
|
|
|
|
|
|
sub next_link { shift->_rel_link( 'next', @_ ) } |
|
92
|
|
|
|
|
|
|
sub previous_link { shift->_rel_link( 'previous', @_ ) }; |
|
93
|
|
|
|
|
|
|
sub current_link { shift->_rel_link( 'current', @_ ) } |
|
94
|
|
|
|
|
|
|
sub prev_archive_link { shift->_rel_link( 'prev-archive', @_ ) } |
|
95
|
|
|
|
|
|
|
sub next_archive_link { shift->_rel_link( 'next-archive', @_ ) } |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub description { shift->{atom}->tagline(@_) } |
|
98
|
|
|
|
|
|
|
sub copyright { shift->{atom}->copyright(@_) } |
|
99
|
|
|
|
|
|
|
sub language { shift->{atom}->language(@_) } |
|
100
|
|
|
|
|
|
|
sub generator { shift->{atom}->generator(@_) } |
|
101
|
|
|
|
|
|
|
sub id { shift->{atom}->id(@_) } |
|
102
|
|
|
|
|
|
|
sub updated { shift->{atom}->updated(@_) } |
|
103
|
|
|
|
|
|
|
sub add_link { shift->{atom}->add_link(@_) } |
|
104
|
|
|
|
|
|
|
sub base { shift->{atom}->base(@_) } |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub author { |
|
107
|
|
|
|
|
|
|
my $feed = shift; |
|
108
|
|
|
|
|
|
|
if (@_ && $_[0]) { |
|
109
|
|
|
|
|
|
|
my $person = XML::Atom::Person->new(Version => 1.0); |
|
110
|
|
|
|
|
|
|
$person->name($_[0]); |
|
111
|
|
|
|
|
|
|
$feed->{atom}->author($person); |
|
112
|
|
|
|
|
|
|
} else { |
|
113
|
|
|
|
|
|
|
$feed->{atom}->author ? $feed->{atom}->author->name : undef; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub image { |
|
118
|
|
|
|
|
|
|
return; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub modified { |
|
122
|
|
|
|
|
|
|
my $feed = shift; |
|
123
|
|
|
|
|
|
|
if (@_) { |
|
124
|
|
|
|
|
|
|
$feed->{atom}->modified(DateTime::Format::W3CDTF->format_datetime($_[0])); |
|
125
|
|
|
|
|
|
|
} else { |
|
126
|
|
|
|
|
|
|
return iso2dt($feed->{atom}->modified) if $feed->{atom}->modified; |
|
127
|
|
|
|
|
|
|
return iso2dt($feed->{atom}->updated) if $feed->{atom}->updated; |
|
128
|
|
|
|
|
|
|
return undef; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub entries { |
|
133
|
|
|
|
|
|
|
my @entries; |
|
134
|
|
|
|
|
|
|
for my $entry ($_[0]->{atom}->entries) { |
|
135
|
|
|
|
|
|
|
push @entries, XML::Feed::Entry::Format::Atom->wrap($entry); |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
@entries; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub add_entry { |
|
142
|
|
|
|
|
|
|
my $feed = shift; |
|
143
|
|
|
|
|
|
|
my $entry = shift || return; |
|
144
|
|
|
|
|
|
|
$entry = $feed->_convert_entry($entry); |
|
145
|
|
|
|
|
|
|
$feed->{atom}->add_entry($entry->unwrap); |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub as_xml { $_[0]->{atom}->as_xml } |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1; |