line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package CGI::RSS; |
3
|
|
|
|
|
|
|
|
4
|
8
|
|
|
8
|
|
29054
|
use strict; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
277
|
|
5
|
8
|
|
|
8
|
|
3721
|
use Date::Manip; |
|
8
|
|
|
|
|
1162466
|
|
|
8
|
|
|
|
|
1099
|
|
6
|
8
|
|
|
8
|
|
14742
|
use AutoLoader; |
|
8
|
|
|
|
|
10339
|
|
|
8
|
|
|
|
|
48
|
|
7
|
8
|
|
|
8
|
|
109251
|
use CGI; |
|
8
|
|
|
|
|
92948
|
|
|
8
|
|
|
|
|
52
|
|
8
|
8
|
|
|
8
|
|
426
|
use Carp; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
554
|
|
9
|
8
|
|
|
8
|
|
35
|
use Scalar::Util qw(blessed); |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
558
|
|
10
|
8
|
|
|
8
|
|
46
|
use base 'Exporter'; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
653
|
|
11
|
8
|
|
|
8
|
|
38
|
use vars qw'@TAGS @EXPORT_OK %EXPORT_TAGS'; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
434
|
|
12
|
|
|
|
|
|
|
|
13
|
8
|
|
|
8
|
|
35
|
no warnings; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
1639
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.9660'; |
16
|
|
|
|
|
|
|
our $pubDate_format = '%a, %d %b %Y %H:%M:%S %z'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Make sure we have a TZ |
19
|
|
|
|
|
|
|
unless( eval {Date_TimeZone(); 1} ) { |
20
|
|
|
|
|
|
|
$ENV{TZ} = "UTC" if $@ =~ m/unable to determine Time Zone/i; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub pubDate_format { |
24
|
1
|
|
|
1
|
0
|
823
|
my $class_or_instance = shift; |
25
|
1
|
|
|
|
|
1
|
my $proposed = shift; |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
2
|
$pubDate_format = $proposed; |
28
|
1
|
|
|
|
|
2
|
$pubDate_format |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub grok_args { |
32
|
39
|
100
|
|
39
|
0
|
111
|
my $this = blessed($_[0]) ? shift : __PACKAGE__->new; |
33
|
39
|
100
|
|
|
|
68
|
my $attrs = ref($_[0]) eq "HASH" ? shift : undef; |
34
|
|
|
|
|
|
|
|
35
|
39
|
100
|
|
|
|
61
|
if( ref($_[0]) eq "ARRAY" ) { |
36
|
4
|
|
|
|
|
7
|
return ($this,$attrs,undef,$_[0]); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
35
|
|
|
|
|
78
|
return ($this,$attrs,join(" ", @_),undef); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub setup_tag { |
43
|
264
|
|
|
264
|
0
|
271
|
my $tag = shift; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# try to mimick CGI.pm (which is very unfriendly about new tags now) |
46
|
|
|
|
|
|
|
|
47
|
8
|
|
|
8
|
|
40
|
no strict 'refs'; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
4618
|
|
48
|
|
|
|
|
|
|
|
49
|
264
|
|
|
|
|
474
|
my @these_tags = ($tag, "start_$tag", "end_$tag"); |
50
|
|
|
|
|
|
|
|
51
|
264
|
|
|
|
|
408
|
push @EXPORT_OK, @these_tags; |
52
|
264
|
|
|
|
|
210
|
push @{ $EXPORT_TAGS{all} }, @these_tags; |
|
264
|
|
|
|
|
476
|
|
53
|
264
|
|
|
|
|
217
|
push @{ $EXPORT_TAGS{tags} }, $tag; |
|
264
|
|
|
|
|
362
|
|
54
|
|
|
|
|
|
|
|
55
|
264
|
|
|
|
|
1035
|
*{ __PACKAGE__ . "::$tag" } = sub { |
56
|
39
|
|
|
39
|
|
63433
|
my ($this, $attrs, $contents, $subs) = grok_args(@_); |
57
|
39
|
|
|
|
|
33
|
my $res; |
58
|
|
|
|
|
|
|
|
59
|
39
|
100
|
|
|
|
44
|
if( $subs ) { |
60
|
4
|
100
|
|
|
|
6
|
$res = join("", map { $this->$tag( ($attrs ? $attrs : ()), $_ ) } @$subs ); |
|
16
|
|
|
|
|
38
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} else { |
63
|
35
|
|
|
|
|
30
|
$res = "<$tag"; |
64
|
|
|
|
|
|
|
|
65
|
35
|
100
|
|
|
|
56
|
if( $attrs ) { |
66
|
10
|
|
|
|
|
12
|
for(values %$attrs) { |
67
|
|
|
|
|
|
|
# XXX: this is a terrible way to do this, better than nothing for now |
68
|
10
|
|
|
|
|
15
|
s/(?
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
10
|
|
|
|
|
12
|
$res .= " " . join(" ", map {"$_=\"$attrs->{$_}\""} keys %$attrs); |
|
10
|
|
|
|
|
23
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
35
|
|
|
|
|
55
|
$res .= ">$contents$tag>"; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
39
|
|
|
|
|
143
|
return $res; |
78
|
264
|
|
|
|
|
847
|
}; |
79
|
|
|
|
|
|
|
|
80
|
264
|
|
|
|
|
852
|
*{ __PACKAGE__ . "::start_$tag" } = sub { |
81
|
0
|
|
|
0
|
|
0
|
my ($this, $attrs) = grok_args(@_); |
82
|
0
|
|
|
|
|
0
|
my $res = "<$tag"; |
83
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
0
|
if( $attrs ) { |
85
|
0
|
|
|
|
|
0
|
for(values %$attrs) { |
86
|
|
|
|
|
|
|
# XXX: this is a terrible way to do this, better than nothing for now |
87
|
0
|
|
|
|
|
0
|
s/(?
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
0
|
$res .= " " . join(" ", map {"$_=\"$attrs->{$_}\""} keys %$attrs); |
|
0
|
|
|
|
|
0
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
0
|
return $res . ">"; |
94
|
264
|
|
|
|
|
740
|
}; |
95
|
|
|
|
|
|
|
|
96
|
264
|
|
|
0
|
|
514
|
*{ __PACKAGE__ . "::end_$tag" } = sub { "$tag>" }; |
|
264
|
|
|
|
|
1270
|
|
|
0
|
|
|
|
|
0
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub AUTOLOAD { |
100
|
0
|
|
|
0
|
|
0
|
my $this = shift; |
101
|
0
|
|
|
|
|
0
|
our $AUTOLOAD; |
102
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
0
|
if( my ($fname) = $AUTOLOAD =~ m/::([^:]+)$/ ) { |
104
|
0
|
0
|
|
|
|
0
|
if( CGI->can($fname) ) { |
105
|
0
|
|
|
|
|
0
|
*{ __PACKAGE__ . "::$fname" } = sub { |
106
|
0
|
|
|
0
|
|
0
|
my $this = shift; |
107
|
0
|
|
|
|
|
0
|
return CGI->$fname(@_); |
108
|
|
|
|
|
|
|
} |
109
|
0
|
|
|
|
|
0
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
else { |
112
|
0
|
|
|
|
|
0
|
croak "can't figure out what to do with $fname() call"; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub new { |
118
|
11
|
|
|
11
|
0
|
1711
|
my $class = shift; |
119
|
11
|
|
|
|
|
70
|
my $this = bless {}, $class; |
120
|
|
|
|
|
|
|
|
121
|
11
|
|
|
|
|
25
|
return $this; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub date { |
125
|
2
|
|
|
2
|
0
|
3
|
my $this = shift; |
126
|
|
|
|
|
|
|
|
127
|
2
|
50
|
|
|
|
7
|
if( my $pd = ParseDate($_[-1]) ) { |
128
|
2
|
|
|
|
|
928
|
my $date = UnixDate($pd, $pubDate_format); |
129
|
2
|
|
|
|
|
980
|
return $this->pubDate($date); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
$this->pubDate(@_); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub header { |
136
|
0
|
|
|
0
|
0
|
|
my $this = shift; |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
my $charset = "UTF-8"; |
139
|
0
|
|
|
|
|
|
my $mime = "application/xml"; |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
eval { |
142
|
8
|
|
|
8
|
|
56
|
no warnings; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
2249
|
|
143
|
0
|
|
|
0
|
|
|
local $SIG{WARN} = sub{}; |
|
0
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
my %opts = @_; |
145
|
0
|
|
0
|
|
|
|
$charset = $opts{'-charset'} || $opts{charset} || $charset; |
146
|
0
|
|
0
|
|
|
|
$mime = $opts{'-type'} || $opts{type} || (@_==1 && $_[0]) || $mime; |
147
|
|
|
|
|
|
|
}; |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
return CGI::header(-type=>$mime, -charset=>$charset) . "\n\n"; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub begin_rss { |
153
|
0
|
|
|
0
|
0
|
|
my $this = shift; |
154
|
0
|
|
|
|
|
|
my $opts = $_[0]; |
155
|
0
|
0
|
|
|
|
|
$opts = {@_} unless ref $opts; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# NOTE: This isn't nearly as smart as CGI.pm's argument parsing... |
158
|
|
|
|
|
|
|
# I assume I could call it, but but I'm only mortal. |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
0
|
|
|
|
my $ver = $opts->{version} || "2.0"; |
161
|
0
|
|
|
|
|
|
my $ret = $this->start_rss({version=>$ver}); |
162
|
0
|
|
|
|
|
|
$ret .= $this->start_channel; |
163
|
0
|
0
|
|
|
|
|
$ret .= $this->link($opts->{link}) if exists $opts->{link}; |
164
|
0
|
0
|
|
|
|
|
$ret .= $this->title($opts->{title}) if exists $opts->{title}; |
165
|
0
|
0
|
|
|
|
|
$ret .= $this->description($opts->{desc}) if exists $opts->{desc}; |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
return $ret; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub finish_rss { |
171
|
0
|
|
|
0
|
0
|
|
my $this = shift; |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
return $this->end_channel . $this->end_rss; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
BEGIN { |
177
|
8
|
|
|
8
|
|
45
|
@TAGS = qw( |
178
|
|
|
|
|
|
|
rss channel item |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
title link description |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
language copyright managingEditor webMaster pubDate lastBuildDate category generator docs |
183
|
|
|
|
|
|
|
cloud ttl image rating textInput skipHours skipDays |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
link description author category comments enclosure guid pubDate source |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
pubDate url |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
|
190
|
8
|
|
|
|
|
26
|
setup_tag($_) for @TAGS; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
1; |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
__END__ |