Fri, 28 Sep 2007

« Sorry, folks | MAIN | The herd »

Setting up an rss feed from scratch

Or, adding rss to your pyblosxom flavour. This is for static rendering, which is all I use. I don't know whether this would work as-is for dynamic rendering.

UPDATE: Will Guaraldi set me straight. Adding "rss" to your "static_flavours" will give you a separate rss file for every entry and category in your blog along with the main rss file. That's crazy. If you're using static rendering and you just need one rss file for the whole thing, then add this to your config.py:

py["static_urls"] = ["/index.rss"]

and keep your original static_flavours setting.

Original entry (superceded):

The key to the problem is that rss is just another pyblosxom flavour. First, mention "rss" in the list of flavours to be rendered in config.py:

# What flavours should get generated?
py["static_flavours"] = ["html", "rss"]

Then create two files in your flavour directory, head.rss and story.rss:

head.rss

"
<?xml version="1.0" encoding="$blog_encoding"?>
<!--
    This web page is actually a data file that is meant to be read by
    RSS reader programs.

    See http://interglacial.com/rss/about.html to learn more about
    RSS.
-->
<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
  <title>blog_author - $blog_title</title>
  <link>$base_url</link>
  <description>$blog_description</description>
  <language>$blog_language</language>
  <copyright>$blog_rights</copyright>
  <pubDate>$latest_rfc822date</pubDate>
  <managingEditor>$blog_email</managingEditor>
  <generator>$pyblosxom_name [$pyblosxom_version]</generator>

story.rss

"
<item>
  <title>[$absolute_path] $title</title>
  <guid isPermaLink="true">$base_url/$file_path</guid>
  <link>$base_url/$file_path.html</link>
  <category domain="http://members.wolfram.com/billw">$absolute_path</category>
  <author>$blog_author &lt;$blog_email&gt;</author>
  <comments>$base_url/$file_path.html#comments</comments>
  <slash:comments>$num_comments</slash:comments>
  <pubDate>$rfc822date</pubDate>
  <description><![CDATA[
$body
]]></description>
</item>

(Note my hard-coded category domain. Is there a pybl setting for that?)

And that's it! When you do your static rendering you should see a bunch of .rss files being generated. You may also want to link to your new rss feed on your blog, as in:

<li><a href="http://members.wolfram.com/billw/summa/index.rss" >This blog's RSS 2.0 feed</a></li>

A facility for quotation covers the absence of original thought.—Lord Peter Wimsey

Left column Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.