Skip navigation.
Home

Drupal "Blog this" bookmarklet

Note: this has been updated in this post to fix problems with certain website titling conventions, and you'll probably want to go there for a look - after reading this, naturally!

Well, after the previous post where I said I missed the Blogger bookmarklet, I realised that somebody else probably felt the same way, so I Googled for 'drupal bookmarklet' and found a few handy links. Only one of them worked for me (I'm using Firefox, as any sensible PC user uses) but I could tell it had been hacked from something else. Well, I took it upon myself to rehack it a bit, to make it more useful for me, and I share the results here for you...

First of all, the code. This is the javascript, split onto seperate lines, so you can see what's going on. If you copy all of this, put it all on one line, replace example.com with your Drupal-powered website, and turn that into the 'location' bit of a bookmark, you get the functionality I was looking for.

javascript:
u=document.location.href;
t=document.title;
s='<blockquote>'+window.getSelection()+'</blockquote>';
pre='<em>From <a target="_blank" href="'+escape(u)+'">'+escape(t)+escape('</a>:</em><br /> ');
void(window.open('http://www.example.com/node/add/blog?edit[title]='+escape('Link: '+t)+'&edit[body]='+pre+escape(s)+escape('<a href="'+u+'" target="_blank">Link</a>'),'_blank','width=710,height=500,status=yes,resizable=yes,scrollbars=yes'));

Obviously that's a bit of a lot to do, so what you could do instead is drag this link to your bookmarks toolbar, then edit the properties so as to give it a useful name and (more importantly) replace www.example.com with your website in the location. (You'll have to do a whole load of scrolling to get there, but it's simple enough.)

If this doesn't work with Internet Explorer... tell it to someone who cares =) Seriously, I never use it, and I made this for me. Feel free to hack this into a shape that works for you.

Requirements

  • Mozilla Firefox. (The traditional Mozilla suite browser is probably fine.)
  • A Drupal website to post to. With it being a bookmarklet it should work with all manner of versions.
  • That's it.

How to use it

On a page that you want to refer to, (optionally) select some text to quote, then hit the Drupal bookmarklet. The page title becomes the blog entry's title, you get a top-and-tail link to the original page, and the text you selected is inserted into <blockquote> tags. Then post and enjoy!

Credits

Thanks to Moshe Weitzman whose bookmarklet I based this on, and whoever he based his on, and so on. And thank you for reading this.