Templates that create templates...
... or why flexibilty is good sometimes.
After some dabbling with Lurker, I decided it's just too much trouble for the prototype site and went looking for alternative mailing list archivers.
I found few, and decided to try MHonArc.
Then I tried to make it fit the rest of the site. Ouch.
It's not that MHonArc doesn't provide a way to customize the generated HTML. It provides one.
A terribly convoluted one where instead of writing a template for MHonArc to fill it has its template and it's filled from the data and from a resource file you write.
For example, I expected writing a template like this (stupid example):
<h1> my archives </h1> ${toolbar} ${contents}
So that MHonArc would put a toolbar and the contents where I tell it to.
In reality, MHonArc has a hardcoded template like this:
IDXPGSSMARKUP IDXPGBEGIN LISTBEGIN (AUTHORBEGIN | DAYBEGIN | SUBJECTBEGIN)? LITEMPLATE+ (AUTHOREND | DAYEND | SUBJECTEND)? LISTEND DOC? IDXPGEND
And you tell it what IDXPGEND should be, or it uses its default value. And there is one of these things, with similar but different variables, for each kind of page it generates.
So, you can customize your layout by putting things like this in a resource file:
<IdxPgEnd> $MY-FOOTER-LINK$ </body> </html> </IdxPgEnd>
Which is doable. But you end with static pages. How can you make that work well with a modern site without duplicating the whole base layout? Not to mention all the niceties like having your username in the toolbar and whatever.
Generate page templates instead.
I customized the MHonArc layout to generate neat Mako templates that inherit the "real" base layout template.
I only had to be careful to escape the $ signs as $$ if I wanted them to survive until Mako saw them.
Then create a view that processes the templates instead of serving the static files and it works like a charm.
A simple, but neat hacklet, I think.