Virtual Spring Cleaning (part 7 of X) Wherein I Enter the Archives

Originally written for providing installable themes for my photo publishing app, App-imagestream, I wrote two modules that make it very easy to provide a basic theme for a web application in an archive. This still allows for quick customization by overlaying the contents of the archive with the contents of another archive or a directory in the file system.

The basic idea is that if you have your templates in

basic_theme.zip
  \- index.tt
   - theme.css

You can override for example theme.css by overlaying the archive using a directory

custom_theme/
  - theme.css

This will still read all files that do not exist below customtheme from basictheme.zip. All the code has to do is to read the list of archives and directories from the configuration file.

The other half of the equation is the (still unreleased) Template::Provider::ArchiveTar, which expects an Archive object that has an API like Archive::Tar. This is not the greatest API but it has the things I need for read-only access to an archive. Using that, you can INCLUDE and PROCESS template blocks from the archive files to your hearts content.

Using Archive::Merged, it would also be fairly simple to whip up a Dancer application that serves files from an archive but replaces key resources from a directory if the user places them there.

Of course I never really used the ability to create themes. The application has the most basic theme and one theme which has a somewhat more responsive photo gallery. This second theme is the theme I use for the gallery on my website.

Leave a comment

About Max Maischein

user-pic I'm the Treasurer for the Frankfurt Perlmongers e.V. . I have organized Perl events including 9 German Perl Workshops and one YAPC::Europe.