| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Template::Plugin::XML::Feed; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
504290
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
38
|
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
|
2
|
|
|
|
|
0
|
|
|
|
2
|
|
|
|
|
50
|
|
|
5
|
2
|
|
|
2
|
|
7
|
use base 'Template::Plugin'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
78
|
|
|
6
|
2
|
|
|
2
|
|
14144
|
use XML::Feed; |
|
|
2
|
|
|
|
|
923395
|
|
|
|
2
|
|
|
|
|
139
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.01; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
6
|
|
|
6
|
1
|
16042
|
my ($class, $context, $filename) = @_; |
|
12
|
|
|
|
|
|
|
|
|
13
|
6
|
50
|
|
|
|
15
|
return $class->fail('No filename specified') |
|
14
|
|
|
|
|
|
|
unless $filename; |
|
15
|
|
|
|
|
|
|
|
|
16
|
6
|
0
|
|
|
|
29
|
my $feed = XML::Feed->parse($filename) |
|
17
|
|
|
|
|
|
|
or return $class->error('failed to create XML::Feed'); |
|
18
|
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
189928
|
return $feed; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__END__ |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Template::Plugin::XML::Feed - Plugin interface to XML::Feed |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
[% USE news = XML.Feed('news.rdf') %] |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
[% FOREACH item IN news.items %] |
|
35
|
|
|
|
|
|
|
[% item.title %] |
|
36
|
|
|
|
|
|
|
[% item.link %] |
|
37
|
|
|
|
|
|
|
[% END %] |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
This Template Toolkit plugin provides a simple interface to the |
|
42
|
|
|
|
|
|
|
XML::Feed module. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
[% USE news = XML.Feed('mysite.rdf') %] |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
It creates an XML::Feed object, which is then used to parse the RSS or Atom |
|
47
|
|
|
|
|
|
|
file specified as a parameter in the USE directive. A reference to |
|
48
|
|
|
|
|
|
|
the XML::Feed object is then returned. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
The attributes of the channel and image elements can be retrieved directly |
|
51
|
|
|
|
|
|
|
from the plugin object using the familiar dotted compound notation: |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
[% news.channel.title %] |
|
54
|
|
|
|
|
|
|
[% news.channel.link %] |
|
55
|
|
|
|
|
|
|
[% news.channel.etc... %] |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
[% news.image.title %] |
|
58
|
|
|
|
|
|
|
[% news.image.url %] |
|
59
|
|
|
|
|
|
|
[% news.image.link %] |
|
60
|
|
|
|
|
|
|
[% news.image.etc... %] |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The list of news items can be retrieved using the 'items' method: |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
[% FOREACH item IN news.items %] |
|
65
|
|
|
|
|
|
|
[% item.title %] |
|
66
|
|
|
|
|
|
|
[% item.link %] |
|
67
|
|
|
|
|
|
|
[% END %] |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 METHODS |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 new |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Constructor method. Delegates to XML::Feed->parse to create an XML::Feed |
|
74
|
|
|
|
|
|
|
object. Not usually called directly. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHORS |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This plugin was written by Dave Cross and was heavily based on the code |
|
79
|
|
|
|
|
|
|
for L<Template::Plugin::XML::RSS> by Andy Wardley. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The XML::Feed module, which implements all of the functionality that |
|
82
|
|
|
|
|
|
|
this plugin delegates to, was written by Benjamin Trott and is now maintained |
|
83
|
|
|
|
|
|
|
by Simon Wardley. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Copyright (C) 2009 Magnum Solutions Ltd. All Rights Reserved. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
|
90
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L<Template::Plugin>, L<XML::Feed> |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|