# Blosxom 3 Plugin: StaticTemplate # Version: 2004-12-10 # Author: Bernie Simon use strict; package Blosxom::Plugin::StaticTemplate; #---------------------------------------------------------------------- # Configurable variables # Location of the HtmlBlocks module use lib '../lib'; # Static template file use constant TEMPLATE_FILE => 'template.htm'; #---------------------------------------------------------------------- use FileHandle; use HtmlBlocks; sub run { my $self = shift; # Shamelessly stolen from render_output. Props to Rael my $content = $self->{response}->{head}->{rendered}; foreach ( @{$self->{response}->{entries}} ) { $self->{state}->{current_entry} = $self->{entries}->{$_}; $content .= $self->render_date(); $content .= $self->{entries}->{$_}->{rendered}; } $content .= $self->{response}->{foot}->{rendered}; # Call HtmlBlocks to wrap content generated by Blosxom if ($self->{request}->{flavour} eq 'html') { my $fd = FileHandle->new (TEMPLATE_FILE); if (defined $fd) { my $template = join ('', <$fd>); my $html = HtmlBlocks::extract ($content); $content = HtmlBlocks::substitute ($template, $html); } } print $content; return 1; } 1; __END__ =head1 NAME Blosxom 3.0 Plugin: StaticTemplate =head1 SYNOPSIS Inserts Blosxom content into template =head1 VERSION 2004-12-10 =head1 DESCRIPTION StaticTemplate is a Blosxom 3 plugin designed to keep a consistent appearance between all pages on a web site, both static and those generated by Blosxom. It uses a template file that contains the common html code used by all pages on the site. Code that changes from page to page is wrapped in comments of the form: where name is any identifier string. When the plugin executes, it looks for comment blocks in the Blosxom output and uses them to replace the block of the same name in the template. The result is that the output consists of the contents of the template outside the named blocks and the content generated by Blosxom inside the named blocks. This plugin is part of a set of scripts to keep a web site synchronized with a template. If you use it, you probably also want to use followme.pl, also available for download from my web site. =head1 INSTALLATION First, place this file in the plugins directory. Then install the Perl module HtmlBlocks.pm, which can be downloaded from my web site. Edit the use lib line at the top of the file to point to the directory containing HtmlBlocks.pm. Create a template file the contains the look of your web site with comment block that wrap the portions of the design that will change from page to page. Edit the html flavour files to include matching comments. Finally, edit the handlers.flow file by replacing Blosxom::output_response with Blosxom::Plugin::StaticTemplate::run. =head1 BUGS Because the version of Blosxom 3 that is currently being distributed ignores the handlers.flow file, you need to first install a patch to Blosxom 3 to fix this problem, such as the one distributed on my site. =head1 AUTHOR Bernie Simon (http://carelesshand.net) =head1 LICENSE Copyright Bernard Simon, 2005. You may use this file as you wish as long as this copyright notice is maintained.