20db AndrewSW: Blog » Blog Archive » State of the Blog address (yeah right) OR how to code an RSS feed by hand
20d2

State of the Blog address (yeah right) OR how to code an RSS feed by hand

So, I mentioned a while ago that I was planning on started a new blog. I still am. But let me go through some of the things that have been going through my mind.

First off: I decided Blososxm made more sense than GreyMatter. I even wrote some stuff to convert GreyMatter templates into a form usable by Blososxm.

Second, I have indeed integrated Blososxm (and GreyMatter too) with CGI::Kwiki, and one of the things at the back of my mind is to blog about that.

Third, I lost the energy to have a political blog. I may yet restart that, one of these days, but not yet. For now, I’ll just leave it as an interested experiment.

Fourth, I got motivation to do some other things. One of which I’ll keep secret for now, the other of which I won’t: as the author of the pluginsUsedPlugin I’ve found that people somehow magically found it and started using it. There are a bunch out there. So I feel kind of motivated to work on it a bit. Like make it be compatible with WordPress 1.3 (it is presently incompatible due to some internal WordPress change). But then I was thinking maybe I should also somehow semantically encode plugin data in the HTML that that plugin generates, and also ping some site, so that we could have a specialized sort of technorati-for-wp-plugins sort of thing. And then I thought that I didn’t really want to be the one in charge of that. I think that in the next version of the plugin, I’ll make the links to the plugins have a special class tag, and let people scrape if they want to build a technorati for wp-plugins sort of thing.

But, for the secret thing, now for the bulk of this post: it involves me coding and parsing RSS 2.0 (and probably eventually Atom as well) feeds. So I wanted to take some time and talk about some of the issues, many of which have probably already been addressed elsewhere.

First off: the RSS 2.0 Specification mentions the use of pubDate which is to comply with RFC822 but which I think to be sane that we should, like the Python library, conform to the RFC2822.

A tricky thing with this is to figure out the time zone appropriately. I decided to use the following snippet of Python code to do so:


# figure out our time zone offset
timeZoneInSeconds = time.timezone
timeZoneInMinutes = timeZoneInSeconds / 60
if timeZoneInMinutes == 0:
        myTimeZone = "+0000"
if timeZoneInMinutes > 0:
        myTimeZone = "+"+string.zfill(str(timeZoneInMinutes),4)
if timeZoneInMinutes < 0:
        myTimeZone = "-"+string.zfill(str(-1*timeZoneInMinutes),4)
print myTimeZone

myTimeZone then winds up having an appropriate offset thing - otherwise everything else works fine (of course, one could always use GMT, but I think parsing code should indeed be able to handle this sort of stuff).

Why, oh why, you ask, the is pubDate element so important to me now when back in the old days I would have thought nothing of coding a feed without it? Well, it can be important for a number of applications that might use RSS. Let me provide some examples: diffs, changelogs, feed-of-recently-modified-items, feed-of-recently-commented-items, and so on. Of course, this can probably be more precisely defined in Atom - but as far as I can tell, I’d really prefer to let the Atom spec settle down a bit.

But then, should I really bother? Perhaps I should just, when done, find an RSS to Atom converter? Where are they? I can easily find an Atom to RSS converter and I can’t quite tell if Feed Burner does it as well or not.

At any rate, I got the feed generated - kind of. Now I need to parse it. Fortunately, if I keep my memory usage down enough, I actually can run Python2 based CGIs, and so can use the xml.parsers.expat Python module, instead of continuing to program in PHP and use MagpieRSS like I have been. Don’t get me wrong, I like MagpieRSS, but I’m getting tired of using PHP and am yearning to return to the more (IMHO) elegant and simple Python.

Anyway, that’s enough of me rambling on for now.

So yeah, I likely won’t be creating another blog - sorry to continually alarm/threaten you all about my “I’m about to create another blog” and then not doing so, or then getting rid of it, or using it very infrequently.

Perhaps more on people creating multiple blogs another time.

b33


0