Arnt Richard Johansen's home page

Migrating from GreyMatter to Pyblosxom

The transition from GreyMatter to Pyblosxom was not entirely painless, though much easier than I had expected. CGI installation was a breeze (although it took me a while to figure out that even though the installation doc did not say anything about moving other files than pyblosxom.cgi and config.py into the CGI directory, Pyblosxom actually consists of a small suite of scripts whose path has to be specified in config.py.

Then came the whole business with URL rewriting. Having URLs like http://arj.nvg.org/pyblosxom.cgi/path/to/blog_entry.html looks ugly, and I'm not sure it is even compliant with the relevant URI standards to have pyblosxom.cgi as anything else than a directory in this case. So I wanted to redirect http://arj.nvg.org/path/to/blog_entry.txt to the pyblosxom script, but only if it does not exist as a regular file.

The solution I found (after reading up on mod_rewrite a while, and various swear words) was adding the following to my top level (but not sitewide) .htaccess:

RewriteEngine on

# If the requested file or directory does not exist
RewriteCond %{REQUEST_FILENAME} !-F
# Try serving it through Pyblosxom
RewriteRule ^(.*)$ /pyblosxom.cgi/$0 [L]

# Replace index.html with Pyblosxom
RewriteRule ^$ /pyblosxom.cgi [L]

Porting the visual layout was not very difficult, either. The "templates" in GreyMatter are quite similar to those in Pyblosxom, so I only had to retrieve them from the web interface and paste them together into Pyblosxom flavour files. Besides, most of the work was done in standalone CSS files anyway.

I opted not to write an import script, since I only had 8 entries in my old blog. Instead, I downloaded the source from the web interface, and inserted <p> and </p> where necessary. Non-Western text in Unicode was troubling, however. GreyMatter stores such characters in a puzzling internal format. After having given up typing the Russian word язык in on emacs, Yudit and KEdit, I pasted it from the web browser to Yudit.

[Tuesday, Dec 21, 2004 @ 17:34] | [] | # | G