Nav links

Sunday, 15 June 2008

Introducing the blog dog

If you glance to the top right of this page you can see the newest member of the Chaucery team, the blog dog. She has many years of good standing in the community, and a nose for a good story. Although not old enough to browse the internet unsupervised, I like to imagine that she hops on the computer when I'm out to peruse this blog. Of course, that's a conceit on my part, as all her friends know she only reads the quality broadsheets.

Spit'n'polish


My animal assistant comes as part of a new design for the blog, a highly-tweaked version of the Unity Purple style from the MovableType style library. The tweaks were tested on-the-fly using the essential Firebug Firefox extension. Firefox users will see a slightly nicer result, because I've used the "-moz-border-radius" CSS shortcut in various places to produce rounded edges (rather than the tedious browser-independent method of creating lots of tiny images). Apparently, a similar feature will appear in css3, and I look forward to changing to that when it becomes widespread.

Template trauma


Although the MoveableType developers take great pains to ensure that new versions of their blogging software are backwardly compatible, such that my ancient MT 3 templates still work perfectly well in the latest MT4.2, I wanted to switch to their new modular templating system to take advantage of its ease of use and new features. This should be as simple as choosing to "Refresh blog templates", which backs up your old templates and adds the new ones. In my case this caused two problems.


Firstly, it created duplicate system templates (eg. the search results template). These templates are so essential that they cannot normally be created or deleted. As a result, MT (and I) got very confused about having duplicates around. When I worked out which template was actually being used I found it MT wouldn't let me update it, with the complaint that a template of that name already existed. Luckily, I'm not averse to delving deeper, so I opened up the SQLite database holding my blog data, and found the templates in question in the mt_template table. I then changed the template_type of my old templates, such as from "comment_preview" to "comment_preview_old". It looks like MT uses template_type to find the system templates, so renaming them effectively hides them. This did the trick.

Secondly, the duplicate archive templates looked quite manageable, but weren't. I deactivated my old ones and set the new ones to be published statically. However, this confused the Publish Site popup, which no longer offered me the option of publishing anything other than indexes. I resolved this by copying the content of the new templates into my old templates, reactivating my old ones, and deleting the new ones.

Despite these problems, I was always sure of a quick resolution, because I knew that if I got really stuck I could always have a look at the Perl code to see what was really going on. That's one of the wonders of Open Source.

Where's the SQLite love?


Although MT4.2 supports SQLite 2 and 3, amongst other database options, they do not support dynamic publishing from an SQLite 3 database. This is odd, because SQLite 3, released in 2004, is faster and smaller than SQLite 2, and ideally suitable for dynamically publishing lightly-trafficked sites like this one. As I've mentioned previously, it only takes a few lines of code to hack this support in manually.

Tagging Along


Tags have been given a more prominent role in the new Chaucery design. The home page now houses a lovely tag cloud (where word size represents how often that tag is used), which I hope will encourage more casual browsing. I previously used categories exclusively, but through my experience with labels in Gmail I'm leaning towards tags nowadays.

As part of my move to use tags I've had to go back over my previous entries to add tags. I couldn't find an easy way within MT to list entries without tags, so I used the following at the command-line to interrogate the database directly:
sqlite3 MyDatabase.db 'select entry_title from mt_entry left join mt_objecttag on objecttag_object_id = entry_id where objecttag_tag_id is null'

In selecting entries to tag I also found MT's regular expression search useful. For example, to find entries to tag as 'breakfast' you might want to look for all that contain either "pepsi" or "lollypop". To do this do an advanced search with the Regex Match box ticked, and search for (pepsi|lollypop). I found that a great time-saver.

From a technical perspective, when a user clicks on a tag MT does a dynamic search for relevant pages using its built-in search facility, even when you've asked for your site to be statically published. For example, clicking charts goes to http://blog.chaucery.com/cgi/mt-search.cgi?blog_id=1&tag=charts&limit=20.Categories, on the other hand, are statically built, so clicking on a category goes directly to an existing html page for that category, eg. http://blog.chaucery.com/archives/language/. If you have a slow server then you might find categories noticeably faster and less stressful on your server. Interestingly, by default clicking on a tag in the tag cloud runs some javascript to do the tag search. I'm not sure why a direct hyperlink is not used.

Speakeasy


Commenting should be easier for everybody, as identification is now open to people using OpenID, LiveJournal, Vox and TypeKey. Previously this was a TypeKey-only establishment.

The final word


Woof.