1 # Blosxom Plugin: rss20
2 # Author(s): Gavin Carr <gavin@openfusion.com.au>
5 # Suggests: absolute, storytags, geo
25 # --- Configuration variables -----
27 # What flavour string to you want to use for your feed?
31 # What email address should be used as the default author email?
32 # Recommended format is 'email (name)', but bare emails or mailto emails are ok too
33 $author_email = 'author@example.com (A. U. Thor)';
35 # What name should be used as the default author name?
36 # Define this only if you don't want to disclose an email address in $author_email.
37 # It will be ignored if $author_email is set.
40 # What email address should feed errors be reported to?
41 # Recommended format is 'email (name)', but bare emails or mailto emails are ok too
42 $webmaster_email = '';
43 #$webmaster_email = 'webmaster@example.com (Web Master)';
45 # What do your story permalinks look like?
46 # This must be single-quoted, to defer evaluation; blosxom namespace applies
47 $permalink = '$url$path/$fn.$default_flavour';
49 # What link should be used for trackbacks on a story?
50 # This must be single-quoted, to defer evaluation; blosxom namespace applies
52 # $trackback_link = '$url$path/$fn.writeback';
53 # $trackback_link = '$url$path/$fn.$feedback::trackback_flavour';
55 # Copyright statement; leave blank to omit.
58 # Generator that produced this feed
59 $generator = "blosxom $blosxom::version";
61 # --------------------------------
64 $webmaster_email ||= $author_email;
66 my $channel_indent = 8;
69 # Escape <, >, and & to hex-encoded entities for max compatibility in text elements
70 # See http://www.rssboard.org/rss-profile#data-types-characterdata
76 my $escape_text_re = join '|' => keys %escape_text;
78 # Escape <, >, and & to standard html-encoded entities for in html elements
84 my $escape_html_re = join '|' => keys %escape_html;
92 my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
94 # Ignore flavours other than ours
95 return unless $blosxom::flavour eq $flavour;
97 # Don't double-encode if someone else has already done it
98 return unless $do_encode || $blosxom::encode_xml_entities;
100 # Because we're inside a loop, we set $do_encode for runs after the first
101 unless ($do_encode) {
103 $blosxom::encode_xml_entities = 0;
106 # Encode and reset encode_xml_entities flag
107 $$title_ref = _escape_text( $$title_ref );
108 $$body_ref = _escape_html( $$body_ref );
111 if ($blosxom::plugins{storytags}) {
112 for (@storytags::taglist) {
113 $category_list .= qq(<category>$_</category>\n) . ' ' x $item_indent;
118 if ($blosxom::plugins{geo} && $geo::latitude && $geo::longitude) {
119 $georss = qq(<georss:point>$geo::latitude $geo::longitude</georss:point>\n) .
126 # --- Private subroutines
130 $text =~ s/($escape_text_re)/$escape_text{$1}/g;
136 $html =~ s/($escape_html_re)/$escape_html{$1}/g;
140 sub _load_templates {
141 $blosxom::template{$flavour}{'content_type'} = 'text/xml; charset=$blog_encoding';
143 $blosxom::template{$flavour}{'date'} = "\n";
145 $blosxom::template{$flavour}{'head'} = <<HEAD;
146 <?xml version="1.0" encoding="$blosxom::blog_encoding"?>
148 xmlns:dc="http://purl.org/dc/elements/1.1/"
149 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
152 if ($blosxom::plugins{geo}) {
153 $blosxom::template{$flavour}{'head'} .=
154 qq( xmlns:georss="http://www.georss.org/georss"\n);
157 $blosxom::template{$flavour}{'head'} .= <<HEAD;
158 xmlns:atom="http://www.w3.org/2005/Atom">
161 <title>$blosxom::blog_title</title>
162 <link>$blosxom::url/</link>
165 if ($blosxom::path_info) {
166 $blosxom::template{$flavour}{'head'} .=
167 ' ' x $channel_indent .
168 qq(<category>$blosxom::path_info</category>\n);
170 if ($blosxom::blog_description) {
171 $blosxom::template{$flavour}{'head'} .=
172 ' ' x $channel_indent .
173 qq(<description>$blosxom::blog_description</description>\n);
175 if ($rss20::author_email) {
176 $blosxom::template{$flavour}{'head'} .=
177 ' ' x $channel_indent .
178 qq(<managingEditor>$rss20::author_email</managingEditor>\n);
180 elsif ($rss20::author_name) {
181 $blosxom::template{$flavour}{'head'} .=
182 ' ' x $channel_indent .
183 qq(<dc:creator>$rss20::author_name</dc:creator>\n);
185 if ($rss20::webmaster_email) {
186 $blosxom::template{$flavour}{'head'} .=
187 ' ' x $channel_indent .
188 qq(<webMaster>$rss20::webmaster_email</webMaster>\n);
190 if ($rss20::copyright) {
191 $blosxom::template{$flavour}{'head'} .=
192 ' ' x $channel_indent .
193 qq(<copyright>$rss20::copyright</copyright>\n);
195 my $path_info_full = $blosxom::path_info_full || "$blosxom::path_info/index.rss";
196 $blosxom::template{$flavour}{'head'} .= <<HEAD;
197 <pubDate>\$storydate::latest_rfc822</pubDate>
198 <language>$blosxom::blog_language</language>
199 <generator>$rss20::generator</generator>
200 <atom:link href="$blosxom::url$path_info_full" rel="self" type="application/rss+xml" />
201 <sy:updatePeriod>hourly</sy:updatePeriod>
202 <sy:updateFrequency>1</sy:updateFrequency>
203 <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
206 $blosxom::template{$flavour}{'story'} = <<STORY;
209 <title>\$title</title>
210 <link>$rss20::permalink</link>
211 <guid isPermaLink="true">$rss20::permalink</guid>
212 <pubDate>\$storydate::story_rfc822</pubDate>
215 if ($rss20::trackback_link) {
216 $blosxom::template{$flavour}{'story'} .=
218 qq(<comments>$rss20::trackback_link</comments>\n);
220 $blosxom::template{$flavour}{'story'} .=
222 '$rss20::category_list';
225 if ($blosxom::plugins{geo}) {
226 $blosxom::template{$flavour}{'story'} .= '$rss20::georss';
229 $blosxom::template{$flavour}{'story'} .= <<'STORY';
235 $blosxom::template{$flavour}{'foot'} = <<'FOOT';
251 rss20 - blosxom plugin to generate an RSS 2.0 feed of your blog
255 rss20 is a blosxom plugin to generate an RSS 2.0 feed of your blog. It
256 is self-contained, including the required flavours, and has a bunch of
257 configuration variables to allow for configuration.
259 If you're using the L<geo> plugin, rss20 will also add georss:point
260 entries for any items with latitude and longitude metadata set (see
265 The following package variables can be configured:
271 Flavour string to use for your feed (typically 'rss' or 'rss20').
275 Default author email address for posts.
277 =item $webmaster_email
279 Email address to use for webmaster responsible for the feed (defaults
284 Story permalink. Default is '$url$path/$fn.$default_flavour'.
285 Note that this value should probably be single quoted to defer
286 variable evaluation until rendering time.
288 =item $trackback_link
290 Story trackback or comment link. Default is ''. Useful if you
291 are using a comments plugin like C<writeback> or C<feedback>,
292 and the format you want will be plugin-dependant.
294 Like $permalink, this value should be single quoted to defer
295 variable evaluation till rendering time.
299 Default copyright clause for posts, if any.
305 rss20 should be loaded relatively late, since you'll typically want
306 plugins that manipulate your story content to have run already. It
307 also should be run after the 'story' or 'prefs' plugins if you want
308 to use those to customise your configuration variables.
310 Requires the L<storydate> plugin for setting up story dates in the
311 right formats, and recommends the L<absolute> plugin for absolutising
317 L<storydate>, L<absolute>, L<geo>
319 Blosxom: http://blosxom.sourceforge.net/
321 rss20 is based on the 'atomfeed' and 'rss10' plugins, by Rael
322 Dornfest and contributors.
327 Please report bugs either directly to the author or to the blosxom
328 development mailing list: <blosxom-devel@lists.sourceforge.net>.
333 Gavin Carr <gavin@openfusion.com.au>, http://www.openfusion.net/
338 Copyright 2007 Gavin Carr.
340 This plugin is licensed under the same terms as blosxom itself i.e.
342 Permission is hereby granted, free of charge, to any person obtaining a
343 copy of this software and associated documentation files (the "Software"),
344 to deal in the Software without restriction, including without limitation
345 the rights to use, copy, modify, merge, publish, distribute, sublicense,
346 and/or sell copies of the Software, and to permit persons to whom the
347 Software is furnished to do so, subject to the following conditions:
349 The above copyright notice and this permission notice shall be included
350 in all copies or substantial portions of the Software.
352 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
353 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
354 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
355 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
356 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
357 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
358 OTHER DEALINGS IN THE SOFTWARE.