X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fblosxom-plugins.git;a=blobdiff_plain;f=gavinc%2Frss20;h=4800501e3f1b48e6516786e9a6bd5a7d981ed9c8;hp=4d7ac2951aa785bc236496d05086a79ea3a7ebec;hb=6d84a0387fdb773efefb534d385ba663395f4acf;hpb=20f6152e08a8e4e7bc9a063cf5d4b4a73f8c3b48 diff --git a/gavinc/rss20 b/gavinc/rss20 index 4d7ac29..4800501 100644 --- a/gavinc/rss20 +++ b/gavinc/rss20 @@ -1,21 +1,24 @@ # Blosxom Plugin: rss20 # Author(s): Gavin Carr -# Version: 0.001002 -# Requires: storydate, lastmodified2 -# Suggests: absolute -# Follows: storydate, lastmodified2 +# Version: 0.002000 +# Requires: storydate +# Suggests: absolute, storytags +# Follows: storydate package rss20; use strict; + use vars qw( $flavour $author_email - $error_email + $author_name + $webmaster_email $permalink $trackback_link $copyright - $generator_url + $generator + $category_list ); # --- Configuration variables ----- @@ -25,10 +28,18 @@ $flavour = 'rss'; #$flavour = 'rss20'; # What email address should be used as the default author email? -$author_email = 'author@example.com'; +# Recommended format is 'email (name)', but bare emails or mailto emails are ok too +$author_email = 'author@example.com (A. U. Thor)'; + +# What name should be used as the default author name? +# Define this only if you don't want to disclose an email address in $author_email. +# It will be ignored if $author_email is set. +$author_name = ''; # What email address should feed errors be reported to? -$error_email = ''; +# Recommended format is 'email (name)', but bare emails or mailto emails are ok too +$webmaster_email = ''; +#$webmaster_email = 'webmaster@example.com (Web Master)'; # What do your story permalinks look like? # This must be single-quoted, to defer evaluation; blosxom namespace applies @@ -44,11 +55,15 @@ $trackback_link = ''; $copyright = ''; # Generator that produced this feed -$generator_url = "http://blosxom.sourceforge.net/?v=$blosxom::version"; +$generator = "blosxom $blosxom::version"; # -------------------------------- +# __END_CONFIG__ + +$webmaster_email ||= $author_email; -$error_email ||= $author_email; +my $channel_indent = 8; +my $item_indent = 12; # Escape <, >, and & to hex-encoded entities for max compatibility in text elements # See http://www.rssboard.org/rss-profile#data-types-characterdata @@ -71,16 +86,32 @@ sub start { _load_templates(); } +my $do_encode = 0; sub story { my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; + # Ignore flavours other than ours + return unless $blosxom::flavour eq $flavour; + # Don't double-encode if someone else has already done it - return unless $blosxom::encode_xml_entities; + return unless $do_encode || $blosxom::encode_xml_entities; + + # Because we're inside a loop, we set $do_encode for runs after the first + unless ($do_encode) { + $do_encode = 1; + $blosxom::encode_xml_entities = 0; + } # Encode and reset encode_xml_entities flag $$title_ref = _escape_text( $$title_ref ); - $$body_ref = _escape_html( $$body_ref ); - $blosxom::encode_xml_entities = 0; + $$body_ref = _escape_html( $$body_ref ); + + $category_list = ''; + if ($blosxom::plugins{storytags}) { + for (@storytags::taglist) { + $category_list .= qq($_\n) . ' ' x $item_indent; + } + } } # --- Private subroutines @@ -107,42 +138,77 @@ sub _load_templates { + xmlns:atom="http://www.w3.org/2005/Atom"> $blosxom::blog_title - $blosxom::url - $blosxom::blog_description - \$lastmodified2::latest_iso8601 - $blosxom::blog_language - mailto:$rss20::author_email - $rss20::copyright - - + $blosxom::url/ +HEAD + + if ($blosxom::path_info) { + $blosxom::template{$flavour}{'head'} .= + ' ' x $channel_indent . + qq($blosxom::path_info\n); + } + if ($blosxom::blog_description) { + $blosxom::template{$flavour}{'head'} .= + ' ' x $channel_indent . + qq($blosxom::blog_description\n); + } + if ($rss20::author_email) { + $blosxom::template{$flavour}{'head'} .= + ' ' x $channel_indent . + qq($rss20::author_email\n); + } + elsif ($rss20::author_name) { + $blosxom::template{$flavour}{'head'} .= + ' ' x $channel_indent . + qq($rss20::author_name\n); + } + if ($rss20::webmaster_email) { + $blosxom::template{$flavour}{'head'} .= + ' ' x $channel_indent . + qq($rss20::webmaster_email\n); + } + if ($rss20::copyright) { + $blosxom::template{$flavour}{'head'} .= + ' ' x $channel_indent . + qq($rss20::copyright\n); + } + $blosxom::template{$flavour}{'head'} .= <\$storydate::latest_rfc822 + $blosxom::blog_language + $rss20::generator hourly 1 2000-01-01T12:00+00:00 - HEAD $blosxom::template{$flavour}{'story'} = < \$title - $rss20::permalink - \$body - $rss20::trackback_link - $rss20::permalink - \$storydate::story_iso8601 + $rss20::permalink + $rss20::permalink + \$storydate::story_rfc822 +STORY + + if ($rss20::trackback_link) { + $blosxom::template{$flavour}{'story'} .= + ' ' x $item_indent . + qq($rss20::trackback_link\n); + } + $blosxom::template{$flavour}{'story'} .= <\$body + STORY $blosxom::template{$flavour}{'foot'} = <<'FOOT'; - - + + + FOOT 1; @@ -177,10 +243,10 @@ Flavour string to use for your feed (typically 'rss' or 'rss20'). Default author email address for posts. -=item $error_email +=item $webmaster_email -Email address to use to report errors with the feed (defaults to -$author_email). +Email address to use for webmaster responsible for the feed (defaults +to $author_email). =item $permalink