Friday, May 22, 2009

Twitter-like delicious gadget for your blog

I was inspired by the great articles I've read today (which I got from Hacker News) so I decided to put links to these articles on my blog. Using the delicious API and some javascript goodness, I created a twitter-like delicious bookmarks list that I can use on my blog (or any blog for that matter). Check it out in action at my sidebar (below the twitter widget).

If you want the same thing, copy the code below and put it to where you want it to appear on your blog.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script>
// change to your username and tag
delicious_widget = {username: 'tonio95', tag: 'read'};

delicious_widget.feed = 'http://feeds.delicious.com/v2/json/'+delicious_widget.username+'/'+delicious_widget.tag+'?count=10&callback=delicious_widget.print_list';
delicious_widget.print_list = function(data) {
var box = ['<ul>'];
$.each(data, function(i, item){
box.push(['<li><a href="', item.u, '">', item.d.substring(0,60), '</a></li>'].join(''));
});
box.push('<li><a href="http://delicious.com/'+delicious_widget.username+'/'+delicious_widget.tag+'">More!</a></li></ul>');
document.write(box.join(''));
};
document.write(unescape("%3Cscript src='" + delicious_widget.feed + "' type='text/javascript'%3E%3C/script%3E"));

</script>

Enjoy! and have fun reading!
Want more delicious? check out the delicious lite firefox extension

No comments:

Post a Comment