Results tagged “templatingsystems” from Appleseed Blog

Though I wrote the first entry two days ago, I didn't link the blog into the site until just now. Setting it up proved to be a slightly more interesting task than I had bargained for.

The blog runs on Movable Type, my favorite blogging software. (It currently plays second banana to Wordpress in the global blog-infrastructure popularity contest, but it's one hundred percent Perl, and therefore I'm much more comfortable with bending it into the shape I need.) Usually, an MT site runs as an entirely self-contained creature, using its very own templating toolkit and CSS-based styling system to define its look and functionality. However, I wanted it to look exactly like the rest of my site, which uses the Mason templating system, as well as perfectly good CSS that I already had lying around.

I decided to solve this problem by having Movable Type output Mason's templating tags as needed, so that the pages it created would pull from the same HTML and CSS files that the rest of the site uses. Most of the pages on a Movable Type site are static files constructed from templates, so it wasn't difficult to customize these templates to output Mason tags. This is how, for example, the blog's own sidebar content appears as part of the usual appleseed-sc.com sidebar on the right, underneath Appleseed's contact information. That's pretty neat. This page on the Mason HQ wiki provided some good advice.

However, in two spots visible to the blog's end-users - writing comments, and searching on tag names - MT runs CGI scripts to produce on-the-fly page content. Figuring out how to work that into my Mason templates was quite a chore, and took the better part of a day. But in doing so, I ended up learning a great deal about Movable Type, Mason, and Perl's API into Apache 2. The short answer is that instead of calling the CGI script directly, the site makes a separate HTTP request to it, captures the output, runs it through the Mason interpreter, and then presents that to you. It must also quietly pass Cookie and Set-cookie headers around as needed, so that features like the comment form's info-remembering checkbox work correctly.

It was a sufficiently interesting and illuminating task that I allowed myself to keep slogging at it until it was done, even though it was entirely unbillable labor. But (with coaching from my friend and fellow expert Andy Turner) it's done now. Back to work!

(Minor note: to my chagrin, Movable Type's comment form uses different name and id attributes, which is technically not valid XHTML, and causes more persnickety validation programs to tut-tut at me. It's currently the only bugaboo on my otherwise whistle-clean website. I'll get around to finding a fix for it later.)

0