5

Friday, 4th July 2008 17:53

Catnip Mouse - Scripts for Web Page Generation



Open Office.org

Decoration Decoration  
  Decoration
Decoration
   

The story so far...

Welcome to Catnip Mouse. This project has grown from the need to 'scratch an itch', like many before it. In this case the specific 'itch' was the need to produce the code for this web site, Catnip Corner. In the old days when this site took shape (circa late 1996) the output of many authoring tools was a very nonedescript form of html, full of nonstandard tags and lots of upper case. More recently the decision was taken to upgrade the site to XHTML, but no tool was available for the task. This gave rise to the first Catnip Mouse script, a very rough Perl hack being mostly a long list of regular expressions to convert tags to lower case, quote attributes and fill in the header fields. This was rather specific to 'fixing' my previous html coding style, so it was never made generally available.

The second flavour of Catnip Mouse was a slightly different animal which was produced partly as an excuse to fiddle with Perl and partly to assist in roughing out XHTML pages. By setting up a few things in a resources file and answering a few questions in an interactive script, an XHTML page could be quickly produced. However, this was not overdeveloped either, as it was generally just as easy to produce a new page by hacking a previously produced one.

As you may have gathered, Catnip Corner is an exhibition of my photography, in a series of pages each featuring several photographs. The question is - 'What is the optimum number of pages to include on each page?'. The more photos, the longer the download time, the more pages, the more difficult the site maintenance. I eventually tried using php to produce a slide show presentation which has the advantage of quickly downloading each image and preloading the next, whilst simplifying site maintenance and the generation of new pages. This script is now in use on my L'Essonne and The Somerset Levels pages.

The script mentioned above was (and is) perfectly functional - it has been operating since mid - 2002, but I never published it as the coding was a bit scrappy, and the tool to automatically produce it never materialised. In mid 2005 I needed a script to display a series of pictures as a sequence of pages with a variable number of pictures per page - see this page. At this point I managed to do some of the tidying that I had been intending to do for so long, and the list of pictures was moved out into a separate php include file and the code structure improved. Finally, things went a full circle when this code was modified to produce a minimalist slide show script.

I am now making generic copies of these scripts and they will be listed in the download section when they become available.

Aims of the Project

The primary aim of this project is to produce a set of scripts to assist in web page generation for slide shows and gallery pages. There will also be a utility to rapidly produce a web page slide show by editing the configuration file. The page will have the following components generated from a rudimentary database file:

  • Title or Title Logo
  • One or more photographs with descriptions
  • Navigation Controls
  • Advertising
  • Generic Information eg copyright and links

The tool to configure the page will be written in Perl, and will modify a PHP script that contains a rudimentary database (in the form of a PHP array declaration) defining a sequence of pictures. The database script and a further script for generating the content will both be included in a skeleton script, that has the name of the page to be generated. Cascading Style Sheets will be used to the extent permitted by the client browser, but the emphasis will be on clean code that validates with the W3C.

Other scripts that may be generally useful will also be listed in the download section.

Downloads

All downloads are licenced under the GNU GPL version 2 or later.

If you use one of these scripts, and have no generator meta tag set in your headers, please consider adding the following line to your headers,

<meta name="generator" content="Catnip Mouse [GNU / Linux]" />

replacing '[GNU / Linux]' with the operating system used by your web server.

count.php

This script is a simple page hit counter that returns a string representation of a number that increments each time the script is called. Several simpler implementations were tried before this script was arrived at; they would mostly perform correctly for a month or so then reset or corrupt. This script has been stress tested with four tight loops each calling the script concurrently - with no ill effects. The script requires a lockfile and two register files to work; make sure these exist in the same directory as the called script and are readable and writeable by the web server process.

Download count.php.txt 20051202 v00.01.00

csscompress.php

This file is nothing to do with the slide show system. It enables a css file to be delivered with gzip compression turned on, on servers where it is not possible or desired to turn on global compression. It also generates an Etag and last-modified header, and sends a 304 response in reply to appropriate If-Modified-Since and If-None-Match headers.

Download csscompress.php.txt 20060407 v00.01.00

od.php

This file is nothing to do with the slide show system. It provides a function that takes the name of an OpenDocument file as input, and returns a text string which is a hyperlink to that OpenDocument file. The function examines the metadata of the OpenDocument file and uses the document title field to generate the link text, and the creator and date fields to generate a file properties string, which is added to the hyperlink 'title' attribute. In the majority of web browsers this information will be displayed as a 'tooltip' when the cursor is placed over the link.

Download od.php.txt 20051103 v00.01.00

Demonstration Page

odfdetect.txt

This file is nothing to do with the slide show system. It is a fragment of JavaScript that can be placed on a web page to indicate if the viewing browser has a plugin to view OpenDocument mime types of the form "application/vnd.oasis.opendocument.XXX" It depends on the navigator.mimeTypes object being present, so works on the Gecko family of browsers but results on other types are unknown.

Download odfdetect.txt 20051103 v00.01.00

Demonstration Page

 

 

 

 

 

 

 

 

Email Pete Harlow
Home Page
Copyright © 2002 - 2006 Pete Harlow All Rights Reserved
http://www.catnip.co.uk/projects/mouse/
Advertisment - Powered by Apache Web Server

Valid XHTML 1.0! Valid CSS! Powered by PHP! Get Firefox 2! Get OpenOffice.org! Powered by Apache!