29.03.2009 23:01

Publishing with NB and Emacs

Picking an engine to publish my writings I wanted something extremely simple. First thing that implies is no SQL. I wanted an engine written in Python and pyblosxom was interesting but in the end I went with NanoBlogger. NB is a blog engine written in Bash that uses standard UNIX utils like sed and grep to create static HTML content. How to write and publish the content is left as an exercise to the user.

NB can automatically generate templates on new entries or articles, but it's not perfect when it comes to GNU Emacs. I wanted at least the correct mode to be started. So I wrote nbpost.sh, it creates a new entry, inserts a template and starts the correct mode. It also recognizes when I'm editing an existing entry, and can start Emacs if it's not already running. As for the mode, html-mode is OK, but I found post-mode to fit perfectly. It was written for mutt and editing e-mails but it has other uses too.

Once written and HTML generated, an article needs to be published to the web server. Doing this manually would be tedious so I wrote nbsync.py. It uses rsync for publishing content over SSH. Rsync will transfer only changes between files, it uses compression and ssh provides encryption... very simple yet very effective.

With that in place I still wanted better integration of NB in my environment. I use ZSH which has great completion and a web search brought me to completion functions written in 2006, a little outdated but very good. I updated them and published _nb here. It completes all the commands as well as categories and entries.

I now have a complete solution for publishing from Emacs. Which also brings its related benefits; syntax highlighting, spell checking, well known key bindings and automatic publishing of content. Not to mention that org-mode found it's use too. I keep a journal.org file outlining all my entries and categories, related TODO tasks and ideas for future articles.


Written by anrxc | Permalink | Filed under main, code, emacs