Wednesday, November 30, 2011

Posting HTML from Pinboard

I finally jumped off social bookmarking site Delicious during the whole kerfuffle over their problem-laden relaunch and moved to Pinboard on the recommendation of @sogrady and others. I had previously setup an account when the then parent of Delicious, Yahoo, began to send signals that it was shutting the service down. I now switched full-time.

The problem was that some Javascript code I was using to easily generate HTML code from my bookmarks and notes for pasting into Blogger stopped working.(See, for example, this post.)  This was actually the reason that I didn't switch to Pinboard full-time when I first setup the account.

I'm far from a Javascript wizard and I had received the code indirectly through a friend so the issue wasn't immediately obvious. It should have kept working; the API's were supposedly compatible except for some documented format changes. But it didn't work.

However, with my full-time switch I had to do something so I dove in and started hacking at the code. What appears to have been the problem was that, with the old Delicious (the new Delicious broke the code too), an object with global scope was being instantiated by the JSON call that retrieves recent bookmarks. Copying the JSON object into a global variable seemed to fix the problem. This doubtless should have been obvious.

In any case, if you use Pinboard and ever have occasion to create HTML from your bookmarks for posting somewhere else, you may find this code useful. You just need to substitute your username into the JSON URL where the comment tells you to. You can also customize in other ways as shown on the Pinboard HowTo page.



Post a Comment