| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package ZConf::RSS; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
21624
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
85
|
|
|
4
|
2
|
|
|
2
|
|
14
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
74
|
|
|
5
|
2
|
|
|
2
|
|
1479
|
use ZConf; |
|
|
2
|
|
|
|
|
166463
|
|
|
|
2
|
|
|
|
|
61
|
|
|
6
|
2
|
|
|
2
|
|
2626
|
use XML::FeedPP; |
|
|
2
|
|
|
|
|
60145
|
|
|
|
2
|
|
|
|
|
70
|
|
|
7
|
2
|
|
|
2
|
|
27
|
use Text::NeatTemplate; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
50
|
|
|
8
|
2
|
|
|
2
|
|
1975
|
use HTML::FormatText::WithLinks; |
|
|
2
|
|
|
|
|
113592
|
|
|
|
2
|
|
|
|
|
11644
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
ZConf::RSS - ZConf backed RSS fetching. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 2.2.0 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '2.2.0'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use ZConf::RSS; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $zcrss = ZConf::RSS->new(); |
|
28
|
|
|
|
|
|
|
... |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 new |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This initializes it. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
One arguement is taken and that is a hash value. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head3 hash values |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head4 zconf |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This is the a ZConf object. If not passed, another one will be created. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $zcrss=ZConf::RSS->new(); |
|
45
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
46
|
|
|
|
|
|
|
print "Error!\n"; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new { |
|
52
|
0
|
|
|
0
|
1
|
|
my %args; |
|
53
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
|
54
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
|
0
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
0
|
|
|
|
|
|
my $function='new'; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $self={error=>undef, |
|
59
|
|
|
|
|
|
|
errorString=>undef, |
|
60
|
|
|
|
|
|
|
zconfconfig=>'rss', |
|
61
|
|
|
|
|
|
|
perror=>1, |
|
62
|
|
|
|
|
|
|
module=>'ZConf-RSS', |
|
63
|
|
|
|
|
|
|
}; |
|
64
|
0
|
|
|
|
|
|
bless $self; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#get the ZConf object |
|
67
|
0
|
0
|
|
|
|
|
if (!defined($args{zconf})) { |
|
68
|
|
|
|
|
|
|
#creates the ZConf object |
|
69
|
0
|
|
|
|
|
|
$self->{zconf}=ZConf->new(); |
|
70
|
0
|
0
|
|
|
|
|
if(defined($self->{zconf}->{error})){ |
|
71
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
72
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
73
|
0
|
|
|
|
|
|
$self->{errorString}="Could not initiate ZConf. It failed with '" |
|
74
|
|
|
|
|
|
|
.$self->{zconf}->{error}."', '". |
|
75
|
|
|
|
|
|
|
$self->{zconf}->{errorString}."'"; |
|
76
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
77
|
0
|
|
|
|
|
|
return $self; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
}else { |
|
80
|
0
|
|
|
|
|
|
$self->{zconf}=$args{zconf}; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#create the config if it does not exist |
|
84
|
|
|
|
|
|
|
#if it does exist, make sure the set we are using exists |
|
85
|
0
|
|
|
|
|
|
my $returned = $self->{zconf}->configExists($self->{zconfconfig}); |
|
86
|
0
|
0
|
|
|
|
|
if($self->{zconf}->{error}){ |
|
87
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
88
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
89
|
0
|
|
|
|
|
|
$self->{errorString}="Checking if '".$self->{zconfconfig}."' exists failed. error='". |
|
90
|
|
|
|
|
|
|
$self->{zconf}->{error}."', errorString='". |
|
91
|
|
|
|
|
|
|
$self->{zconf}->{errorString}."'"; |
|
92
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.':'.$self->{errorString}); |
|
93
|
0
|
|
|
|
|
|
return $self; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#initiate the config if it does not exist |
|
97
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
98
|
|
|
|
|
|
|
#init it |
|
99
|
0
|
|
|
|
|
|
$self->init; |
|
100
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
101
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
102
|
0
|
|
|
|
|
|
$self->{errorString}='Init failed.'; |
|
103
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
104
|
0
|
|
|
|
|
|
return $self; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
}else { |
|
107
|
|
|
|
|
|
|
#if we have a set, make sure we also have a set that will be loaded |
|
108
|
0
|
|
|
|
|
|
$returned=$self->{zconf}->defaultSetExists($self->{zconfconfig}); |
|
109
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
110
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
111
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
112
|
0
|
|
|
|
|
|
$self->{errorString}="Checking if '".$self->{zconfconfig}."' exists failed. error='". |
|
113
|
|
|
|
|
|
|
$self->{zconf}->{error}."', errorString='". |
|
114
|
|
|
|
|
|
|
$self->{zconf}->{errorString}."'"; |
|
115
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
116
|
0
|
|
|
|
|
|
return $self; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
#if we don't have a default set, initialize it |
|
120
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
121
|
|
|
|
|
|
|
#init it |
|
122
|
0
|
|
|
|
|
|
$self->init; |
|
123
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
124
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
125
|
0
|
|
|
|
|
|
$self->{errorString}='Init failed.'; |
|
126
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
127
|
0
|
|
|
|
|
|
return $self; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
#read the config |
|
133
|
0
|
|
|
|
|
|
$self->{zconf}->read({config=>$self->{zconfconfig}}); |
|
134
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
135
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
136
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
137
|
0
|
|
|
|
|
|
$self->{errorString}="Reading the ZConf config '".$self->{zconfconfig}."' failed. error='". |
|
138
|
|
|
|
|
|
|
$self->{zconf}->{error}."', errorString='". |
|
139
|
|
|
|
|
|
|
$self->{zconf}->{errorString}."'"; |
|
140
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
141
|
0
|
|
|
|
|
|
return $self; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
return $self; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 feedExists |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This makes sure a specified template exists. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $returned=$zcrss->feedExists('someFeed'); |
|
153
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
154
|
|
|
|
|
|
|
print "Error!\n"; |
|
155
|
|
|
|
|
|
|
}else{ |
|
156
|
|
|
|
|
|
|
if($returned){ |
|
157
|
|
|
|
|
|
|
print "It exists.\n"; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub feedExists{ |
|
164
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
165
|
0
|
|
|
|
|
|
my $template=$_[1]; |
|
166
|
0
|
|
|
|
|
|
my $function='feedExists'; |
|
167
|
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
$self->errorblank; |
|
169
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
170
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
my @templates=$self->listFeeds; |
|
175
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
176
|
0
|
|
|
|
|
|
warn('ZConf-RSS feedExists:2: listFeeds errored'); |
|
177
|
0
|
|
|
|
|
|
return undef; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
my $int=0; |
|
181
|
0
|
|
|
|
|
|
while (defined($templates[$int])) { |
|
182
|
0
|
0
|
|
|
|
|
if ($templates[$int] eq $template) { |
|
183
|
0
|
|
|
|
|
|
return 1; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
$int++; |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
|
return undef; |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 delFeed |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
This removes a feed. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
One arguement is required and that is the name of the feed. |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
$zcrss->delFeed('someFeed'); |
|
199
|
|
|
|
|
|
|
if($self->{error}){ |
|
200
|
|
|
|
|
|
|
print "Error!\n"; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub delFeed{ |
|
206
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
207
|
0
|
|
|
|
|
|
my $feed=$_[1]; |
|
208
|
0
|
|
|
|
|
|
my $function='delFeed'; |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
#blanks any previous errors |
|
211
|
0
|
|
|
|
|
|
$self->errorblank; |
|
212
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
213
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
#makes sure a feed is specified |
|
217
|
0
|
0
|
|
|
|
|
if (!defined($feed)) { |
|
218
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
219
|
0
|
|
|
|
|
|
$self->{errorString}='No feed specified.'; |
|
220
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
221
|
0
|
|
|
|
|
|
return undef; |
|
222
|
|
|
|
|
|
|
} |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
#make sure it exists |
|
225
|
0
|
0
|
|
|
|
|
if (!$self->feedExists($feed)) { |
|
226
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
227
|
0
|
|
|
|
|
|
$self->{errorString}='The feed, "'.$feed.'", does not exist'; |
|
228
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
229
|
0
|
|
|
|
|
|
return undef; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
#remove them |
|
233
|
0
|
|
|
|
|
|
my @deleted=$self->{zconf}->regexVarDel('rss', '^feeds\/'.quotemeta($feed).'\/'); |
|
234
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
235
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
236
|
0
|
|
|
|
|
|
$self->{errorString}="regexVarDel errored ". |
|
237
|
|
|
|
|
|
|
"error='".$self->{zconf}->{error}."' errorString='" |
|
238
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
239
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
240
|
0
|
|
|
|
|
|
return undef; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
#saves it |
|
244
|
0
|
|
|
|
|
|
$self->{zconf}->writeSetFromLoadedConfig({config=>'rss'}); |
|
245
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
246
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
247
|
0
|
|
|
|
|
|
$self->{errorString}=" writeSetFromLoadedConfig for 'rss'.". |
|
248
|
|
|
|
|
|
|
"failed with '".$self->{zconf}->{error}."', '" |
|
249
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
250
|
|
|
|
|
|
|
#remove any that were added |
|
251
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
252
|
0
|
|
|
|
|
|
return undef; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
|
|
255
|
0
|
|
|
|
|
|
return 1; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head2 delTemplate |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
This removes a template. |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
One arguement is taken and it is the template name. |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
$zcrss->delTemplate('someTemplate'); |
|
265
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
266
|
|
|
|
|
|
|
print "Error!\n"; |
|
267
|
|
|
|
|
|
|
} |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=cut |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub delTemplate{ |
|
272
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
273
|
0
|
|
|
|
|
|
my $template=$_[1]; |
|
274
|
0
|
|
|
|
|
|
my $function='delFeed'; |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
#blanks any previous errors |
|
277
|
0
|
|
|
|
|
|
$self->errorblank; |
|
278
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
279
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
280
|
|
|
|
|
|
|
} |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
#makes sure a feed is specified |
|
283
|
0
|
0
|
|
|
|
|
if (!defined($template)) { |
|
284
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
285
|
0
|
|
|
|
|
|
$self->{errorString}='No template specified.'; |
|
286
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
287
|
0
|
|
|
|
|
|
return undef; |
|
288
|
|
|
|
|
|
|
} |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
#make sure it exists |
|
291
|
0
|
|
|
|
|
|
my $returned=$self->templateExists($template); |
|
292
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
293
|
0
|
|
|
|
|
|
$self->{error}=7; |
|
294
|
0
|
|
|
|
|
|
$self->{errorString}='The template, "'.$template.'", does not exist'; |
|
295
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
296
|
0
|
|
|
|
|
|
return undef; |
|
297
|
|
|
|
|
|
|
} |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
#remove them |
|
300
|
0
|
|
|
|
|
|
my @deleted=$self->{zconf}->regexVarDel('rss', '^templates\/'.quotemeta($template).'$'); |
|
301
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
302
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
303
|
0
|
|
|
|
|
|
$self->{errorString}="regexVarDel errored ". |
|
304
|
|
|
|
|
|
|
"error='".$self->{zconf}->{error}."' errorString='" |
|
305
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
306
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
307
|
0
|
|
|
|
|
|
return undef; |
|
308
|
|
|
|
|
|
|
} |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
#saves it |
|
311
|
0
|
|
|
|
|
|
$self->{zconf}->writeSetFromLoadedConfig({config=>'rss'}); |
|
312
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
313
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
314
|
0
|
|
|
|
|
|
$self->{errorString}=" writeSetFromLoadedConfig for 'rss'.". |
|
315
|
|
|
|
|
|
|
"failed with '".$self->{zconf}->{error}."', '" |
|
316
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
317
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
318
|
0
|
|
|
|
|
|
return undef; |
|
319
|
|
|
|
|
|
|
} |
|
320
|
|
|
|
|
|
|
|
|
321
|
0
|
|
|
|
|
|
return 1; |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
=head2 getFeed |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
This creates a 'XML::FeedPP' object based on a feed. |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
One arguement is taken and it is the name of the feed. |
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
my $feedobj=$zcrss->getFeed; |
|
331
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
332
|
|
|
|
|
|
|
print "Error!\n"; |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
=cut |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
sub getFeed{ |
|
338
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
339
|
0
|
|
|
|
|
|
my $feed=$_[1]; |
|
340
|
0
|
|
|
|
|
|
my $function='getFeed'; |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
#blanks any previous errors |
|
343
|
0
|
|
|
|
|
|
$self->errorblank; |
|
344
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
345
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
#get the arguements for the feed |
|
349
|
0
|
|
|
|
|
|
my %args=$self->getFeedArgs($feed); |
|
350
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
351
|
0
|
|
|
|
|
|
warn('ZConf-RSS getFeed: getFeedArgs for "'.$feed.'" failed'); |
|
352
|
0
|
|
|
|
|
|
return undef; |
|
353
|
|
|
|
|
|
|
} |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
# |
|
356
|
0
|
|
|
|
|
|
my $feedobj = XML::FeedPP->new($args{feed}); |
|
357
|
0
|
0
|
|
|
|
|
if (!defined($feedobj)) { |
|
358
|
0
|
|
|
|
|
|
$self->{error}=7; |
|
359
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to load the feed "'.$feed.'"'; |
|
360
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
361
|
0
|
|
|
|
|
|
return undef; |
|
362
|
|
|
|
|
|
|
} |
|
363
|
|
|
|
|
|
|
|
|
364
|
0
|
|
|
|
|
|
return $feedobj; |
|
365
|
|
|
|
|
|
|
} |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
=head2 getFeedArgs |
|
368
|
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
This fetches the arguements for the feed. |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
my %args=$zcrss->getFeedArgs('someFeed'); |
|
372
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
373
|
|
|
|
|
|
|
print "Error!\n"; |
|
374
|
|
|
|
|
|
|
} |
|
375
|
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=cut |
|
377
|
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
sub getFeedArgs{ |
|
379
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
380
|
0
|
|
|
|
|
|
my $feed=$_[1]; |
|
381
|
0
|
|
|
|
|
|
my $function='getFeedArgs'; |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
#blanks any previous errors |
|
384
|
0
|
|
|
|
|
|
$self->errorblank; |
|
385
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
386
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
387
|
|
|
|
|
|
|
} |
|
388
|
|
|
|
|
|
|
|
|
389
|
0
|
0
|
|
|
|
|
if (!defined($feed)) { |
|
390
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
391
|
0
|
|
|
|
|
|
$self->{errorString}='No feed name given.'; |
|
392
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
393
|
0
|
|
|
|
|
|
return undef; |
|
394
|
|
|
|
|
|
|
} |
|
395
|
|
|
|
|
|
|
|
|
396
|
0
|
0
|
|
|
|
|
if (!$self->feedExists($feed)) { |
|
397
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
398
|
0
|
|
|
|
|
|
$self->{errorString}='The feed, "'.$feed.'", does not exist'; |
|
399
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
400
|
0
|
|
|
|
|
|
return undef; |
|
401
|
|
|
|
|
|
|
} |
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
# |
|
404
|
0
|
0
|
|
|
|
|
if ($feed=~/\//) { |
|
405
|
0
|
|
|
|
|
|
warn('ZConf-RSS getFeedArgs:4: The feed name "'.$feed.'" matches /\//'); |
|
406
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
407
|
0
|
|
|
|
|
|
$self->{errorString}='The feed name "'.$feed.'" matches /\//'; |
|
408
|
0
|
|
|
|
|
|
return undef; |
|
409
|
|
|
|
|
|
|
} |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
#blanks any previous variables |
|
412
|
0
|
|
|
|
|
|
my %vars=$self->{zconf}->regexVarGet('rss', '^feeds/'.$feed.'/'); |
|
413
|
0
|
0
|
|
|
|
|
if($self->{zconf}->{error}){ |
|
414
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
415
|
0
|
|
|
|
|
|
$self->{errorString}='regexVarGet failed for "rss".'. |
|
416
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
417
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
418
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
419
|
0
|
|
|
|
|
|
return undef; |
|
420
|
|
|
|
|
|
|
} |
|
421
|
|
|
|
|
|
|
|
|
422
|
0
|
|
|
|
|
|
my @keys=keys(%vars); |
|
423
|
0
|
|
|
|
|
|
my $int=0; |
|
424
|
0
|
|
|
|
|
|
my %args; |
|
425
|
0
|
|
|
|
|
|
while (defined($keys[$int])) { |
|
426
|
0
|
|
|
|
|
|
my @split=split(/\//, $keys[$int], 3); |
|
427
|
0
|
|
|
|
|
|
$args{$split[2]}=$vars{$keys[$int]}; |
|
428
|
|
|
|
|
|
|
|
|
429
|
0
|
|
|
|
|
|
$int++; |
|
430
|
|
|
|
|
|
|
} |
|
431
|
|
|
|
|
|
|
|
|
432
|
0
|
|
|
|
|
|
return %args; |
|
433
|
|
|
|
|
|
|
} |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=head2 getFeedAsTemplatedString |
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
This fetches a feed, processes it using the specified templates |
|
438
|
|
|
|
|
|
|
and returns a string. |
|
439
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
my $string=$zcrss->getFeedAsTemplatedString('someFeed'); |
|
441
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
442
|
|
|
|
|
|
|
print "Error!\n"; |
|
443
|
|
|
|
|
|
|
} |
|
444
|
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
=cut |
|
446
|
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
sub getFeedAsTemplatedString{ |
|
448
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
449
|
0
|
|
|
|
|
|
my $feed=$_[1]; |
|
450
|
0
|
|
|
|
|
|
my $function='getFeedAsTemplatedString'; |
|
451
|
|
|
|
|
|
|
|
|
452
|
0
|
|
|
|
|
|
$self->errorblank; |
|
453
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
454
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
455
|
|
|
|
|
|
|
} |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
#get the arguements for the feed |
|
458
|
0
|
|
|
|
|
|
my %args=$self->getFeedArgs($feed); |
|
459
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
460
|
0
|
|
|
|
|
|
warn('ZConf-RSS getFeed: getFeedArgs for "'.$feed.'" failed'); |
|
461
|
0
|
|
|
|
|
|
return undef; |
|
462
|
|
|
|
|
|
|
} |
|
463
|
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
#gets the feed object |
|
465
|
0
|
|
|
|
|
|
my $fo=$self->getFeed($feed); |
|
466
|
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
#this is the hash that will be passed to the template system |
|
468
|
0
|
|
|
|
|
|
my %thash=(ctitle=>'', cdesc=>'', cpubdate=>'', ccopyright=>'', clink=>'', |
|
469
|
|
|
|
|
|
|
clang=>'', cimage=>'', ititle=>'', idesc=>'', ipubdate=>'', |
|
470
|
|
|
|
|
|
|
icat=>'', iauthor=>'', iguid=>'', ilink=>''); |
|
471
|
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
#used for checking to make sure everything is defined |
|
473
|
0
|
|
|
|
|
|
my @hashItems=keys(%thash); |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
#gets the channel stuff |
|
476
|
0
|
|
|
|
|
|
$thash{ctitle}=$fo->title(); |
|
477
|
0
|
|
|
|
|
|
$thash{cdesc}=$fo->description(); |
|
478
|
0
|
|
|
|
|
|
$thash{cpubdate}=$fo->pubDate(); |
|
479
|
0
|
|
|
|
|
|
$thash{ccopyright}=$fo->copyright(); |
|
480
|
0
|
|
|
|
|
|
$thash{clink}=$fo->link(); |
|
481
|
0
|
|
|
|
|
|
$thash{clang}=$fo->language(); |
|
482
|
0
|
|
|
|
|
|
$thash{cimage}=$fo->image(); |
|
483
|
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
#makes sure everything in the hash is defined |
|
485
|
0
|
|
|
|
|
|
foreach (@hashItems) { |
|
486
|
0
|
0
|
|
|
|
|
if (!defined($thash{$_})) { |
|
487
|
0
|
|
|
|
|
|
$thash{$_}=''; |
|
488
|
|
|
|
|
|
|
} |
|
489
|
|
|
|
|
|
|
} |
|
490
|
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
#get the templates |
|
492
|
0
|
|
|
|
|
|
my $topT=$self->getTemplate($args{topTemplate}); |
|
493
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
494
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': getTemplate errored'); |
|
495
|
0
|
|
|
|
|
|
return undef; |
|
496
|
|
|
|
|
|
|
} |
|
497
|
0
|
|
|
|
|
|
my $itemT=$self->getTemplate($args{itemTemplate}); |
|
498
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
499
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': getTemplate errored'); |
|
500
|
0
|
|
|
|
|
|
return undef; |
|
501
|
|
|
|
|
|
|
} |
|
502
|
0
|
|
|
|
|
|
my $bottomT=$self->getTemplate($args{bottomTemplate}); |
|
503
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
504
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': getTemplate errored'); |
|
505
|
0
|
|
|
|
|
|
return undef; |
|
506
|
|
|
|
|
|
|
} |
|
507
|
|
|
|
|
|
|
|
|
508
|
0
|
|
|
|
|
|
my $tobj = Text::NeatTemplate->new(); |
|
509
|
|
|
|
|
|
|
|
|
510
|
0
|
|
|
|
|
|
my $string=$tobj->fill_in(data_hash=>\%thash, template=>$topT); |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
#process each item |
|
513
|
0
|
|
|
|
|
|
foreach my $item ($fo->get_item()) { |
|
514
|
|
|
|
|
|
|
#gets the channel stuff |
|
515
|
0
|
|
|
|
|
|
$thash{ititle}=$item->title(); |
|
516
|
0
|
|
|
|
|
|
$thash{idesc}=$item->description(); |
|
517
|
0
|
|
|
|
|
|
$thash{ipubdate}=$item->pubDate(); |
|
518
|
0
|
|
|
|
|
|
$thash{ilink}=$item->link(); |
|
519
|
|
|
|
|
|
|
#it will either return a string or array ref |
|
520
|
0
|
|
|
|
|
|
my $categories=$item->category; |
|
521
|
0
|
0
|
|
|
|
|
if (ref($categories) eq 'ARRAY') { |
|
522
|
0
|
|
|
|
|
|
$categories=join(', ', @{$categories}); |
|
|
0
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
} |
|
524
|
0
|
|
|
|
|
|
$thash{icat}=$categories; |
|
525
|
0
|
|
|
|
|
|
$thash{iauthor}=$item->author(); |
|
526
|
0
|
|
|
|
|
|
$thash{iguid}=$item->guid(); |
|
527
|
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
#makes sure everything in the hash is defined |
|
529
|
0
|
|
|
|
|
|
foreach (@hashItems) { |
|
530
|
0
|
0
|
|
|
|
|
if (!defined($thash{$_})) { |
|
531
|
0
|
|
|
|
|
|
$thash{$_}=''; |
|
532
|
|
|
|
|
|
|
} |
|
533
|
|
|
|
|
|
|
} |
|
534
|
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
#If you don't put this here, it add each previous link as well. :( |
|
536
|
0
|
|
|
|
|
|
my $f = HTML::FormatText::WithLinks->new(unique_links=>'1'); |
|
537
|
0
|
|
|
|
|
|
$thash{idescFTWL}=$f->parse($thash{idesc}); |
|
538
|
|
|
|
|
|
|
|
|
539
|
0
|
|
|
|
|
|
my $itemS=$tobj->fill_in(data_hash=>\%thash, template=>$itemT); |
|
540
|
|
|
|
|
|
|
|
|
541
|
0
|
|
|
|
|
|
$string=$string.$itemS; |
|
542
|
|
|
|
|
|
|
} |
|
543
|
|
|
|
|
|
|
|
|
544
|
0
|
|
|
|
|
|
$string=$string.$tobj->fill_in(data_hash=>\%thash, template=>$bottomT); |
|
545
|
|
|
|
|
|
|
|
|
546
|
0
|
|
|
|
|
|
return $string; |
|
547
|
|
|
|
|
|
|
} |
|
548
|
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=head2 getSet |
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
This gets what the current set is. |
|
552
|
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
my $set=$zcrss->getSet; |
|
554
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
555
|
|
|
|
|
|
|
print "Error!\n"; |
|
556
|
|
|
|
|
|
|
} |
|
557
|
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
=cut |
|
559
|
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
sub getSet{ |
|
561
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
562
|
0
|
|
|
|
|
|
my $function='getSet'; |
|
563
|
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
#blanks any previous errors |
|
565
|
0
|
|
|
|
|
|
$self->errorblank; |
|
566
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
567
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
568
|
|
|
|
|
|
|
} |
|
569
|
|
|
|
|
|
|
|
|
570
|
0
|
|
|
|
|
|
my $set=$self->{zconf}->getSet('rss'); |
|
571
|
0
|
0
|
|
|
|
|
if($self->{zconf}->{error}){ |
|
572
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
573
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error getting the loaded set the config "rss".'. |
|
574
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
575
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
576
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
577
|
0
|
|
|
|
|
|
return undef; |
|
578
|
|
|
|
|
|
|
} |
|
579
|
|
|
|
|
|
|
|
|
580
|
0
|
|
|
|
|
|
return $set; |
|
581
|
|
|
|
|
|
|
} |
|
582
|
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
=head2 getTemplate |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
This returns a template as a string. |
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
my $template=$zcrss->getTemplate('some/template'); |
|
588
|
|
|
|
|
|
|
if ($zcrss->{error}) { |
|
589
|
|
|
|
|
|
|
print "Error!\n"; |
|
590
|
|
|
|
|
|
|
} |
|
591
|
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
=cut |
|
593
|
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
sub getTemplate{ |
|
595
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
596
|
0
|
|
|
|
|
|
my $template=$_[1]; |
|
597
|
0
|
|
|
|
|
|
my $function='getTemplate'; |
|
598
|
|
|
|
|
|
|
|
|
599
|
0
|
|
|
|
|
|
$self->errorblank; |
|
600
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
601
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
602
|
|
|
|
|
|
|
} |
|
603
|
|
|
|
|
|
|
|
|
604
|
0
|
0
|
|
|
|
|
if (!defined($template)) { |
|
605
|
0
|
|
|
|
|
|
$self->{error}=6; |
|
606
|
0
|
|
|
|
|
|
$self->{errorstring}='No template specified.'; |
|
607
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
608
|
0
|
|
|
|
|
|
return undef; |
|
609
|
|
|
|
|
|
|
} |
|
610
|
|
|
|
|
|
|
|
|
611
|
0
|
|
|
|
|
|
my $returned=$self->templateExists($template); |
|
612
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
613
|
0
|
|
|
|
|
|
warn('ZConf-RSS getTemplate: templateExists errored'); |
|
614
|
0
|
|
|
|
|
|
return undef; |
|
615
|
|
|
|
|
|
|
} |
|
616
|
|
|
|
|
|
|
|
|
617
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
618
|
0
|
|
|
|
|
|
$self->{error}=7; |
|
619
|
0
|
|
|
|
|
|
$self->{errorString}='The template, "'.$template.'", does not exist'; |
|
620
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
621
|
0
|
|
|
|
|
|
return undef; |
|
622
|
|
|
|
|
|
|
} |
|
623
|
|
|
|
|
|
|
|
|
624
|
0
|
|
|
|
|
|
return $self->{zconf}{conf}{rss}{'templates/'.$template}; |
|
625
|
|
|
|
|
|
|
} |
|
626
|
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
=head2 init |
|
628
|
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
This initializes it or a new set. |
|
630
|
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
If the specified set already exists, it will be reset. |
|
632
|
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
One arguement is required and it is the name of the set. If |
|
634
|
|
|
|
|
|
|
it is not defined, ZConf will use the default one. |
|
635
|
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
#creates a new set named foo |
|
637
|
|
|
|
|
|
|
$zcw->init('foo'); |
|
638
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
639
|
|
|
|
|
|
|
print "Error!\n"; |
|
640
|
|
|
|
|
|
|
} |
|
641
|
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
#creates a new set with ZConf choosing it's name |
|
643
|
|
|
|
|
|
|
$zcrss->init(); |
|
644
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
645
|
|
|
|
|
|
|
print "Error!\n"; |
|
646
|
|
|
|
|
|
|
} |
|
647
|
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
=cut |
|
649
|
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
sub init{ |
|
651
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
652
|
0
|
|
|
|
|
|
my $set=$_[1]; |
|
653
|
0
|
|
|
|
|
|
my $function='init'; |
|
654
|
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
#blanks any previous errors |
|
656
|
0
|
|
|
|
|
|
$self->errorblank; |
|
657
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
658
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
659
|
|
|
|
|
|
|
} |
|
660
|
|
|
|
|
|
|
|
|
661
|
0
|
|
|
|
|
|
my $returned = $self->{zconf}->configExists("rss"); |
|
662
|
0
|
0
|
|
|
|
|
if(defined($self->{zconf}->{error})){ |
|
663
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
664
|
0
|
|
|
|
|
|
$self->{errorString}="Could not check if the config 'rss' exists.". |
|
665
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->{error}."', '" |
|
666
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
667
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
668
|
0
|
|
|
|
|
|
return undef; |
|
669
|
|
|
|
|
|
|
} |
|
670
|
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
#create the config if it does not exist |
|
672
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
673
|
0
|
|
|
|
|
|
$self->{zconf}->createConfig("rss"); |
|
674
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
675
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
676
|
0
|
|
|
|
|
|
$self->{errorString}="Could not create the ZConf config 'rss'.". |
|
677
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->{rss}."', '" |
|
678
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
679
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
680
|
0
|
|
|
|
|
|
return undef; |
|
681
|
|
|
|
|
|
|
} |
|
682
|
|
|
|
|
|
|
} |
|
683
|
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
#default templates setup... |
|
685
|
0
|
|
|
|
|
|
my $top="Channel: {\$ctitle}\n". |
|
686
|
|
|
|
|
|
|
"Date: {\$cpubdate}\n". |
|
687
|
|
|
|
|
|
|
"Language: {\$clang}\n". |
|
688
|
|
|
|
|
|
|
"Copywright: {\$ccopyright}\n". |
|
689
|
|
|
|
|
|
|
"Link: {\$clink}\n". |
|
690
|
|
|
|
|
|
|
"\n". |
|
691
|
|
|
|
|
|
|
"{\$cdesc}\n"; |
|
692
|
0
|
|
|
|
|
|
my $item="--------------------------------------------------------------------------------\n". |
|
693
|
|
|
|
|
|
|
"Title: {\$ititle}\n". |
|
694
|
|
|
|
|
|
|
"Date: {\$ipubdate}\n". |
|
695
|
|
|
|
|
|
|
"Author: {\$iauthor}\n". |
|
696
|
|
|
|
|
|
|
"Category: {\$icat}\n". |
|
697
|
|
|
|
|
|
|
"Link: {\$ilink}\n". |
|
698
|
|
|
|
|
|
|
"". |
|
699
|
|
|
|
|
|
|
"{\$idescFTWL}\n"; |
|
700
|
|
|
|
|
|
|
|
|
701
|
0
|
|
|
|
|
|
my $bottom=''; |
|
702
|
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
#create the new set |
|
705
|
0
|
|
|
|
|
|
$self->{zconf}->writeSetFromHash({config=>"rss", set=>$set},{ |
|
706
|
|
|
|
|
|
|
'templates/defaultTop'=>$top, |
|
707
|
|
|
|
|
|
|
'templates/defaultItem'=>$item, |
|
708
|
|
|
|
|
|
|
'templates/defaultBottom'=>$bottom, |
|
709
|
|
|
|
|
|
|
}); |
|
710
|
|
|
|
|
|
|
#error if the write failed |
|
711
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
712
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
713
|
0
|
|
|
|
|
|
$self->{errorString}="writeSetFromHash failed.". |
|
714
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->{error}."', '" |
|
715
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
716
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
717
|
0
|
|
|
|
|
|
return undef; |
|
718
|
|
|
|
|
|
|
} |
|
719
|
|
|
|
|
|
|
|
|
720
|
0
|
|
|
|
|
|
return 1; |
|
721
|
|
|
|
|
|
|
} |
|
722
|
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
=head2 listFeeds |
|
724
|
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
This lists the available feeds. |
|
726
|
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
my @feeds=$zcrss->listFeeds(); |
|
728
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
729
|
|
|
|
|
|
|
print "Error!\n"; |
|
730
|
|
|
|
|
|
|
} |
|
731
|
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=cut |
|
733
|
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
sub listFeeds{ |
|
735
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
736
|
0
|
|
|
|
|
|
my $function='listFeeds'; |
|
737
|
|
|
|
|
|
|
|
|
738
|
0
|
|
|
|
|
|
$self->errorblank; |
|
739
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
740
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
741
|
|
|
|
|
|
|
} |
|
742
|
|
|
|
|
|
|
|
|
743
|
0
|
|
|
|
|
|
my @feedsA=$self->{zconf}->regexVarSearch('rss', '^feeds/'); |
|
744
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
745
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
746
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing feeds for the config "rss".'. |
|
747
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
748
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
749
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
750
|
0
|
|
|
|
|
|
return undef; |
|
751
|
|
|
|
|
|
|
} |
|
752
|
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
#removes feeds/ from the beginning of the variable name |
|
754
|
0
|
|
|
|
|
|
my $int=0; |
|
755
|
0
|
|
|
|
|
|
my %feeds; |
|
756
|
0
|
|
|
|
|
|
while (defined($feedsA[$int])) { |
|
757
|
0
|
|
|
|
|
|
my @split=split(/\//, $feedsA[$int]); |
|
758
|
0
|
|
|
|
|
|
$feeds{$split[1]}=''; |
|
759
|
|
|
|
|
|
|
|
|
760
|
0
|
|
|
|
|
|
$int++; |
|
761
|
|
|
|
|
|
|
} |
|
762
|
|
|
|
|
|
|
|
|
763
|
0
|
|
|
|
|
|
return keys(%feeds); |
|
764
|
|
|
|
|
|
|
} |
|
765
|
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
=head2 listSets |
|
767
|
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
This lists the available sets. |
|
769
|
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
my @sets=$zcrss->listSets; |
|
771
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
772
|
|
|
|
|
|
|
print "Error!"; |
|
773
|
|
|
|
|
|
|
} |
|
774
|
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
=cut |
|
776
|
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
sub listSets{ |
|
778
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
779
|
0
|
|
|
|
|
|
my $function='listSets'; |
|
780
|
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
#blanks any previous errors |
|
782
|
0
|
|
|
|
|
|
$self->errorblank; |
|
783
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
784
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
785
|
|
|
|
|
|
|
} |
|
786
|
|
|
|
|
|
|
|
|
787
|
0
|
|
|
|
|
|
my @sets=$self->{zconf}->getAvailableSets('rss'); |
|
788
|
0
|
0
|
|
|
|
|
if($self->{zconf}->{error}){ |
|
789
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
790
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing sets for the config "rss".'. |
|
791
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
792
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
793
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
794
|
0
|
|
|
|
|
|
return undef; |
|
795
|
|
|
|
|
|
|
} |
|
796
|
|
|
|
|
|
|
|
|
797
|
0
|
|
|
|
|
|
return @sets; |
|
798
|
|
|
|
|
|
|
} |
|
799
|
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
=head2 listTemplates |
|
801
|
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
This gets a list of available templates. |
|
803
|
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
my @templates=$zcrss->listTemplates; |
|
805
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
806
|
|
|
|
|
|
|
print "Error!\n"; |
|
807
|
|
|
|
|
|
|
} |
|
808
|
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
=cut |
|
810
|
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
sub listTemplates{ |
|
812
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
813
|
0
|
|
|
|
|
|
my $function='listTemplates'; |
|
814
|
|
|
|
|
|
|
|
|
815
|
0
|
|
|
|
|
|
$self->errorblank; |
|
816
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
817
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
818
|
|
|
|
|
|
|
} |
|
819
|
|
|
|
|
|
|
|
|
820
|
0
|
|
|
|
|
|
my @templates=$self->{zconf}->regexVarSearch('rss', '^templates/'); |
|
821
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
822
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
823
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing templates for the config "rss".'. |
|
824
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
825
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
826
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
827
|
0
|
|
|
|
|
|
return undef; |
|
828
|
|
|
|
|
|
|
} |
|
829
|
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
#removes templates/ from the beginning of the variable name |
|
831
|
0
|
|
|
|
|
|
my $int=0; |
|
832
|
0
|
|
|
|
|
|
while (defined($templates[$int])) { |
|
833
|
0
|
|
|
|
|
|
$templates[$int]=~s/^templates\///; |
|
834
|
|
|
|
|
|
|
|
|
835
|
0
|
|
|
|
|
|
$int++; |
|
836
|
|
|
|
|
|
|
} |
|
837
|
|
|
|
|
|
|
|
|
838
|
0
|
|
|
|
|
|
return @templates; |
|
839
|
|
|
|
|
|
|
} |
|
840
|
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
=head2 readSet |
|
842
|
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
This reads a specific set. If the set specified |
|
844
|
|
|
|
|
|
|
is undef, the default set is read. |
|
845
|
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
#read the default set |
|
847
|
|
|
|
|
|
|
$zcrss->readSet(); |
|
848
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
849
|
|
|
|
|
|
|
print "Error!\n"; |
|
850
|
|
|
|
|
|
|
} |
|
851
|
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
#read the set 'someSet' |
|
853
|
|
|
|
|
|
|
$zcrss->readSet('someSet'); |
|
854
|
|
|
|
|
|
|
if($zcrss->{error}){ |
|
855
|
|
|
|
|
|
|
print "Error!\n"; |
|
856
|
|
|
|
|
|
|
} |
|
857
|
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
=cut |
|
859
|
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
sub readSet{ |
|
861
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
862
|
0
|
|
|
|
|
|
my $set=$_[1]; |
|
863
|
0
|
|
|
|
|
|
my $function='readSet'; |
|
864
|
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
#blanks any previous errors |
|
866
|
0
|
|
|
|
|
|
$self->errorblank; |
|
867
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
868
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
869
|
|
|
|
|
|
|
} |
|
870
|
|
|
|
|
|
|
|
|
871
|
0
|
|
|
|
|
|
$self->{zconf}->read({config=>'rss', set=>$set}); |
|
872
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
873
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
874
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error reading the config "rss".'. |
|
875
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->{error}.'" '. |
|
876
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
877
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
878
|
0
|
|
|
|
|
|
return undef; |
|
879
|
|
|
|
|
|
|
} |
|
880
|
|
|
|
|
|
|
|
|
881
|
0
|
|
|
|
|
|
return 1; |
|
882
|
|
|
|
|
|
|
} |
|
883
|
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
=head2 setFeed |
|
885
|
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
This adds a new feed or modifies a existing one. |
|
887
|
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
One arguement is taken and it is a hash. |
|
889
|
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
=head3 hash args |
|
891
|
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
=head4 feed |
|
893
|
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
This the feed to be added. |
|
895
|
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
=head4 name |
|
897
|
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
This is the name to use for it. |
|
899
|
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
=head4 topTemplate |
|
901
|
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
This is the name of the top template to use. |
|
903
|
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
=head4 itemTemplate |
|
905
|
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
This is the name of the template that will be used for each item. |
|
907
|
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
=head4 bottomTemplate |
|
909
|
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
This is the name of the bottom template to use. |
|
911
|
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
$zcrss->setFeed({ |
|
913
|
|
|
|
|
|
|
feed=>'http://foo.bar/rss.xml', |
|
914
|
|
|
|
|
|
|
name=>'Foo Bar', |
|
915
|
|
|
|
|
|
|
topTemplate=>'defaultTop', |
|
916
|
|
|
|
|
|
|
itemTemplate=>'defaultItem', |
|
917
|
|
|
|
|
|
|
bottomTemplate=>'defaultBottom', |
|
918
|
|
|
|
|
|
|
}); |
|
919
|
|
|
|
|
|
|
if($zrss->{error}){ |
|
920
|
|
|
|
|
|
|
print "Error!\n"; |
|
921
|
|
|
|
|
|
|
} |
|
922
|
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
=cut |
|
924
|
|
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
sub setFeed{ |
|
926
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
927
|
0
|
|
|
|
|
|
my %args; |
|
928
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
|
929
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
|
0
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
} |
|
931
|
0
|
|
|
|
|
|
my $function='setFeed'; |
|
932
|
|
|
|
|
|
|
|
|
933
|
|
|
|
|
|
|
#blanks any previous errors |
|
934
|
0
|
|
|
|
|
|
$self->errorblank; |
|
935
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
936
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
937
|
|
|
|
|
|
|
} |
|
938
|
|
|
|
|
|
|
|
|
939
|
|
|
|
|
|
|
#required hash arguements |
|
940
|
0
|
|
|
|
|
|
my @required=('feed', 'name', 'topTemplate', 'itemTemplate', |
|
941
|
|
|
|
|
|
|
'bottomTemplate'); |
|
942
|
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
|
|
944
|
0
|
|
|
|
|
|
my $rint=0; |
|
945
|
|
|
|
|
|
|
#make sure everything is defined |
|
946
|
0
|
|
|
|
|
|
while (defined($required[$rint])) { |
|
947
|
0
|
0
|
|
|
|
|
if (!defined($required[$rint])) { |
|
948
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
949
|
0
|
|
|
|
|
|
$self->{errorString}='%args is missing the key "'. |
|
950
|
|
|
|
|
|
|
$required[$rint].'"'; |
|
951
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
952
|
0
|
|
|
|
|
|
return undef; |
|
953
|
|
|
|
|
|
|
} |
|
954
|
0
|
|
|
|
|
|
$rint++; |
|
955
|
|
|
|
|
|
|
} |
|
956
|
|
|
|
|
|
|
|
|
957
|
0
|
0
|
|
|
|
|
if ($args{name} =~ /\//) { |
|
958
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
959
|
0
|
|
|
|
|
|
$self->{errorString}='The feed name, "'.$args{name}.'", can\'t match /\//'; |
|
960
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
961
|
0
|
|
|
|
|
|
return undef; |
|
962
|
|
|
|
|
|
|
} |
|
963
|
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
#adds each one |
|
965
|
0
|
|
|
|
|
|
$rint=0; |
|
966
|
0
|
|
|
|
|
|
while (defined($required[$rint])) { |
|
967
|
0
|
|
|
|
|
|
$self->{zconf}->setVar('rss', 'feeds/'.$args{name}.'/'.$required[$rint], |
|
968
|
|
|
|
|
|
|
$args{$required[$rint]}); |
|
969
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
970
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
971
|
0
|
|
|
|
|
|
$self->{errorString}=" Setting variable for 'rss'.". |
|
972
|
|
|
|
|
|
|
"failed with '".$self->{zconf}->{error}."', '" |
|
973
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
974
|
|
|
|
|
|
|
#remove any that were added |
|
975
|
0
|
|
|
|
|
|
$self->{zconf}->regexVarDel('rss', '^feeds/'.$args{name}.'/'); |
|
976
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
977
|
0
|
|
|
|
|
|
return undef; |
|
978
|
|
|
|
|
|
|
} |
|
979
|
|
|
|
|
|
|
|
|
980
|
0
|
|
|
|
|
|
$rint++; |
|
981
|
|
|
|
|
|
|
} |
|
982
|
|
|
|
|
|
|
|
|
983
|
0
|
|
|
|
|
|
$self->{zconf}->writeSetFromLoadedConfig({config=>'rss'}); |
|
984
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
985
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
986
|
0
|
|
|
|
|
|
$self->{errorString}=" writeSetFromLoadedConfig for 'rss'.". |
|
987
|
|
|
|
|
|
|
"failed with '".$self->{zconf}->{error}."', '" |
|
988
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
989
|
|
|
|
|
|
|
#remove any that were added |
|
990
|
0
|
|
|
|
|
|
$self->{zconf}->regexVarDel('rss', '^feeds/'.$args{name}.'/'); |
|
991
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
992
|
0
|
|
|
|
|
|
return undef; |
|
993
|
|
|
|
|
|
|
} |
|
994
|
|
|
|
|
|
|
|
|
995
|
0
|
|
|
|
|
|
return 1; |
|
996
|
|
|
|
|
|
|
} |
|
997
|
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
=head2 setTemplate |
|
999
|
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
This sets a specified template to the given value. |
|
1001
|
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
$zcrss->setTemplate($templateName, $template); |
|
1003
|
|
|
|
|
|
|
if ($zcw->{error}) { |
|
1004
|
|
|
|
|
|
|
print "Error!\n"; |
|
1005
|
|
|
|
|
|
|
} |
|
1006
|
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
=cut |
|
1008
|
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
sub setTemplate{ |
|
1010
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
1011
|
0
|
|
|
|
|
|
my $name=$_[1]; |
|
1012
|
0
|
|
|
|
|
|
my $template=$_[2]; |
|
1013
|
0
|
|
|
|
|
|
my $function='setTemplate'; |
|
1014
|
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
#blanks any previous errors |
|
1016
|
0
|
|
|
|
|
|
$self->errorblank; |
|
1017
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
1018
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
1019
|
|
|
|
|
|
|
} |
|
1020
|
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
#make sure a name for the template is specified |
|
1022
|
0
|
0
|
|
|
|
|
if (!defined($name)) { |
|
1023
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
1024
|
0
|
|
|
|
|
|
$self->{errorstring}='No template specified'; |
|
1025
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
1026
|
0
|
|
|
|
|
|
return undef; |
|
1027
|
|
|
|
|
|
|
} |
|
1028
|
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
#make sure a template is specified |
|
1030
|
0
|
0
|
|
|
|
|
if (!defined($template)) { |
|
1031
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
1032
|
0
|
|
|
|
|
|
$self->{errorstring}='No template specified'; |
|
1033
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
1034
|
0
|
|
|
|
|
|
return undef; |
|
1035
|
|
|
|
|
|
|
} |
|
1036
|
|
|
|
|
|
|
|
|
1037
|
0
|
|
|
|
|
|
$self->{zconf}->setVar('rss', 'templates/'.$name, $template); |
|
1038
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
1039
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
1040
|
0
|
|
|
|
|
|
$self->{errorString}=' Error set the variable "templates/'.$name.'"'. |
|
1041
|
|
|
|
|
|
|
'for "rss" ZConf error="'.$self->{zconf}->{error}.'" '. |
|
1042
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->{errorString}.'"'; |
|
1043
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
1044
|
0
|
|
|
|
|
|
return undef; |
|
1045
|
|
|
|
|
|
|
} |
|
1046
|
|
|
|
|
|
|
|
|
1047
|
0
|
|
|
|
|
|
$self->{zconf}->writeSetFromLoadedConfig({config=>'rss'}); |
|
1048
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
1049
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
1050
|
0
|
|
|
|
|
|
$self->{errorString}=" writeSetFromLoadedConfig for 'rss'.". |
|
1051
|
|
|
|
|
|
|
"failed with '".$self->{zconf}->{error}."', '" |
|
1052
|
|
|
|
|
|
|
.$self->{zconf}->{errorString}."'"; |
|
1053
|
|
|
|
|
|
|
#remove any that were added |
|
1054
|
0
|
|
|
|
|
|
$self->{zconf}->regexVarDel('rss', '^templates/'.$name.'/'); |
|
1055
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
|
1056
|
0
|
|
|
|
|
|
return undef; |
|
1057
|
|
|
|
|
|
|
} |
|
1058
|
|
|
|
|
|
|
|
|
1059
|
0
|
|
|
|
|
|
return 1; |
|
1060
|
|
|
|
|
|
|
} |
|
1061
|
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
=head2 templateExists |
|
1063
|
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
This makes sure a specified template exists. |
|
1065
|
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
my $returned=$zcrss->templateExists('someTemplate'); |
|
1067
|
|
|
|
|
|
|
if($zcw->{error}){ |
|
1068
|
|
|
|
|
|
|
print "Error!\n"; |
|
1069
|
|
|
|
|
|
|
}else{ |
|
1070
|
|
|
|
|
|
|
if($returned){ |
|
1071
|
|
|
|
|
|
|
print "It exists.\n"; |
|
1072
|
|
|
|
|
|
|
} |
|
1073
|
|
|
|
|
|
|
} |
|
1074
|
|
|
|
|
|
|
|
|
1075
|
|
|
|
|
|
|
=cut |
|
1076
|
|
|
|
|
|
|
|
|
1077
|
|
|
|
|
|
|
sub templateExists{ |
|
1078
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
1079
|
0
|
|
|
|
|
|
my $template=$_[1]; |
|
1080
|
0
|
|
|
|
|
|
my $function='templateExists'; |
|
1081
|
|
|
|
|
|
|
|
|
1082
|
0
|
|
|
|
|
|
$self->errorblank; |
|
1083
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
1084
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set'); |
|
1085
|
|
|
|
|
|
|
} |
|
1086
|
|
|
|
|
|
|
|
|
1087
|
0
|
|
|
|
|
|
my @templates=$self->listTemplates; |
|
1088
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
|
1089
|
0
|
|
|
|
|
|
warn('ZConf-RSS templateExists: listTemplates errored'); |
|
1090
|
0
|
|
|
|
|
|
return undef; |
|
1091
|
|
|
|
|
|
|
} |
|
1092
|
|
|
|
|
|
|
|
|
1093
|
0
|
|
|
|
|
|
my $int=0; |
|
1094
|
0
|
|
|
|
|
|
while (defined($templates[$int])) { |
|
1095
|
0
|
0
|
|
|
|
|
if ($templates[$int] eq $template) { |
|
1096
|
0
|
|
|
|
|
|
return 1; |
|
1097
|
|
|
|
|
|
|
} |
|
1098
|
|
|
|
|
|
|
|
|
1099
|
0
|
|
|
|
|
|
$int++; |
|
1100
|
|
|
|
|
|
|
} |
|
1101
|
|
|
|
|
|
|
|
|
1102
|
0
|
|
|
|
|
|
return undef; |
|
1103
|
|
|
|
|
|
|
} |
|
1104
|
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
=head2 errorblank |
|
1106
|
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
This blanks the error storage and is only meant for internal usage. |
|
1108
|
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
It does the following. |
|
1110
|
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
$self->{error}=undef; |
|
1112
|
|
|
|
|
|
|
$self->{errorString}=""; |
|
1113
|
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
=cut |
|
1115
|
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
#blanks the error flags |
|
1117
|
|
|
|
|
|
|
sub errorblank{ |
|
1118
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
1119
|
|
|
|
|
|
|
|
|
1120
|
0
|
0
|
|
|
|
|
if ($self->{perror}) { |
|
1121
|
0
|
|
|
|
|
|
return undef; |
|
1122
|
|
|
|
|
|
|
} |
|
1123
|
|
|
|
|
|
|
|
|
1124
|
0
|
|
|
|
|
|
$self->{error}=undef; |
|
1125
|
0
|
|
|
|
|
|
$self->{errorString}=""; |
|
1126
|
|
|
|
|
|
|
|
|
1127
|
0
|
|
|
|
|
|
return 1; |
|
1128
|
|
|
|
|
|
|
} |
|
1129
|
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
=head1 TEMPLATE VARIABLES |
|
1131
|
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
The templating system used is 'Text::NeatTemplate'. The varialbes are as below. |
|
1133
|
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
=head2 CHANNEL |
|
1135
|
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
=head3 ctitle |
|
1137
|
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
This is the title for the channel. |
|
1139
|
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
=head3 cdesc |
|
1141
|
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
This is the description for the channel. |
|
1143
|
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
=head3 cpubdate |
|
1145
|
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
This is the publication date for the channel. |
|
1147
|
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
=head3 ccopyright |
|
1149
|
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
This is the copyright info for the channel. |
|
1151
|
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
=head3 clink |
|
1153
|
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
This is the link for the channel. |
|
1155
|
|
|
|
|
|
|
|
|
1156
|
|
|
|
|
|
|
=head3 clang |
|
1157
|
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
This is the language for the channel. |
|
1159
|
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
=head3 cimage |
|
1161
|
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
This is the image for the channel. |
|
1163
|
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
=head2 ITEM |
|
1165
|
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
=head3 ititle |
|
1167
|
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
This is the title for a item. |
|
1169
|
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
=head3 idesc |
|
1171
|
|
|
|
|
|
|
|
|
1172
|
|
|
|
|
|
|
This is the description for a item. |
|
1173
|
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
=head3 idescFTWL |
|
1175
|
|
|
|
|
|
|
|
|
1176
|
|
|
|
|
|
|
This is the description for a item that has been |
|
1177
|
|
|
|
|
|
|
has been formated with 'HTML::FormatText::WithLinks' |
|
1178
|
|
|
|
|
|
|
|
|
1179
|
|
|
|
|
|
|
=head3 ipubdate |
|
1180
|
|
|
|
|
|
|
|
|
1181
|
|
|
|
|
|
|
This is the date published for a item. |
|
1182
|
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
=head3 icat |
|
1184
|
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
This is the category for a item. |
|
1186
|
|
|
|
|
|
|
|
|
1187
|
|
|
|
|
|
|
=head3 iauthor |
|
1188
|
|
|
|
|
|
|
|
|
1189
|
|
|
|
|
|
|
This is the author for a item. |
|
1190
|
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
=head3 iguid |
|
1192
|
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
This is the item's guid element. |
|
1194
|
|
|
|
|
|
|
|
|
1195
|
|
|
|
|
|
|
=head3 ilink |
|
1196
|
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
This is the link for a item. |
|
1198
|
|
|
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
=head1 DEFAULT TEMPLATES |
|
1200
|
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
=head2 defaultTop |
|
1202
|
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
Channel: {$ctitle} |
|
1204
|
|
|
|
|
|
|
Date: {$cpubdate} |
|
1205
|
|
|
|
|
|
|
Language: {$clang} |
|
1206
|
|
|
|
|
|
|
Copywright: {$ccopyright} |
|
1207
|
|
|
|
|
|
|
Link: {$clink} |
|
1208
|
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
{$cdesc} |
|
1210
|
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
=head2 defaultItem |
|
1212
|
|
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
|
|
1214
|
|
|
|
|
|
|
-------------------------------------------------------------------------------- |
|
1215
|
|
|
|
|
|
|
Title: {$ititle} |
|
1216
|
|
|
|
|
|
|
Date: {$ipubdate} |
|
1217
|
|
|
|
|
|
|
Author: {$iauthor} |
|
1218
|
|
|
|
|
|
|
Category: {$icat} |
|
1219
|
|
|
|
|
|
|
Link: {$ilink} |
|
1220
|
|
|
|
|
|
|
|
|
1221
|
|
|
|
|
|
|
{$idescFTWL} |
|
1222
|
|
|
|
|
|
|
|
|
1223
|
|
|
|
|
|
|
=head2 defaultBottom |
|
1224
|
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
This one is blank by default. |
|
1226
|
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
=head1 ERROR CODES |
|
1228
|
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
=head2 1 |
|
1230
|
|
|
|
|
|
|
|
|
1231
|
|
|
|
|
|
|
Could not initialize ZConf. |
|
1232
|
|
|
|
|
|
|
|
|
1233
|
|
|
|
|
|
|
=head2 2 |
|
1234
|
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
ZConf error. |
|
1236
|
|
|
|
|
|
|
|
|
1237
|
|
|
|
|
|
|
=head2 3 |
|
1238
|
|
|
|
|
|
|
|
|
1239
|
|
|
|
|
|
|
Missing required arguement. |
|
1240
|
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
=head2 4 |
|
1242
|
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
Feed name can't match /\//. |
|
1244
|
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
=head2 5 |
|
1246
|
|
|
|
|
|
|
|
|
1247
|
|
|
|
|
|
|
Feed does not exist. |
|
1248
|
|
|
|
|
|
|
|
|
1249
|
|
|
|
|
|
|
=head2 6 |
|
1250
|
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
Feed not defined. |
|
1252
|
|
|
|
|
|
|
|
|
1253
|
|
|
|
|
|
|
=head2 7 |
|
1254
|
|
|
|
|
|
|
|
|
1255
|
|
|
|
|
|
|
Failed to load feed. |
|
1256
|
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
=head1 AUTHOR |
|
1258
|
|
|
|
|
|
|
|
|
1259
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
|
1260
|
|
|
|
|
|
|
|
|
1261
|
|
|
|
|
|
|
=head1 BUGS |
|
1262
|
|
|
|
|
|
|
|
|
1263
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
1264
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
1265
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
1266
|
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
=head1 SUPPORT |
|
1268
|
|
|
|
|
|
|
|
|
1269
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
1270
|
|
|
|
|
|
|
|
|
1271
|
|
|
|
|
|
|
perldoc ZConf::RSS |
|
1272
|
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
|
|
1274
|
|
|
|
|
|
|
You can also look for information at: |
|
1275
|
|
|
|
|
|
|
|
|
1276
|
|
|
|
|
|
|
=over 4 |
|
1277
|
|
|
|
|
|
|
|
|
1278
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
1279
|
|
|
|
|
|
|
|
|
1280
|
|
|
|
|
|
|
L |
|
1281
|
|
|
|
|
|
|
|
|
1282
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
1283
|
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
L |
|
1285
|
|
|
|
|
|
|
|
|
1286
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
1287
|
|
|
|
|
|
|
|
|
1288
|
|
|
|
|
|
|
L |
|
1289
|
|
|
|
|
|
|
|
|
1290
|
|
|
|
|
|
|
=item * Search CPAN |
|
1291
|
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
L |
|
1293
|
|
|
|
|
|
|
|
|
1294
|
|
|
|
|
|
|
=back |
|
1295
|
|
|
|
|
|
|
|
|
1296
|
|
|
|
|
|
|
|
|
1297
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
1298
|
|
|
|
|
|
|
|
|
1299
|
|
|
|
|
|
|
|
|
1300
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
1301
|
|
|
|
|
|
|
|
|
1302
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
|
1303
|
|
|
|
|
|
|
|
|
1304
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
1305
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
1306
|
|
|
|
|
|
|
|
|
1307
|
|
|
|
|
|
|
|
|
1308
|
|
|
|
|
|
|
=cut |
|
1309
|
|
|
|
|
|
|
|
|
1310
|
|
|
|
|
|
|
1; # End of ZConf::RSS |