Mohegan SkunkWorks

Sun, 19 Jul 2009 11:49:05 EST

CL-BLIKY : A simple lisp based blog engine

I 'm writing this using a self rolled blog engine called cl-bliky. I'm indebted to an excellent tutorial put together by Vetle Roeim. His goal was obviously to put together a compelling tutorial and he succeeded. My goal was to use lisp in a small programming project, and developing a simple and easily customizable blog engine seemed like a good start.

cl-bliky is build around a simple hunchentoot web server. Dynamically generated html is used to provide a gui interface to provide an upload and edit facility for posts as well as a facility for publishing posts to the remote repository. Elephant is used together with Berkeley DB to store the posts on the local disk.

The engine generates static pages from the posts stored in the database. These static pages are pushed a local git repository, which is then synced with a remote one hosted on github. Hosting is done through github pages. Each post has a title, an introduction and a body. I decided against some automated form of intro generation, because at the end of the day you"ll never be able to get it completely right. Leaving it in the hands of the writer seems more appropriate.

The engine recognizes two types of blog posts : regular posts, and side bar elements. Side bar elements are used for things like a list of code repositories or other short notices.

Posts can be written in html and markdown and I'm using cl-markdown to translate markdown to html.A 'feature' I added was to remove all line feed characters and to mark an empty line with an break which seems to be added by the web interface. This makes the encoding of 'hard' line breaks a little different from standardmarkdown. This is now a combination of less than three spaces at the end of a line plus an additional line break followed by less than three spaces.

Pushing the posts to the local or remote git repository is straight forward. I used sbcl's proprietary sb-ext to accomplish this. I haven't tried to use other lisp implementations.

Posts can be recreated from the git repo. I do this by sprinkling the html generated by bliky with various "<div id=.." tags. That allows me to identify the various pieces I need to recreate the underlying object. I use cl-html-parse to do this, followed by htmlgen to recreate the html in the posts.

There 's some loss in fidelity, since I don't translate the html back to markdown. Also, things delimited by brackets <& > are interpreted as tags by the cl-html-parse. The text can obviously be copied and pasted from the original post, so this shouldn't be too much of a problem.

The current implementation assumes that github pages are used for hosting. However, it should be relatively simple to add hosting through any other simple page server.