Object Commando languages, development and design


Blogging with org2blog

It's been a while since I've blogged! I'm hoping to blog more this year than I did last year. One improvement I'm making to my blog process is org2blog mode. I spend a lot of my day in Emacs and so it's pretty typical that I write notes and at least a portion of blog posts in Emacs, often all of it. org-mode for Emacs is easy to use library for marking up plain text. I had been using it to write blog posts for sometime, however I would typically export from org-mode to HTML, then paste it into WordPress's editor. This was time consuming (though still easier than writing the whole entry in the WordPress editor). As a result, fewer blog posts made the transition from org-mode to WordPress. This process is now very stream-lined thanks to org2blog.

Setting up org2blog

The first snag I hit setting up org2blog was an outdated version of org-mode. Although the project page doesn't specify a version (just saying the latest) I found that it needs definitely newer than version 6.34. If you're using the version shipped with emacs, you will probably need to upgrade (23.1 which is what I'm using came with 6.21). When I tried to use org2blog to post a new draft of this blog post with that old version of org-mode, I received an error that it could execute the org-find-exact-headline-in-buffer function. It looks like that function didn't exist in the older copies of org-mode. I pulled from the org-mode git repo and followed these instructions to set up the new version.

To push up new blog entries to WordPress, org2blog uses the elisp xml-rpc library. This is easy to install if you have ELPA (if you don't have ELPA, follow these instructions). With the proper version of org and xml-rpc, org2blog is ready to be installed. I pulled down the org2blog source code (from git://github.com/punchagan/org2blog.git) and added the below elisp to my Emacs startup:

(setq load-path (cons "~/path/to/org2blog/" load-path))

(require 'org2blog)

(setq org2blog/wp-blog-alist
       :url "http://blog.address.com"
       :username "Blog User Name"
       :default-title ""
       :default-categories ("Some Category")
       :tags-as-categories nil)))

You can eval the above code or restart Emacs. To make sure it's working you can try M-x org2blog/wp-login to see if it can connect to your blog.

Using org2blog

org2blog mode has several interactive functions for blogging. To create a new entry use M-x org2blog/wp-new-entry. This creates a new (unsaved) buffer that has org-mode markup already in it to indicate category, blog title, date, etc. After adding content and setting a title etc, running M-x org2blog/wp-post-buffer will upload the contents of the buffer as a new draft (not yet publishing it), to the blog you specify. The blog matches blog-name that you configured in your org2blog setup. After transporting the blog post, it then asks you if you'd like to open the draft in a browser. I like this feature a lot, it makes it easy for me to verify that the markup converts properly (until I get more confidence in it) and assures me that it's still in draft mode (making sure an entry doesn't get published prematurely).

Something I found unexpected is that when it creates the post, your local copy is still live. When creating the entry it fputs identifier information in the heading along with the title. So you can post a draft, make a few changes and post that same draft again, and it will update that existing entry (not create a new entry).

Below are some useful functions that can be invoked via M-x (or bound to a key)

Function Description
org2blog/wp-new-entry Creates a new blank blog entry with the headers added
org2blog/wp-post-buffer Posts the buffer as a draft to the WordPress instance
org2blog/wp-preview-buffer-post Opens a tab in a browser to preview the blog post
org2blog/wp-post-buffer-and-publish Publishes a draft


Moving On

Yesterday I accepted a position at Revelytix. I'll be starting in March. They're a tech company that is working on Sematic Web technologies. I'm looking forward to the cutting edge technologies and digging into the Semantic web. I'll be working with Alex Miller and a few others as we start on development of a new product. Expect some posts on the Semantic Web, Clojure and Scala!

Filed under: Misc 1 Comment

Back on the Air

I've not had a post for quite a while now. Graduate school picked back up in August and things ramped up at work pushing to make a deadline. These things didn't leave much time for writing! I graduated in December and things have calmed down a bit at work so I'm looking forward to doing some more writing. More to come in 2010!

Filed under: Misc No Comments