Monday, March 9, 2009

Blogging about blogging

Setting up the 360Data blog was just phase one of the operation; "spare" time this week has been spent integrating the blog with the regular web site front page so that new posts appear immediately in the sidebar area without any manual intervention on my part.

This sounds like something that should be easy, but in practice turned out to be a little more challenging than expected, but very interesting. Configuring the blog's Atom feed was easy, and I reckoned that consuming it was just a question of finding someone's pre-cooked RSS reader control and dropping it in, but I couldn't find one that did everything I wanted and that worked properly with the Atom XML format.

What did I want? Nothing too fancy, in theory: just a sidebar element that would read the blog's feed and deliver the newest posts. I only wanted the two most recent posts to appear (otherwise the sidebar content became too long) and only the first few hundred or so characters of each post were necessary to give a flavour of the entry (but I didn't want to have text cut in mid-word). I also needed to display the publication date, the title and link the title back to the entire post.

Eventually, after several sidetracks and false starts I ended up using the plain-vanilla ASP.NET XML Data Source control to call the feed, parsing out the two newest items from the resulting XML document with XPath, and writing my own functions to reformat the publish date and to only show the first couple of lines for the post in the sidebar instead of the whole lot. So as a side benefit to improving the site's maintainability and currency I learned some new things about XML processing in ASP.NET and my new favourite control is the Repeater (until my web hosting provider supports the ListView, at least).

I can feel a full-scale technical article coming on...

Labels: , ,