1 # Blosxom Plugin: rss20
2 # Author(s): Gavin Carr <gavin@openfusion.com.au>
5 # Suggests: absolute, storytags
24 # --- Configuration variables -----
26 # What flavour string to you want to use for your feed?
30 # What email address should be used as the default author email?
31 # Recommended format is 'email (name)', but bare emails or mailto emails are ok too
32 $author_email = 'author@example.com (A. U. Thor)';
34 # What name should be used as the default author name?
35 # Define this only if you don't want to disclose an email address in $author_email.
36 # It will be ignored if $author_email is set.
39 # What email address should feed errors be reported to?
40 # Recommended format is 'email (name)', but bare emails or mailto emails are ok too
41 $webmaster_email = '';
42 #$webmaster_email = 'webmaster@example.com (Web Master)';
44 # What do your story permalinks look like?
45 # This must be single-quoted, to defer evaluation; blosxom namespace applies
46 $permalink = '$url$path/$fn.$default_flavour';
48 # What link should be used for trackbacks on a story?
49 # This must be single-quoted, to defer evaluation; blosxom namespace applies
51 # $trackback_link = '$url$path/$fn.writeback';
52 # $trackback_link = '$url$path/$fn.$feedback::trackback_flavour';
54 # Copyright statement; leave blank to omit.
57 # Generator that produced this feed
58 $generator = "blosxom $blosxom::version";
60 # --------------------------------
63 $webmaster_email ||= $author_email;
65 my $channel_indent = 8;
68 # Escape <, >, and & to hex-encoded entities for max compatibility in text elements
69 # See http://www.rssboard.org/rss-profile#data-types-characterdata
75 my $escape_text_re = join '|' => keys %escape_text;
77 # Escape <, >, and & to standard html-encoded entities for in html elements
83 my $escape_html_re = join '|' => keys %escape_html;
91 my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
93 # Ignore flavours other than ours
94 return unless $blosxom::flavour eq $flavour;
96 # Don't double-encode if someone else has already done it
97 return unless $do_encode || $blosxom::encode_xml_entities;
99 # Because we're inside a loop, we set $do_encode for runs after the first
100 unless ($do_encode) {
102 $blosxom::encode_xml_entities = 0;
105 # Encode and reset encode_xml_entities flag
106 $$title_ref = _escape_text( $$title_ref );
107 $$body_ref = _escape_html( $$body_ref );
110 if ($blosxom::plugins{storytags}) {
111 for (@storytags::taglist) {
112 $category_list .= qq(<category>$_</category>\n) . ' ' x $item_indent;
117 # --- Private subroutines
121 $text =~ s/($escape_text_re)/$escape_text{$1}/g;
127 $html =~ s/($escape_html_re)/$escape_html{$1}/g;
131 sub _load_templates {
132 $blosxom::template{$flavour}{'content_type'} = 'text/xml; charset=$blog_encoding';
134 $blosxom::template{$flavour}{'date'} = "\n";
136 $blosxom::template{$flavour}{'head'} = <<HEAD;
137 <?xml version="1.0" encoding="$blosxom::blog_encoding"?>
139 xmlns:dc="http://purl.org/dc/elements/1.1/"
140 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
141 xmlns:atom="http://www.w3.org/2005/Atom">
144 <title>$blosxom::blog_title</title>
145 <link>$blosxom::url/</link>
148 if ($blosxom::path_info) {
149 $blosxom::template{$flavour}{'head'} .=
150 ' ' x $channel_indent .
151 qq(<category>$blosxom::path_info</category>\n);
153 if ($blosxom::blog_description) {
154 $blosxom::template{$flavour}{'head'} .=
155 ' ' x $channel_indent .
156 qq(<description>$blosxom::blog_description</description>\n);
158 if ($rss20::author_email) {
159 $blosxom::template{$flavour}{'head'} .=
160 ' ' x $channel_indent .
161 qq(<managingEditor>$rss20::author_email</managingEditor>\n);
163 elsif ($rss20::author_name) {
164 $blosxom::template{$flavour}{'head'} .=
165 ' ' x $channel_indent .
166 qq(<dc:creator>$rss20::author_name</dc:creator>\n);
168 if ($rss20::webmaster_email) {
169 $blosxom::template{$flavour}{'head'} .=
170 ' ' x $channel_indent .
171 qq(<webMaster>$rss20::webmaster_email</webMaster>\n);
173 if ($rss20::copyright) {
174 $blosxom::template{$flavour}{'head'} .=
175 ' ' x $channel_indent .
176 qq(<copyright>$rss20::copyright</copyright>\n);
178 my $path_info_full = $blosxom::path_info_full || "$blosxom::path_info/index.rss";
179 $blosxom::template{$flavour}{'head'} .= <<HEAD;
180 <pubDate>\$storydate::latest_rfc822</pubDate>
181 <language>$blosxom::blog_language</language>
182 <generator>$rss20::generator</generator>
183 <atom:link href="$blosxom::url$path_info_full" rel="self" type="application/rss+xml" />
184 <sy:updatePeriod>hourly</sy:updatePeriod>
185 <sy:updateFrequency>1</sy:updateFrequency>
186 <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
189 $blosxom::template{$flavour}{'story'} = <<STORY;
192 <title>\$title</title>
193 <link>$rss20::permalink</link>
194 <guid isPermaLink="true">$rss20::permalink</guid>
195 <pubDate>\$storydate::story_rfc822</pubDate>
198 if ($rss20::trackback_link) {
199 $blosxom::template{$flavour}{'story'} .=
201 qq(<comments>$rss20::trackback_link</comments>\n);
203 $blosxom::template{$flavour}{'story'} .= <<STORY;
204 \$rss20::category_list<description>\$body
209 $blosxom::template{$flavour}{'foot'} = <<'FOOT';
225 rss20 - blosxom plugin to generate an RSS 2.0 feed of your blog
229 rss20 is a blosxom plugin to generate an RSS 2.0 feed of your blog. It
230 is self-contained, including the required flavours, and has a bunch of
231 configuration variables to allow for configuration.
235 The following package variables can be configured:
241 Flavour string to use for your feed (typically 'rss' or 'rss20').
245 Default author email address for posts.
247 =item $webmaster_email
249 Email address to use for webmaster responsible for the feed (defaults
254 Story permalink. Default is '$url$path/$fn.$default_flavour'.
255 Note that this value should probably be single quoted to defer
256 variable evaluation until rendering time.
258 =item $trackback_link
260 Story trackback or comment link. Default is ''. Useful if you
261 are using a comments plugin like C<writeback> or C<feedback>,
262 and the format you want will be plugin-dependant.
264 Like $permalink, this value should be single quoted to defer
265 variable evaluation till rendering time.
269 Default copyright clause for posts, if any.
275 rss20 should be loaded relatively late, since you'll typically want
276 plugins that manipulate your story content to have run already. It
277 also should be run after the 'story' or 'prefs' plugins if you want
278 to use those to customise your configuration variables.
283 Blosxom: http://blosxom.sourceforge.net/
285 rss20 is based on the 'atomfeed' and 'rss10' plugins, by Rael
286 Dornfest and contributors.
291 Please report bugs either directly to the author or to the blosxom
292 development mailing list: <blosxom-devel@lists.sourceforge.net>.
297 Gavin Carr <gavin@openfusion.com.au>, http://www.openfusion.net/
302 Copyright 2007 Gavin Carr.
304 This plugin is licensed under the same terms as blosxom itself i.e.
306 Permission is hereby granted, free of charge, to any person obtaining a
307 copy of this software and associated documentation files (the "Software"),
308 to deal in the Software without restriction, including without limitation
309 the rights to use, copy, modify, merge, publish, distribute, sublicense,
310 and/or sell copies of the Software, and to permit persons to whom the
311 Software is furnished to do so, subject to the following conditions:
313 The above copyright notice and this permission notice shall be included
314 in all copies or substantial portions of the Software.
316 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
317 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
318 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
319 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
320 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
321 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
322 OTHER DEALINGS IN THE SOFTWARE.