29 August 2009

Sending a Ping to PubSubHubbub from MarsEdit

MarsEdit is a handy Macintosh application that I use to compose entries for my website. Unfortunately, for reasons I don’t understand, when I publish a post with MarsEdit, none of Movable Type’s plug-ins seem to fire off. At present I use Multiblog to rebuilt my Debigulated URLs blog, which allows short URLs to work for all of my main blog’s entries, and I use MT-PubSubHubbub to ping Google’s PubSubHubbub hub when I post a new entry. If Multiblog doesn’t get triggered, the short URL I’m declaring in my page’s head won’t work because the .htaccess file at my link shortener hasn’t been rebuilt. If MT-PubSubHubbub doesn’t fire, the hub won’t get notified of a new post. I can work around the first problem using Bob the Rebuilder, and I’ve written up a sloppy AppleScript to deal with pinging the hub from MarsEdit.

I am absolutely certain that there’s a better way to do this, but here’s what I’ve got going for now. It works in testing using FriendFeed, which updates within seconds of a post that pings Google’s hub1. Here’s the script:

tell application "Safari" activate do JavaScript "window.open('http://david. ely.fm/davextreme/')" in document 1 end tell  delay 2  tell application "System Events" tell process "Safari" tell menu bar 1 tell menu bar item "Bookmarks" tell menu "Bookmarks" tell menu item "Bookmarklets" tell menu "Bookmarklets" click menu item "Publish to Hub" end tell end tell end tell end tell end tell end tell end tell  delay 2  tell application "Safari" to close the front window 

I placed the script in my MarsEdit scripts folder (found easily by going to MarsEdit’s Scripts menu and selecting “Open Scripts Folder”).

The script requires that you have:

  1. A “Bookmarklets” folder in your main Bookmarks menu in Safari; and
  2. Google’s “Publish to Hub” bookmarklet in that folder, which bookmarklet can be found on Google’s site near the bottom of the page2.

From there, I post an entry using MarsEdit, then select my “Ping Hub” script from the Scripts menu. It opens my webpage, waits two seconds for it to load, invokes the “Publish to Hub” bookmarklet, then closes the window.

My hope is that someone develops a plugin for MarsEdit that does this more elegantly, but maybe this will be helpful to people in the meantime. (Or someone can tell me why those plugins don’t activate when my xmlrpc updates go through.)

  1. The only use I have for FriendFeed being testing this push stuff. 
  2. Yes, I’ve been reading David Foster Wallace, so I use “which” in new ways and employ footnotes too often3. Hopefully it’ll wear off soon. 
  3. Also I go out of my way to point out that I’ve been reading DFW (and call him DFW).