September 6, 2007

Revising Movable Type 4's QuickPost Bookmarklet

Movable Type 4, like its predecessor Movable Type 3, includes a "QuickPost" bookmarklet—a link you can install in your browser's Bookmarks bar that you can click on when you're looking at a page you want to link to from your blog. Clicking on it opens the entry editor in another window, pre-populated with information about the page.

To set up the QuickPost bookmarklet, go to your blog's admin screen, click the Write Entry button, then scroll down below the "Save" button, and drag the "QuickPost to ..." link to your browser's Bookmarks bar.

Movable Type 4 changed the format of the pre-populated entry from MT 3. MT 3's bookmarklet created a new entry with no title, and an entry body containing HTML for the link to the page whose text was the title of the page. If you had selected text before clicking the bookmarklet, that text appeared below the link. It looked something like this:

[Title:] 
[Body:]
<a href="http://url-of-page/">Title Of Page</a>
 
Selected text, if any.

In MT 4, the QuickPost bookmarklet pre-populates the entry's title with the title of the page, and sticks the URL of the page and the selected text in the message body. The URL is not a link, it's just the URL, followed by two <br /> tags, then the selected text, if any. Like this:

[Title:] Title Of Page
[Body:]
http://url-of-page/<br /><br />
 
Selected text, if any.

The new behavior is weird. Entry titles are all the rage with newer blogs and RSS feeds, so I'll grant that I'm behind the times for not using entry titles on short link-y entries. And perhaps usability studies showed that most people didn't want the page title to be the link text, though it doesn't seem like a hassle to make that the default. But I can't think of a reason why I'd want to use the URL without being a link. The <br /> tags recall a heated debate about the behavior of MT 4's new rich text editor, which uses <br /> tags between paragraphs instead of surrounding them with <p>...</p> tags. (The old default "Convert Line Breaks" does better.) The only real point of contention I can think of is the new rich text editor, and the other text formatters that come bundled. But as far as I can tell, the QuickPost bookmarklet's behavior is undesirable for all of them except the "None" formatter.

Thankfully, it's easy to edit the QuickPost bookmarklet after setting it up. The steps for editing the URL of a bookmark differ from browser to browser, but assuming you can figure that out, you can paste in new code. In Firefox, one way is to right-click on the bookmark in the bookmarks bar, select Properties, then edit the Location. You can also do it from the Bookmarks Manager: Bookmarks menu, Organize Bookmarks...

The following bookmarklet code reproduces the old behavior: no title, body contains HTML for a link to the page with the page title as the text, and selected text afterward. To use it, copy this text, paste it into your bookmark, then replace www.dansanderson.com/blog/mt/mt.cgi with the URL of your blog's mt.cgi.

javascript:d=document;w=window;t='';if(d.selection)t=d.selection.createRange().text;else{if(d.getSelection)t=d.getSelection();else{if(w.getSelection)t=w.getSelection()}}void(w.open('http://www.dansanderson.com/blog/mt/mt.cgi?__mode=view&_type=entry&blog_id=1&qp=1&title=&text='+encodeURIComponent('%3Ca%20href="'+d.location.href+'"%3E'+d.title+'%3C/a%3E\n\n'+t),'_blank','scrollbars=yes,status=yes,resizable=yes,location=yes'))

The following alternate version does the same thing, but also pre-populates the entry title with the title of the page. Again, remember to replace www.dansanderson.com/blog/mt/mt.cgi with the appropriate path for your blog:

javascript:d=document;w=window;t='';if(d.selection)t=d.selection.createRange().text;else{if(d.getSelection)t=d.getSelection();else{if(w.getSelection)t=w.getSelection()}}void(w.open('http://www.dansanderson.com/blog/mt/mt.cgi?__mode=view&_type=entry&blog_id=1&qp=1&title='+encodeURIComponent(d.title)+'&text='+encodeURIComponent('%3Ca%20href="'+d.location.href+'"%3E'+d.title+'%3C/a%3E\n\n'+t),'_blank','scrollbars=yes,status=yes,resizable=yes,location=yes'))

comments...

Thank you! The new but not improved MT4 bookmarklet is was a major pet peeve of mine. If I just wanted to paste the URL in plaintext, I wouldn't use a bookmarklet, I'd just copy and paste off my location bar...

Another mash note here for the restoration of that great function. The MT 4 version is useless.

post a comment...