line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::FeedWriter::RSS20;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
962
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
4
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw( XML::FeedWriter::Base );
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
425
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->_alias({
|
9
|
|
|
|
|
|
|
creator => 'dc:creator',
|
10
|
|
|
|
|
|
|
pubdate => 'pubDate',
|
11
|
|
|
|
|
|
|
published => 'pubDate',
|
12
|
|
|
|
|
|
|
lastbuilddate => 'lastBuildDate',
|
13
|
|
|
|
|
|
|
updated => 'lastBuildDate',
|
14
|
|
|
|
|
|
|
webmaster => 'webMaster',
|
15
|
|
|
|
|
|
|
managingeditor => 'managingEditor',
|
16
|
|
|
|
|
|
|
editor => 'managingEditor',
|
17
|
|
|
|
|
|
|
content => 'content:encoded',
|
18
|
|
|
|
|
|
|
summary => 'description',
|
19
|
|
|
|
|
|
|
});
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__PACKAGE__->_requires({
|
22
|
|
|
|
|
|
|
channel => [qw( description link title )],
|
23
|
|
|
|
|
|
|
cloud => [qw( domain path port protocol registerProcedure )],
|
24
|
|
|
|
|
|
|
image => [qw( link title url )],
|
25
|
|
|
|
|
|
|
textinput => [qw( description link name title )],
|
26
|
|
|
|
|
|
|
enclosure => [qw( length type url )],
|
27
|
|
|
|
|
|
|
});
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__PACKAGE__->_sort_order({
|
30
|
|
|
|
|
|
|
title => 10,
|
31
|
|
|
|
|
|
|
link => 9,
|
32
|
|
|
|
|
|
|
description => 8,
|
33
|
|
|
|
|
|
|
creator => 7,
|
34
|
|
|
|
|
|
|
author => 7,
|
35
|
|
|
|
|
|
|
pubDate => 6,
|
36
|
|
|
|
|
|
|
guid => 5,
|
37
|
|
|
|
|
|
|
});
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _extra_options {
|
40
|
|
|
|
|
|
|
my ($self, $options) = @_;
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $no_cdata = delete $options->{no_cdata};
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$self->{_use_cdata} = !$no_cdata;
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _root_element {
|
48
|
|
|
|
|
|
|
my ($self, $modules) = @_;
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$self->xml->startTag( rss =>
|
51
|
|
|
|
|
|
|
version => '2.0',
|
52
|
|
|
|
|
|
|
'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
|
53
|
|
|
|
|
|
|
'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/',
|
54
|
|
|
|
|
|
|
%{ $modules },
|
55
|
|
|
|
|
|
|
);
|
56
|
|
|
|
|
|
|
}
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _channel {
|
59
|
|
|
|
|
|
|
my ($self, $channel) = @_;
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$channel->{lastBuildDate} ||= $self->dtx->for_rss20;
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$self->xml->startTag('channel');
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
foreach my $key ( $self->_sort_keys( $channel ) ) {
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
if ( $key eq 'category' ) {
|
68
|
|
|
|
|
|
|
$self->_duplicable_elements( $key => $channel->{$key} );
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
elsif ( $key eq 'cloud' ) {
|
72
|
|
|
|
|
|
|
$self->_empty_element( $key => $channel->{$key} );
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
elsif ( $key =~ /image|textinput/ ) {
|
76
|
|
|
|
|
|
|
$self->_element_with_children( $key => $channel->{$key} );
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
elsif ( $key =~ /lastBuildDate|pubDate/ ) {
|
80
|
|
|
|
|
|
|
$self->_datetime_element( $key => $channel->{$key} );
|
81
|
|
|
|
|
|
|
}
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
elsif ( my ($type) = $key =~ /skip(Day|Hour)s/ ) {
|
84
|
|
|
|
|
|
|
$self->_element_with_duplicable_children(
|
85
|
|
|
|
|
|
|
$key => $channel->{$key}, lc $type
|
86
|
|
|
|
|
|
|
);
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
else {
|
90
|
|
|
|
|
|
|
$self->_data_element( $key => $channel->{$key} );
|
91
|
|
|
|
|
|
|
}
|
92
|
|
|
|
|
|
|
}
|
93
|
|
|
|
|
|
|
}
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub add_items {
|
96
|
|
|
|
|
|
|
my ($self, @items) = @_;
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
croak "can't add items any longer" if $self->_closed;
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
foreach my $i ( @items ) {
|
101
|
|
|
|
|
|
|
my %item = $self->_canonize( $i );
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$self->xml->startTag('item');
|
104
|
|
|
|
|
|
|
foreach my $key ( $self->_sort_keys( \%item ) ) {
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
if ( $key eq 'pubDate' ) {
|
107
|
|
|
|
|
|
|
$self->_datetime_element( $key => $item{$key} );
|
108
|
|
|
|
|
|
|
}
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
elsif ( $key eq 'description' ) {
|
111
|
|
|
|
|
|
|
$self->_cdata_element( $key => $item{$key} );
|
112
|
|
|
|
|
|
|
}
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
elsif ( $key eq 'enclosure' ) {
|
115
|
|
|
|
|
|
|
$self->_empty_element( $key => $item{$key} );
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
elsif ( $key eq 'category' ) {
|
119
|
|
|
|
|
|
|
$self->_duplicable_elements( $key => $item{$key} );
|
120
|
|
|
|
|
|
|
}
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
else {
|
123
|
|
|
|
|
|
|
$self->_data_element( $key => $item{$key} );
|
124
|
|
|
|
|
|
|
}
|
125
|
|
|
|
|
|
|
}
|
126
|
|
|
|
|
|
|
$self->xml->endTag('item');
|
127
|
|
|
|
|
|
|
}
|
128
|
|
|
|
|
|
|
}
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub close {
|
131
|
|
|
|
|
|
|
my $self = shift;
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
return if $self->_closed;
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$self->xml->endTag('channel');
|
136
|
|
|
|
|
|
|
$self->xml->endTag('rss');
|
137
|
|
|
|
|
|
|
$self->xml->end;
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$self->_closed(1);
|
140
|
|
|
|
|
|
|
}
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1;
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__END__
|