Today I got fed up (sorry) with my current RSS reader, and set out to find a new one. I settled on NewsFire. Unfortunately, NewsFire does not display the categories associated with each item. There are a few feeds (notably Planet Case) where I want to view this information, so I came up with a solution.

The solution is a CGI script, written in Ruby, that transforms an RSS 2.0 feed (Atom is not supported) so the categories are listed at the top of the item body. I called it "categorify.cgi" and dropped it into my machine's web server root directory.

Now, instead of subscribing to the feed directly in NewsFire, I instead subscribe to the categorify script. For example, instead of subscribing to, I would subscribe to http://localhost/~andrew/categorify.cgi?rss=

As an added "nifty" feature, the script supports turning each category name into a link. So http://localhost/~andrew/categorify.cgi?rss= would link each category name to its corresponding page on - handy for viewing other blog entries with the same tag.

Here's the source code of the categorify.cgi script:

#!/usr/bin/env ruby

require 'cgi'
require 'rss/2.0'
require 'open-uri'

cgi =
rss_uri = cgi.params['rss'].first
link_uri = cgi.params['link'].first

rss_text = open(rss_uri).readlines.join
rss = RSS::Parser.parse(rss_text, false) do |item|
  cats = item.categories.collect do |cat|
  if link_uri! do |cat|
      "<a href=\"#{link_uri}#{cat}\">#{cat}</a>"
  if cats.length > 0
    item.description =<<-END
<p style="font-size: 85%; margin-top: 0;">
  <strong>Tags:</strong> #{cats.join(', ')}

cgi.out { rss.to_s }
Post a comment