Jeremy Keith’s lifestream was the first I saw online, where he’d aggregated together his many RSS feeds into one place. It shows the various sources ordered by time, and it can be quite interesting to follow along and see what sort of sources are most prevalent at any one time. I’d been meaning to have a play with something similar myself for some time, but wasn’t sure how to go about it. Then a couple of weekends ago, I went to BarCampLondon3 and Cristiano Betta did a great session on how to author your lifestream using Yahoo! Pipes. There’s bags more information about how to do it at his blog. Finally, I thought it was about time I had a play with it myself. The feeds I used were the following:
- My photographic blog
- My rubgymad blog
- My web design blog
- Stuff I post to Flickr
- My tweets from Twitter
- Stuff I’m reading via del.icio.us
I decided against using my Last.fm feed for the moment, as it would probably swamp all the other inputs (I listen to a lot of music while working, it’s one of the perks of working from home, no-one moans about your choice of songs!).
Having got the basic lifestream out of Pipes, I used Dreamweaver’s XSLT transform functionality to generate a list which would sit in my ASP.NET page. I wanted to use specific icons to show which feed each item was from. Cristiano was using a JSON output for his pipe, but mine is coming out as RSS, so the custom ID’s applied in the pipe weren’t getting through, since they’re not part of the RSS spec.
CSS3 attribute selectors are one option, but they don’t work in clunky browsers like IE6. So having also been at Simon Willison‘s jQuery session at BarCampLondon3, I thought I’d have a play with with the library to see if I could do some neat DOM manipulation to add the correct class to each list item.
The Llifestream list is marked up thus: <ul id=”lifestream”>. I added some jQuery to insert the class for the list element, based on the attribute of the link it contains. That requires a parent element to be changed, based on it’s child’s attributes. Slightly tricky for a jQuery novice like myself. It took me a while but eventually I found the correct syntax:
$(“#lifestream > li > a[@href^=http://twitter]”).parent(“li”).addClass(“twitter”);
The first line calls jQuery once the full DOM is loaded; line 2 (which looks rather horrible with text wrap, but bear with me) selects an anchor with the attribute which begins with “http://twitter”, but I wanted the class added to the parent LI, so hence the chaining of jQuery functions.
Now all I needed to do was to add a case for each link type to my new lifestreamclasses.js file and add a linke to it in the header of my lifestream page, and the proper stylings can be applied. I decided to keep them in a separate JS file for ease of maintenance. Once the pipe has mashed it all together and I’ve written the relevant styles into the stylesheet, the resulting RSS aggregated feed looks like this.