pmuellr is Patrick Mueller, Senior Node Engineer at NodeSource.

other pmuellr thangs: home page, twitter, flickr, github

Friday, November 03, 2006

creating tagged feeds from roller

So, this dWorks blog supports tagging, which is great and all, but doesn't seem to support generating a feed of entries based on the tags, which isn't great. I asked the various &dieties; that I knew, Elias Torres, who I ended up having a great extended call with today, and James Snell, if they knew how to do this. In fact, I remembered James posting a blog entry with some roller atom generation hacks. Upside, they thought it was possible, but didn't have anything they could give me at the moment.

Blade Here by alykat

I started with James' blog post Deploying a Comments Feed in Roller, which got me most of the way there. And then tweaking from there.

Here's what I have so far:

Debugging these templates is ... a pain. And the programming facilities, using Velocity, aren't quite complete enough for my tastes.

One problem was the $requestParameters macro will give you the values for a particular query string parameter, but it gives you the values as an array (which is what you want). But Velocity doesn't seem to have any way of accessing arrays. Which seems totally insane. I found a little utility object the roller exposes called $utilities with a method called stringArrayToString which was ... good enough.

How did I find the $utilities variable? Roller's help. Notice however, no description of what $utilities is, is actually provided. How did I find stringArrayToString?

Debugging even something as small as this template is quite painful. One false move, and you'll get a 500 back from your server, with no indication of what the problem is. The trick is to create another template that you can plop tiny bits of code to exercise, and test that first. Want to know what class the $utilities object is, so you can find what methods are available? Just put the string $utilities in the 'testing' template, save, and then view the template. Voila. Hopefully you'll get the default toString() representation of the object, yielding the class name. From there ... google is your friend.

The crudest form of doIt / printIt I think I've ever used, but good enough for jazz.

Anyway, looks like it's functional, and validates.

Photo "Blade Here", with a nice CC license, by alykat. Found using the Create Commons Search Site.

No comments: