Monday, March 10, 2008

Tumblr hack: A real tag cloud

Tumblr may come up with "real" tag browsing soon, but meanwhile, here's a tag cloud that -- unlike third party services -- uses the actual tags that you assign to your posts.

Basically, the script calls the Tumblr JSON API and processes the posts, 50 at a time (the maximum allowable; configurable). It saves the tags, URLs, and a bit of the content. If there are any remaining posts, it keeps on doing this until it retrieves all of them, or reaches a preset maximum (150 by default, or thrice). It then renders the tags in varying font sizes depending on the total number of times each tag was used.

By default, links are created for each of the tags. Clicking on a tag will generate a list of posts with that particular tag. [ Hey Tumblr! A /tags/<tagname> path that only shows posts with that tag would be nice. :-) ]

I used Jason Levitt's Dynamic Script Tag class to call the Tumblr API as many times as required.

Here's*** the quick-and-dirty demo script showing the tags from my scifaiku site (again). If you do use it, please send me your URL via a comment. :-)

*** Update: The original one didn't use the titles (I had no titles in scifAI, originally) but instead parsed the content up to the first HTML tag. Here is a more generic one, using post titles.

16 comments:

GB said...

just put it up on mine. cool!

gregcbrown.net

Unknown said...

Hi Greg! You may want to try this one instead, as the original code was tuned for scifAI. The new one uses the actual post titles as the links. See the tumblrCallback function for changes.

Maia Bittner said...

Hi Alex, I'm working on putting mine up here: http://www.maiaeats.com

Thanks!

Todd said...

Hey Alex -

First off, thanks so much for putting this together!

Now, on to the business at hand... I'm trying to get this up and running at http://tumble.toddlevy.com/ and it's not quite working.

It'll only return 3 or 4 posts at most. I tried messing with CLOUD_JSON_NUM and CLOUD_JSON_MAX to no avail.

In fact, as best I can tell, CLOUD_JSON_NUM isn't ever used in the code. And if I set CLOUD_JSON_MAX to 0, I get a 503 error from Tumblr.

Any help appreciated.

TL

i like jesus buns said...

Hey thanks for this neat script: i spent a bit of idle time tooling around with it on my page, and created a crappy hack that puts a tag blurb at the bottom of posts as well. Now if there was some way to do it on the dashboard, i feel like a dumba**, but still, it was fun to play around with:

http://modx.tumblr.com/post/43313433/enjoy-the-tags-or-else

Hatch said...

Bug Report :-D

Find this line:
cloud_request = new JSONscriptRequest(CLOUD_JSON_URL + '?callback=tumblrCallback&type=regular&start='+cloud_done+'&num='+CLOUD_JSON_MAX);

And change CLOUD_JSON_MAX to CLOUD_JSON_NUM.

Also, the script only shows text posts. If you aren't getting very many results, maybe you don't have very many text posts.

Anonymous said...

Thanks!

I've updated mine to

1) include all tags from all types of posts (remove "type=regular" from buildCloud function) and,

2) set the tags to be links to the list of your posts with that tag.

' +cloud_tags[i]+ ' ';

Active here:
http://reactorboy.tumblr.com

Anonymous said...

@joegasper: THANK YOU!

Tag cloud is finally working as desired on my site!

See it in action here...
http://tumble.toddlevy.com

Peteski said...

got it (sort of) kind the way I want it.

http://hotwheels.tumblr.com/

thanks.

p4tr1ck said...

Just got it all figured out.

http://p4tr1ck.tumblr.com

Unknown said...

Hi,

I was using your script on Tumblr and it was working great. Until recently : it just disappeared. No more cloud. I didn't mess with the code. At first I thought I must have create too much tags, but people are telling me there is no limit on the number of tags you can create. Any idea? And thanks for the hard work.

chadanuk said...

http://dan.blogs.steamshift.com/

SKS said...

I think I am a confused novice, but where is the actual HTML script to add to my tumblr?

Thanks!

Anonymous said...

help an idiot out.

ive got the script working fine to a point - but how do i get it to break out of the sidebar when displaying a post for a clicked tag?

just click any tag http://gascomm.tumblr.com/ to see my problem

wakeleyrabito said...

Wynn Resorts - Hotel & Casino - Dr. Maryland
Wynn Resorts 삼척 출장마사지 is the 거제 출장안마 official 울산광역 출장마사지 destination for all 춘천 출장샵 things gaming and entertainment,” said Linda 정읍 출장안마 Chen, Director of Wynn Resorts and Chief Operating Officer of

tadhgsaad said...

Paddy Power in the £400m UK: Paddy Power owner wants to sell it
The titanium watch band Paddy Power brand had its annual share price fall by 2.50% last month due to babyliss titanium flat iron the titanium glasses frames Covid-19 pandemic, but that ford ecosport titanium figure remained unchanged for cerakote titanium