How to Build Your Own Lifestream with Yahoo Pipes and NO Server Side Logic

Step 6: Go Back and Fix/Prepare the Data

So, we are almost there this is basically the tips and tricks section. When I was building the interface for my Lifestream I noticed some issues that made me go back to the Yahoo Pipe to fix it.

Truncating

The first issue was to add a parameter to the pipe that would define the size of the output of the pipe. In some cases I only wanted one item outputted, in other cases 50, so adding a little parameter was of big importance. Doing this in Yahoo Pipes is pretty easy. By adding a “Number Input” module you can fetch a number, either direct from the user or as a parameter in the url. In my case, I added the module to accept a number for the parameter ‘l’ and then passed that number to the “Truncate Module” to truncate the output of the pipe. After this, passing a number to the pipe can be done easy by adding the parameter ‘l’ to the url:

http://pipes.yahoo.com/pipes/pipe.run?id=nLJtNct93BGnML4nl7okhQ&_render=json&_callback=drawLifeStream&l=50

Prevent Caching

Second thing I wanted to achieve was to get around a quirk of Yahoo Pipes that didn’t really fit my needs: caching. Yahoo Pipes caches stuff fanatically (about 24 hours) which is good for them and good for the response time, but not particularly nice for the refresh cycle of my lifestream. The workaround is pretty easy: just add a random cache parameter to the url and change the parameter whenever you wish to circumvent the caching.

In my case I only wanted to update every 30 minutes, so I got the current time in javascript, rounded that to the last 30 minutes, and got the MD5 hash. Then I passed this “cache token” to the Yahoo Pipe just like I did with the length parameter:

function loadJSON() {
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
var time = new Date().getTime();
time = time - (time%1800000);
time = time += "";
var token = hex_md5(time);
newScript.src = 'http://pipes.yahoo.com/pipes/pipe.run?_id=nLJtNct93BGnML4nl7okhQ&_render=json&_callback=drawLifeStream&l=50&cache=abcdef0123456789';
document.getElementsByTagName("head")[0].appendChild(newScript);
}

As I wasn’t sure if this was enough, I also passed this token to all the separate Feed Fetcher modules in all the Lifestream Items to make sure that Yahoo Pipes would not cache any feed when I wanted it to.

Add identifiers

Last, I wanted to make it a bit easier to identify in my Javascript code which item belonged to which original source. This makes it easy to add the different colors and logos to all the different sources in my Lifestream. The dirty way to do this is to look at the source URL, but as some feeds get run through Feedburner this is hard, plus it makes things more complex on the Javascript side for no specific reason.

The other way is to add specific new values to every item in the feeds, identifying them as being a “Flickr” item or a “Twitter” item. Take a look at the LifeStreamItem module to see how I did this as it was not particularly standard procedure. In short: I make a copy of one item value and name it “source, after which I then change it’s value to whatever I want it to be.

[Next up: Done...]

Pages: 1 2 3 4 5 6 7 8

10 Comments to 'How to Build Your Own Lifestream with Yahoo Pipes and NO Server Side Logic'

Subscribe to comments with RSS or TrackBack to 'How to Build Your Own Lifestream with Yahoo Pipes and NO Server Side Logic'.

  1. Paul Downey
    Paul Downey said,

    Nice! I built mine (http://360.whatfettle.com) using Venus and keep meaning to present it on a SIMILE timeline ..

  2. Cristiano Betta

    Hi Paul. What I like about your version is that show pictures/photos. I was thinking of doing something in SIMILE, but if you add a lot of rich media content that might get a bit confusing quickly.

    I had never heard of Venus. What is it? It’s a back-end technology I assume? Thing to remember here is that my project was also kind of an exercise for me to see what Yahoo Pipes and what I could do with it.

  3. http://alcopop.org/me/openid/

    Hi, the pipe debug link in this page is broken.

  4. Cristiano Betta

    Which link do you mean?

    There is loads of stuff broken, especially the images. My hosting provider lost them by accident and I still haven’t had time to put them back.

  5. http://alcopop.org/me/openid/

    It was the one on page four (I didn\’t realise the comments were common across all pages). P.S. thanks for the article!

  6. Cristiano Betta

    The link seems to work fine. Maybe you can’t access it because you aren’t logged in. The debug output is only accessible when you are editing the pipe. So go and make an account and start editing your or my pipe.

:: Trackbacks/Pingbacks ::

  1. Pingback by Kerry Buckley » [BarcampLondon3] Creating a Lifestream with Yahoo Pipes (CristianoBetta) - on November 24th, 2007 at 3:37 pm

  2. Pingback by Cristiano on Tech/Life » Video of BarcampLondon3 Presentation on Yahoo Pipes - on November 24th, 2007 at 4:55 pm

  3. Pingback by Four Starters » How to Build Your Own Lifestream with Yahoo Pipes and NO Server Side Logic - on November 26th, 2007 at 11:35 pm

  4. Pingback by Lifestream Posts & Pages for November 27th 2007 | Lifestream Blog - on November 28th, 2007 at 6:29 am

Leave a Reply

© Cristiano on Tech/Life • Powered by Wordpress • Themed based loosely on the Swiss Cool theme.