PipeJax - pure javascript version, Yahoo Pipes to Ajax Bridge
The goal of this is to have an easy way to load Pipes content onto your site. It’s very configurable, so you can style it to look the way you need it to look and it fails gracefully - it only appears when/if Pipes returns some content. So if pipes is down or the internet is slow or the pipe returns no results, you won’t see an empty box or anything. You can see this in action on this site - look for the “who else is writing about this” links at the bottom of most posts - if you reload the homepage you can watch them appear over a couple seconds.
You can use any Yahoo Pipe with any user supplied fields and automatically places them wherever you want in whatever format you want on your web page, more or less. I used to use a php file to mirror the json return, but thanks to this page I learned about Pipes’ javascript callback feature which lets you easily pull the JSON return and do something with it. I couldn’t find any documentation on the Pipes set but looking through that code, it works simply enough - you just pass in a _callback parameter with the name of your callback function and it gets called with the JSON variable passed in as an argument.
There’s a few steps involved in getting this to work for you, but they are all pretty easy, so bear with me. Here’s the instructions:
Prep Work:
- Download this tar file, it contains pipes-pure.js and test.html
- get jquery.js from jquery.com - here is a direct link to the download.
- rename jquery-latest.pack.js to jquery.js
Installation:
- add pipes-pure.js to your document root. You need to note down the url to access it in your browser.
- add jquery.js to your document root. You need to note down the url to access it in your browser.
- in your header (or header template) somewhere in the head block add these two lines (make sure that the paths to these two files are the ones you noted down in Installation Steps 1 and 2 - not /path/to/jquery.js):
- <script type=”text/javascript” src=”/path/to/jquery.js”></script>
- <script type=”text/javascript” src=”/path/to/pipes-pure.js”></script>
That’s it for installation. Now to actually use it you need to put some html in your file. If you look in the contents of test.html you’ll see that it has in the head block the two lines from Installation Step 5 (it’s set to work with my setup - so this file will not work for you unmodified).
The easiest way to see this working is to put it in your document root after updating the two script tags so that it points to jquery.js and pipes.js as they exist on your server. Once there, you should see (after a few moments while it loads the data) two sets of links appear. First should be 2 links that relate (at least a little) to snowboarding and then 4 links that relate to jquery.
If you look at the source code you’ll see several things. The key things are in the surrounding div tags. First, each of the two surrounding div tags have a class of deasil_pipe, this is the trigger that says this is something we need to pull links for. You can leave that as is. The second thing is you’ll see a deasil_pipe attribute, in this case it says deasil_pipe=’AHaR2Y242xGwcHpiZFUMqA’ - this is the id of the pipe you are trying to access, in this case it is my technorati search pipe. You can update that so that this will reference whichever pipe you like.
Then you’ll see a couple attributes that look like deasilx_[something], in this case it’s deasilx_text and deasilx_num - text and num are the names of the two user input fields I created for the technorati search pipe. By placing these deasilx_ attributes in the div, I am going to send their values to the yahoo pipe. So, as you can see, whatever user inputs are required can simply be added to this template. You can see in the first set I send deasilx_text=”snowboarding” and deasilx_num=”2″ - so that’s why you see two links about snowboarding. In the seccond deasilx_text=”jquery” and deasilx_num=”4″ - 4 links about jquery. Easy! Right?
So, that lets you set which pipe you want to access and what fields you want to send it. Then within each surrounding div (the ones with class=”deasil_pipe”) you see some more html. Right now there’s only three magic things here - things with class deasil_pipe_item, deasil_pipe_link and deasil_pipe_title. Everything else that is text or html w/out those classes will show up untouched.
deasil_pipe_item is how we should display 1 link. So for each element that the pipe returns, this html will show up once. An “a” tag with class of deasil_pipe_link will get it’s href set to that link and a span class with class deasil_pipe_title will show up with the title within the span. All of these things can be styled as anything else, so you could give the span another class or surround it with “b” tags to make it bold, etc..
One last thing, you’ll notice that on the surrounding divs (class=”deasil_pipe”) I have set the style to display: none. This hides the whole block until we get data back from yahoo (which can be flaky at times) and so the html will only show up if we get good data back.
That’s it - it may sound like a lot of work, but it’s actually fairly easy to work with, once you get the hang of it. Please let me know if you run into any trouble or if you successfully install it somewhere!








February 19th, 2007 at 11:54 pm
Great Job! I got it up and running at DirtyGreek.org
Don’t have the styling the way I want yet, but it works!
February 20th, 2007 at 8:13 am
Try turning the pipe_item div’s into spans and you should be set :) Glad it worked out!
February 20th, 2007 at 3:32 pm
Any chance of turning this into a wordpress plugin?
February 20th, 2007 at 3:38 pm
That’s a great idea! I’ve never written a plugin before and my php sauce is pretty weak, but it’d be a good learning experience. I’ll look into what’s involved.
But how would you like to see this used? As a sidebar thing? Or a per-article thing?
February 21st, 2007 at 11:21 am
[...] used PipeJax to stick this on - tweaked it a little bit because it wasn’t dealing with nested items [...]
February 27th, 2007 at 4:59 pm
Personally I’d probably just use it on a per-article basis, but I’m sure some people would like to use it on their sidebar for one thing or another.. I haven’t looked at making wordpress plugins before but I do know a bit of php if you’d like some help :]
February 28th, 2007 at 10:38 am
[...] thought so, punks!) Anyhow.. I decided to give it a whirl and created a new technorati search pipe, same as the old one but this time I append the domain-ey part of the link to the end of the title. So I try and get the [...]
March 15th, 2007 at 10:07 am
[...] been thinking about serendipity in the discovery of pages while surfing the web. With all the noodling around I’ve been doing with Yahoo Pipes (bear with me, this post isn’t about Pipes but rather a lucky byproduct of how I’ve [...]
March 15th, 2007 at 2:01 pm
Nice app :-)
I took a different approach and tried to hand the rendering work over to Grazr by generating grazrscript UIs (for example, some are here: http://blogs.open.ac.uk/Maths/ajh59/009993.html)
I only just came across your blog (via cleverclogs) and can already see my weekend disappearing trying some of your pipework out!
tony
March 15th, 2007 at 5:32 pm
Thanks, stringle looks pretty sweet, too!
March 23rd, 2007 at 8:22 am
Thanks, nice app
I have got these errors on Firefox (it doesn’t work on IE either)
deasil.pipe_callbacks_0_ is not a function
deasil.pipe_callbacks_1_ is not a function
With the “web developer” add on of Firefox, when I view javascript, i can see (with “_callback=deasil.pipe_callbacks[0]“, yahoo pipes returns “deasil.pipe_callbacks_0_”) :
http://pipes.yahoo.com/pipes/AHaR2Y242xGwcHpiZFUMqA/run?_render=json&_callback=deasil.pipe_callbacks0&num=2&text=snowboarding
deasil.pipe_callbacks_0_({”count”:2,”value”:{”title”:”technorati …
….
http://pipes.yahoo.com/pipes/AHaR2Y242xGwcHpiZFUMqA/run?_render=json&_callback=deasil.pipe_callbacks1&num=4&text=jquery
deasil.pipe_callbacks_1_({”count”:4,”value”:{”title”:”technorati ….
March 23rd, 2007 at 8:45 am
Yes, something seems to have changed on the Pipes side about yesterday or the day before. I haven’t had a chance to look into this yet. Sad.
March 23rd, 2007 at 9:26 pm
ok, yahoo changed something so they were not liking array notation in the callback function. I updated that to dot notation and all seems well again, please give it another shot!
Just redownload the new tar.gz file above and that should give you the slightly modified pipes-pure.js.
March 27th, 2007 at 3:52 am
Thanks,
I have download the new tar.gz file above.
In the file “test.html”, i have replace “pipes-pure-test.js” by “pipes-pure.js”, class=”d easil_pipe” by class=”deasil_pipe”, class=”dei asil_pipe” by class=”deasil_pipe”.
It works fine.
June 20th, 2007 at 1:32 am
Yahoo pipes team have posted something similar on
http://blog.pipes.yahoo.com/examples/example.01.html
July 29th, 2007 at 7:41 pm
Nice! Now, though, I’m looking for a simple solution for incorporating the full text of a Pipes RSS feed, not just a list of links. I thought about trying to extend your solution, but I quickly got in over my head. Suggestions?
– Prentiss Riddle riddle@io.com
July 30th, 2007 at 2:48 pm
Prentiss - huh, that’s probably a good idea! I’m about to leave on my honeymoon, so I can’t update the code just yet but I’ll add that in when I get back. If you’re interested to take a shot I think all you’ll need to do is add more fields (i.e. add in deasil_pipe_description, or whichever fields you want to pull from rss) into your html and then edit in the deasil.doit() function where you see things like var Link = $(’#’ + id + ‘.deasil_pipe_link’) - add a new one for the new fields and then set it below, with something like description.append(cur.description). Something along those lines. But I’ll also give it a whack when I get back. :)
October 7th, 2007 at 4:35 pm
Hi Felix, your suggestion in the last comment worked well in getting the description of a feed displayed, but I haven’t had any luck trying to restrict the output. I looked into the code you wrote in pipes-pure.js, and noticed you have a function in there that does something similar to the title. I couldn’t figure out how it worked though, especially what you set the limit to be. I attempted to duplicate it for the description, but that didn’t quite work. Do you have any suggestions on how to proceed on this? Ideally, the solution would limit the description output to around 250 characters while also stripping out any images that may appear.