I’ve been trying out MarsEdit and I like it. I prefer its posting interface to MoveableType’s web interface. However, I still like to compose my entries in BBEdit and save a local copy on my hard drive.
This is doable using MarsEdit’s “Edit with BBEdit” command, but it’s a little cumbersome; the best solution I came up with was editing the post in BBEdit, “saving” the text back to MarsEdit, then pasting the text from MarsEdit into a new BBEdit document.
Like I said, cumbersome.
My solution was to write an AppleScript that would create a new MarsEdit post from the frontmost BBEdit window.
on run tell application "BBEdit" try set active_doc to active document of text window 1 set doc_title to (name of active_doc) -- check to see if the file's been saved -- if not, check if the document has a custom name. if (active_doc is not on disk) then if (doc_title starts with "untitled text") then set doc_title to "" end if end if on error beep return end try end tell my CreateNewPost((text of active_doc), doc_title) end run on CreateNewPost(post_text, post_title) tell application "MarsEdit" set post_window to make new post window tell post_window set the body to post_text set the title to post_title end tell end tell activate end CreateNewPost
The body of the new posting comes from the text of the BBEdit window and the title comes from the name of the document. If the document doesn’t exist on disk, the script checks to see if the document has a customized name.
The check for a customized name is a little simplistic — it checks if the document name starts with “untitled text.” I couldn’t really think of anything better to try, but I’m open to suggestions.
If I were really industrious, I’d create a script that used the External Weblog Editor Interface so it would work with multiple editors. However, I’m lazy and I just wanted something that would work for my situation.
This has been tested under BBEdit 8.0. I don’t know if it’ll work as written for older versions. If it doesn’t, it should only take minor modifications to fix any issues or make it work with TextWrangler.