Web Design

Drupal and the Lost Art of the Bookmarklet

This article is mostly about one thing: creating a simple little "blog this" bookmark for your web browser.  But it reaches into larger issues of Drupal vs. Wordpress, and D6 vs. D7.

Wordpress has this nifty little feature where, when you find an interesting web page somewhere, simply press a button on your web browser and it will automatically create a new blog post for you, based on the web page you were looking at.    This is called a "bookmarklet."  It's one of the many, many reasons why people think Wordpress is easier than Drupal.  It's not that you can't do this in Drupal; it's just that it takes a lot of work to set up, versus being handed to you automatically in Wordpress.

Some people have turned this into a holy war, but calmer heads have pointed out that Wordpress is good at some things, and Drupal is good at others.

So, how do you do it in Drupal?  The most popular method involves the Prepopulate Module, which lets you create new content with certain fields already filled out.  Most people like to write a little javascript that sets it up just how they like it.  For Drupal 7, there's a module for that.

So, the discussion should end there, right?  If you can throw together a couple modules, then what's the problem?  The problem, of course, is if you're still running Drupal 6.  A lot of people are, myself included.  No one ever came up with a good migration path from D6 to D7, and that's fine because D6 is still a very fine piece of software, still runs very well, still receives bug fixes and security updates, and still has more modules available than D7.  In my case, I've got a multi-site installation with 4-5 different sites all running off the same Drupal core.  It would be a very large task to migrate them all to D7, even if an adequate upgrade path existed, and I'm doing most of these sites for free (for a non-profit organization).

The best bookmarklet script I've found was from Brock Boland, who also wrote the D7 module.  I modified it slightly to fit my own uses:

javascript: var siteURL='koplowicz.com', nodeType='blog', d=document, w=window, e=w.getSelection, k=d.getSelection, x=d.selection, s=(e?e():(k)?k():(x?x.createRange().text:0)), l=d.location.href.replace("http://",""), e=encodeURIComponent, url='http://'+siteURL+'/node/add/'+nodeType+'?edit[title]='+e(d.title); if(s) { s='<blockquote>'+s+'</blockquote>'; s+='\n\nfrom '+l; url+='&edit[body_field][body]='+e(s);} a=function(){if(!w.open(url,'quickpost','toolbar=0,resizable=1,scrollbars=1,status=1,width=1024,height=570')) l.href=url;}; if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)

Obviously you will have to modify the script for yourself.  Don't bother trying to post content to koplowicz.com; you don't have permission.  (Koplowicz.com is my personal blog, and is separate from my web design business.)

Bottom line: It is still possible to do everything in Drupal that you can do in Wordpress.  Just takes more work.  Of course, that begs the question: if Wordpress can have this handy feature built-in, why not Drupal?  There's no reason why simple features should be harder.  The only answer is that we're waiting for someone to write it.  Both projects are open source and community-supported, so this isn't a problem; it's an invitation.