user.p0d.org

bits release in progress

Me, myself, and i

Main links to myselves:

Projects i'm involved with:


This blog engine

I'll try to describe my blog engine and what is so different from the others.

The main difference between this blog and most of the others is there is no dynamic page beside the contact and the search; yes, the content is static.

There are mainly two parts:

  1. the blog engine, generating static pages
  2. the blog daemon, serving dynamic pages

The blog engine is invoked from the command line, here is an example how to register a new article to the blog:

$ blog.py add www/article/my_article.rst

That's it!

A database back end is required to store the tags and provide searching functionalities. Actually it's SQLAlchemy (so you can use a relational database, from sqlite to Oracle), but i made a big hack to use key-values back end.

The "difficult" parts

The only problematic was to know which pages has to be (re)generated. Upon an addition, there are:

  • obviously the page you are adding / updating
  • the parents (previous and next) pages to link them together
  • the home page if the article you are adding is recent enough to fit there
  • the tag indexes, to register the article in the indexes
  • every single page if there is a tag addition (so the new tag can be shown in the tags list)

If you think the process is heavy, think about it; this only has to be done once (in a while), while a "standard" dynamic website has to generate the page for each request. And even if there is some caching, that usually require some processing.

If you have a lot of additions to make, you can delay the rebuilding while doing your bulk edits, then force a rebuild when you are ready.

Features
  • use the file system to store source (restructuredText) and html files; easy to backup or add versioning on your articles, etc.
  • use the file last modification time for dating the page (used in the Last-Modified HTTP header and the article last modification date)
  • a command line wrapper to edit a file without changing its modification time
Technology
  • Python as a scripting language
  • reStructuredText as the plain text markup syntax used for the billets
  • SQLAlchemy for the database abstraction
  • jinja2 for the templating and Pygments for the syntax highlight
  • flask over werkzeug for the dynamic part
  • virtualenv and pip to locally freeze or update the dependencies without impacting the system (not required to run the blog)

I just found about Octopress/Jekyll today (15 September 2012) which are a framework for generating static web content, they are better than my engine (but i'll stick with mine, na!) so if you want a good blog try them!