Add atom:link support to rss20.
[matthijs/upstream/blosxom-plugins.git] / gavinc / rss20
1 # Blosxom Plugin: rss20
2 # Author(s): Gavin Carr <gavin@openfusion.com.au>
3 # Version: 0.001002
4 # Requires: storydate, lastmodified2
5 # Suggests: absolute
6 # Follows:  storydate, lastmodified2
7
8 package rss20;
9
10 use strict;
11 use vars qw(
12   $flavour
13   $author_email 
14   $error_email 
15   $permalink
16   $trackback_link
17   $copyright
18   $generator_url
19 );
20
21 # --- Configuration variables -----
22
23 # What flavour string to you want to use for your feed?
24 $flavour = 'rss';
25 #$flavour = 'rss20';
26
27 # What email address should be used as the default author email?
28 $author_email = 'author@example.com';
29
30 # What email address should feed errors be reported to?
31 $error_email = '';
32
33 # What do your story permalinks look like?
34 # This must be single-quoted, to defer evaluation; blosxom namespace applies
35 $permalink = '$url$path/$fn.$default_flavour';
36
37 # What link should be used for trackbacks on a story?
38 # This must be single-quoted, to defer evaluation; blosxom namespace applies
39 $trackback_link = '';
40 # $trackback_link = '$url$path/$fn.writeback';
41 # $trackback_link = '$url$path/$fn.$feedback::trackback_flavour';
42
43 # Copyright statement; leave blank to omit.
44 $copyright = '';
45
46 # Generator that produced this feed
47 $generator_url = "http://blosxom.sourceforge.net/?v=$blosxom::version";
48
49 # --------------------------------
50
51 $error_email ||= $author_email;
52
53 sub start { 
54   _load_templates();
55
56   1;
57 }
58
59 # --- Private subroutines
60
61 sub _load_templates {
62   $blosxom::template{$flavour}{'content_type'} = 'text/xml; charset=$blog_encoding';
63
64   $blosxom::template{$flavour}{'date'} = "\n";
65
66   $blosxom::template{$flavour}{'head'} = <<HEAD;
67 <?xml version="1.0" encoding="$blosxom::blog_encoding"?>
68 <rss version="2.0"
69     xmlns:dc="http://purl.org/dc/elements/1.1/"
70     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
71     xmlns:admin="http://webns.net/mvcb/"
72     xmlns:atom="http://www.w3.org/2005/Atom"
73     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
74     xmlns:content="http://purl.org/rss/1.0/modules/content/">
75
76     <channel>
77         <title>$blosxom::blog_title</title>
78         <link>$blosxom::url</link>
79         <description>$blosxom::blog_description</description>
80         <dc:date>\$lastmodified2::latest_iso8601</dc:date>
81         <dc:language>$blosxom::blog_language</dc:language>
82         <dc:creator>mailto:$rss20::author_email</dc:creator>
83         <dc:rights>$rss20::copyright</dc:rights>
84         <admin:generatorAgent rdf:resource="$rss20::generator_url" />
85         <admin:errorReportsTo rdf:resource="mailto:$rss20::error_email" />
86         <atom:link href="$blosxom::url$ENV{PATH_INFO}" rel="self" type="application/rss+xml" />
87         <sy:updatePeriod>hourly</sy:updatePeriod>
88         <sy:updateFrequency>1</sy:updateFrequency>
89         <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
90
91 HEAD
92
93   $blosxom::template{$flavour}{'story'} = <<STORY;
94         <item>
95             <title>\$title</title>
96             <link>$rss20::permalink</link>                                                                             
97             <description>\$body</description>                                                   
98             <comments>$rss20::trackback_link</comments>                                                            
99             <guid isPermaLink="true">$rss20::permalink</guid>                                                          
100             <dc:date>\$storydate::story_iso8601</dc:date>
101         </item>
102 STORY
103
104   $blosxom::template{$flavour}{'foot'} = <<'FOOT';
105     </channel>                                    
106 </rss>  
107 FOOT
108 }
109
110
111 1;
112
113 __END__
114
115 =head1 NAME
116
117 rss20 - blosxom plugin to generate an RSS 2.0 feed of your blog
118
119 =head1 DESCRIPTION
120
121 rss20 is a blosxom plugin to generate an RSS 2.0 feed of your blog. It
122 is self-contained, including the required flavours, and has a bunch of
123 configuration variables to allow for configuration.
124
125 =head2 CONFIGURATION
126
127 The following package variables can be configured:
128
129 =over 4
130
131 =item $flavour
132
133 Flavour string to use for your feed (typically 'rss' or 'rss20').
134
135 =item $author_email
136
137 Default author email address for posts.
138
139 =item $error_email
140
141 Email address to use to report errors with the feed (defaults to 
142 $author_email).
143
144 =item $permalink
145
146 Story permalink. Default is '$url$path/$fn.$default_flavour'.
147 Note that this value should probably be single quoted to defer
148 variable evaluation until rendering time.
149
150 =item $trackback_link
151
152 Story trackback or comment link. Default is ''. Useful if you
153 are using a comments plugin like C<writeback> or C<feedback>,
154 and the format you want will be plugin-dependant.
155
156 Like $permalink, this value should be single quoted to defer
157 variable evaluation till rendering time.
158
159 =item $copyright
160
161 Default copyright clause for posts, if any.
162
163 =back
164
165 =head1 USAGE
166
167 rss20 should be loaded relatively late, since you'll typically want
168 plugins that manipulate your story content to have run already. It 
169 also should be run after the 'story' or 'prefs' plugins if you want
170 to use those to customise your configuration variables.
171
172
173 =head1 SEE ALSO
174
175 Blosxom: http://blosxom.sourceforge.net/
176
177 rss20 is based on the 'atomfeed' and 'rss10' plugins, by Rael
178 Dornfest and contributors.
179
180
181 =head1 BUGS
182
183 Please report bugs either directly to the author or to the blosxom 
184 development mailing list: <blosxom-devel@lists.sourceforge.net>.
185
186
187 =head1 AUTHOR
188
189 Gavin Carr <gavin@openfusion.com.au>, http://www.openfusion.net/
190
191
192 =head1 LICENSE
193
194 Copyright 2007 Gavin Carr.
195
196 This plugin is licensed under the same terms as blosxom itself i.e.
197
198 Permission is hereby granted, free of charge, to any person obtaining a
199 copy of this software and associated documentation files (the "Software"),
200 to deal in the Software without restriction, including without limitation
201 the rights to use, copy, modify, merge, publish, distribute, sublicense,
202 and/or sell copies of the Software, and to permit persons to whom the
203 Software is furnished to do so, subject to the following conditions:
204
205 The above copyright notice and this permission notice shall be included
206 in all copies or substantial portions of the Software.
207
208 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
209 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
210 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
211 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
212 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
213 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
214 OTHER DEALINGS IN THE SOFTWARE.
215
216 =cut
217
218 # vim:ft=perl