Reblog notes

In light of the imminent release of Tumblr 5, this was probably a needless exercise, but after reading this post about linking to reblog notes from a custom Tumblr theme, I had to give it a try. Tumblr makes reblog notes available as a fragment of HTML containing just an ordered list. The fragment can be fetched using a URL containing the post’s numeric ID and the post owner’s unique key. (The unique key is different from the user’s Tumblr account name, so that notes can’t be viewed unless the key is made public — I’m happy for my notes to be read, thus I’ve included my key in the source code.)

Linking to unstyled notes on another page is a start, but I preferred to mimic the Tumblr dashboard (and the sites of Tumblr staff) that use AJAX to load and display notes right on the post page. Due to cross-site scripting protection in modern browsers, the only way to load an HTML fragment from a different domain (my site is on matthewbuchanan.name, the notes are on tumblr.com) is by using JSONP to provide the name of a callback function that can send the data from the other domain. To do this I parsed the notes fragment with the help of Troy Wolf’s PHP Proxy, and added in the necessary JSONP handling with a little guidance from someone who knows about such things. I also stripped out the avatar images on the way through, as I’m not displaying them.

The mechanic on the site is fairly simple. jQuery looks for every link with a class of notes-button and preloads the parsed notes fragment for each into a hidden div. (I’m pre-fetching the notes so I know how many there are for each post.) If there is more than one note — ie, someone other than me reblogged or liked the post — the link to view the notes is displayed. Clicking the link reveals the hidden div, styling for which exists in the site’s CSS. (If you’re reading this on the Dashboard, you can see the results here.)

Because of the server-side parsing requirement (and the expectation that easier support for notes will be in the forthcoming release, in the form of new custom theme tags), I’m not releasing this for anyone to use at present, but if there’s huge demand I might reconsider. Might you put notes on your Tumblr if you could?

Update: no API or custom theme changes were announced with the Tumblr 5 Dashboard release, so I released the above as a plugin.

ADS by FUSION

Written and designed by Matthew Buchanan. Colophon. Please give credit. Email