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 $blosxom::template{$flavour}{'head'} .= <<HEAD;
179 <pubDate>\$storydate::latest_rfc822</pubDate>
180 <language>$blosxom::blog_language</language>
181 <generator>$rss20::generator</generator>
182 <atom:link href="$blosxom::url$ENV{PATH_INFO}" rel="self" type="application/rss+xml" />
183 <sy:updatePeriod>hourly</sy:updatePeriod>
184 <sy:updateFrequency>1</sy:updateFrequency>
185 <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
188 $blosxom::template{$flavour}{'story'} = <<STORY;
191 <title>\$title</title>
192 <link>$rss20::permalink</link>
193 <guid isPermaLink="true">$rss20::permalink</guid>
194 <pubDate>\$storydate::story_rfc822</pubDate>
197 if ($rss20::trackback_link) {
198 $blosxom::template{$flavour}{'story'} .=
200 qq(<comments>$rss20::trackback_link</comments>\n);
202 $blosxom::template{$flavour}{'story'} .= <<STORY;
203 \$rss20::category_list<description>\$body
208 $blosxom::template{$flavour}{'foot'} = <<'FOOT';
224 rss20 - blosxom plugin to generate an RSS 2.0 feed of your blog
228 rss20 is a blosxom plugin to generate an RSS 2.0 feed of your blog. It
229 is self-contained, including the required flavours, and has a bunch of
230 configuration variables to allow for configuration.
234 The following package variables can be configured:
240 Flavour string to use for your feed (typically 'rss' or 'rss20').
244 Default author email address for posts.
246 =item $webmaster_email
248 Email address to use for webmaster responsible for the feed (defaults
253 Story permalink. Default is '$url$path/$fn.$default_flavour'.
254 Note that this value should probably be single quoted to defer
255 variable evaluation until rendering time.
257 =item $trackback_link
259 Story trackback or comment link. Default is ''. Useful if you
260 are using a comments plugin like C<writeback> or C<feedback>,
261 and the format you want will be plugin-dependant.
263 Like $permalink, this value should be single quoted to defer
264 variable evaluation till rendering time.
268 Default copyright clause for posts, if any.
274 rss20 should be loaded relatively late, since you'll typically want
275 plugins that manipulate your story content to have run already. It
276 also should be run after the 'story' or 'prefs' plugins if you want
277 to use those to customise your configuration variables.
282 Blosxom: http://blosxom.sourceforge.net/
284 rss20 is based on the 'atomfeed' and 'rss10' plugins, by Rael
285 Dornfest and contributors.
290 Please report bugs either directly to the author or to the blosxom
291 development mailing list: <blosxom-devel@lists.sourceforge.net>.
296 Gavin Carr <gavin@openfusion.com.au>, http://www.openfusion.net/
301 Copyright 2007 Gavin Carr.
303 This plugin is licensed under the same terms as blosxom itself i.e.
305 Permission is hereby granted, free of charge, to any person obtaining a
306 copy of this software and associated documentation files (the "Software"),
307 to deal in the Software without restriction, including without limitation
308 the rights to use, copy, modify, merge, publish, distribute, sublicense,
309 and/or sell copies of the Software, and to permit persons to whom the
310 Software is furnished to do so, subject to the following conditions:
312 The above copyright notice and this permission notice shall be included
313 in all copies or substantial portions of the Software.
315 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
316 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
317 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
318 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
319 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
320 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
321 OTHER DEALINGS IN THE SOFTWARE.