This Fozzolog now Template-Toolkit powered

| No Comments | No TrackBacks

I just migrated all the Fozzolog mod_perl code to use Template Toolkit instead of CGI::FastTemplate.

To do this, I had to rewrite all the template files dealing with Fozzolog pages. There are seven of those. Because the Template Toolkit syntax supports more logic than CGI::FastTemplate, I moved as much of the presentation logic as I could out of the mod_perl content handler into the template files.

I believe the move to Template Toolkit makes the Fozzolog code more portable, easier to maintain, and easier to understand.

It’s fairly trivial now for me to fire up another journal site based on Fozzolog code. All I need to do is set up a <Location> section in the Apache configuration file with some Perl variables.

<Location /journal>
  PerlSetVar Fozzolog_DSN dbi:Pg:dbname=joealog
  PerlSetVar Fozzolog_Path /journal
  PerlSetVar Fozzolog_TemplateDir /www/joejoejoe.com/templates
  PerlSetVar Fozzolog_Site www.joejoejoe.com
  PerlSetVar Fozzolog_DateFormat "%a %d %b, %Y at %H:%M"
  SetHandler perl-script
  PerlHandler FGM::FozzologHandler
</Location>

The PerlSetVar directives provide all the key data needed. Any other customization can be done in the template files.

For the insanely bored, here’s a snippet of a template file:

<table width="100%" border="1" cellpadding="5" cellspacing="0">
  <tr>
   <td class="highlight">
    <table width="100%">
     <tr>
      <td align="left">
       <div class="journalhead">
        Date: [% manip.UnixDate(jentry.dt_posted, date_format) %]<br/>
        Topic: <strong>[% jentry.topic_name %]</strong><br/>
        Headline: <strong>[% jentry.headline %]</strong>
       </div>
      </td>
     </tr>
    </table>
    [% jentry.body %]
    <div class="commentsummary"> 
      [% IF jentry.comment_count == 0 %]
        No comments
      [% ELSIF jentry.comment_count == 1 %]
        <a href="[% fozzolog_path %]/SC[% jentry.jentry_id %]">
	  1 comment</a>
      [% ELSE %]
        <a href="[% fozzolog_path %]/SC[% jentry.jentry_id %]">
	   [% jentry.comment_count %] comments</a>
      [% END %]
      |
      <a href="[% fozzolog_path %]/PC/[% jentry.jentry_id %]">
        Add a comment</a>
    </div>
   </td>
  </tr>
 </table>

No TrackBacks

TrackBack URL: http://fozzolog.fozzilinymoo.org/mt-tb.cgi/1053

Leave a comment

About this Entry

This page contains a single entry by Doran L. Barton published on March 8, 2004 2:55 AM.

My Terpstra encounter was the previous entry in this blog.

All this spam is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.