Bye bye Zine, hello Blogofile!

January 24, 2010 | categories: Blog, Python, Programming | View Comments

So only two posts have passed since I switched my blogging engine from PyBlosxom to Zine. Yesterday I moved again: From Zine to Blogofile. (This is turning into a blog about blogging software.)

What was wrong with Zine?

  • Zine brought my server to a halt a couple times before I realized that it was the large amount of (correctly marked) spam comments that made it use loads of resources. Deactivating comments fixed the problem. (Still, I really wanted them.)
  • The comments moderation screen couldn't cope with 100s of spam comments.

Yes, I could have looked into it and fixed it. I didn't like the idea though. First off, I'm debugging enough web apps in my daily work, and it's not what I want to do in my spare time. Secondly, debugging an application's memory consumption is not exactly something you do in one evening, at least not without prior knowledge of the codebase.

So I had my comments deactivated for a while, which sucked. And then came along Blogofile. Which is really similar to my former blog engine PyBlosxom in that your content lives on the filesystem, in plain text files, instead of being buried inside a database.

That means you can edit your content offline using your favourite text editor, build and push it to the server once it's done, instead of having to mess around with copy and paste and HTML text areas.

Other things I like about Blogofile so far:

  • Templating is very easy. I was able to apply my homepage's style in a matter of minutes.
  • All rendering is done once, offline. Then it's only static files on the server, no web app!

Just like with Zine though, using Pygments turned out not to work out of the box together with reStructuredText. (It does work fine with Markdown.)

Fortunately, Mike Bayer already did the work for me. All I had to make was some little tweaks. Supposedly this has to do with recent changes in Blogofile.

Update: Mike updated his Blogofile Hacks to work with the most recent Blogofile 0.7. All you should need to do is follow his instructions, and disregard the following ones.

First, I had to add this to my _config.py:

blog.post_default_filters = {
    "rst": "rst, syntax_highlight"
}

(Note how Mike is using blog_post_default_filters, with an underscore between blog and post.)

Then I changed his syntax_highlight.py slightly:

@@ -4,6 +4,11 @@
 from pygments import util, formatters, lexers, highlight
 import blogofile_bf as bf

+config = {
+    'syntax_highlight_style': 'murphy',
+    }
+
 css_files_written = set()

 code_block_re = re.compile(
@@ -39,8 +44,7 @@
 from mako.filters import html_entities_unescape

 def run(src):
-
-    style = bf.config.syntax_highlight_style
+    style = bf.config.filters.syntax_highlight.syntax_highlight_style
     css_class = "pygments_"+style
     formatter = formatters.HtmlFormatter(
             linenos=False, cssclass=css_class, style=style)

Read and Post Comments

New Blog Software

March 15, 2009 | categories: Python, Blog, Programming | View Comments

Update: I just switched from Zine to using Blogofile. That is, I'm using another new blog software now. o_O

I have a new blog now. This one's running Zine. I'm redirecting the old RSS and Atom feeds to Zine's Atom feed. I hope that this doesn't blow up someone's RSS reader. I decided not to import the posts from the old Atom feed (which Zine allows you to), because I'd lose comments. That's why the old blog will just stay online for the time being.

So update your bookmarks and readers and whatnot!

I decided to switch from my old blog running PyBlosxom for a couple of reasons:

  • I'm trying something new
  • PyBlosxom doesn't do tags (or: more than one category)
  • It doesn't do threaded comments
  • PyBlosxom's code is somewhat messy

Now what I really like about PyBlosxom though is its ability to render your blog from a bunch of files on the filesystem. You have a couple of folders, which represent your categories, and a couple of text files in those; your blog posts. Zine uses a technology called SQL database instead (wink), which is alienating in comparison.

The second thing I like about PyBlosxom is that those text files can use the reStructuredText format, which is my favourite markup language. Zine doesn't do this out of the box. There's this rst plugin floating around, but it didn't really work for me. And so I decided that instead of debugging this obscure reST-0.2.plugin file, and to warm up to Zine, I'd write a little reStructuredText plug-in myself.

You can get the plug-in here. If you have trouble like me to install it through Zine's admin interface, try restarting your Zine after installation. Here's the code for those who like code:

import docutils.core
from zine.i18n import _
from zine.parsers import BaseParser
from zine.utils.zeml import parse_html

class RSTParser(BaseParser):
    """A reStructured Text parser."""

    name = _(u'reStructured Text')
    settings = dict(file_insertion_enabled=0,
                    raw_enabled=0,
                    output_encoding='unicode',
                    input_encoding='unicode',
                    initial_header_level=4)

    def parse(self, input_data, reason):
        parts = docutils.core.publish_parts(
            input_data, writer_name='html',
            settings_overrides=self.settings)
        return parse_html(parts['html_body'])

def setup(app, plugin):
    app.add_parser('restructuredtext', RSTParser)

(The clever programmers see that it's still lacking support for Pygments.)

Update: There is Pygments support now, and I've changed the link to point to the updated version.

You can see that it's easy enough to extend Zine with a plug-in like this. (There's only a metadata file that you also need to put into your module.) But, I'm somewhat irritated that Zine's not using setuptools eggs and entry points for distribution and installation. Zine seems to have a general aversion to setuptools; to install Zine itself, one is advised to ./configure && make install.

More comments can be found at the original blog post.

Read and Post Comments