Laatste reacties
Archief
Quote of the Day
Ninety-Ninety Rule of Project Schedules:
The first ninety percent of the task takes ninety percent of the time, and the last ten percent takes the other ninety percent.

whatsnew.pl

(Current version: 1.2, November 2004)

Download here

Change history

Version 1.2, November 2004:

  • added ability to include files on other web servers;

Version 1.1, April 2004:

  • added ability to scan directories for changed or created subdirectories;

Version 1.0, September 2002:

  • initial release;

Introduction

Whatsnew.pl is a simple PERL script that will check the modification time of a selection of pages in a site and list the most recently changed sorted on the date of the most recent changes. It does not simply traverse directories finding each and every file that may be there for testing or whatever, but you tell it what files to look for, and what URL’s they belong to. Thus you may have one entry for a number of pages, in order not to clutter your list with a lot of individual files all belonging together. The most recently changed file defines the date attached to the entry.

Whatsnew.pl is distributed under the GPL. Specifically this means that you may redistribute it, change it to your liking etc. If you make modifications that make it more usable for other people, please let me know.

Prerequisites

Whatsnew needs the LWP::Simple package. This is part of most PERL installations on web servers.

Installation

Download the file.

Untar the distribution file and put the following files into your cgi-bin directory:

  • whatsnew.pl (the script itself)
  • whatsnew-config.pl (guess :-) , see below)
  • whatsnew.db (files to check, see below)

The whatsnew.db file may be put in another directory if you prefer, or even give it an entirely different name. This change will need to be reflected in the whatsnew-config.pl file however.

You will need to make the script files executable

>chmod +x whatsnew*.pl

The script will probably run on any platform as there’s not much fancy stuff in there, but I only tested it on Linux.

Configuration

The configuration is found in two files: whatsnew-config.pl holds the general configuration and defines the general behaviour of the script, whatsnew.db defines what files to check for their dates.

whatsnew-config.pl

The following variables are define in whatsnew-config.pl:

$BASEDIR
Top directory on your site from which to reference the files checked. Remember that the script runs in your server so this may need to hold the complete path, even though you never see it from the web.
$BASEURL
Base  path to reference in the <A HREF> tags. May be the URL of your site, but a simple “/” may suffice.
$TARGETFRAME
In a frame bases site: frame in which to display the found pages if their links are clicked in the list.
$DB
Name of the file that holds the definition of files to be checked.
$TZCORR
Our site is targeted at the Netherlands although it actually runs in the USA, or anyway, it is in that timezone:-). This will lead to illogical times on the files (we seem to work at the strangest times of day:-). This variable is used to correct this, so times will show up as the time it was in the Netherlands when the files were changed.
$HOWMANY
Number of entries to show.
$PT
Page Title
$CSS
Cascading Style Sheet to use for formatting the results page.
$PH
Page Header. Any HTML content you want to display on your page above the table of recent changes.
$PF
Page Footer. Any HTML content you want to display on your page below the table of recent changes.
$THD
Table Header for the Description column.
$THM
Table Header for the Date column.

whatsnew.db

The file list defines which entries can show up in the results page, what page they will link to and what files the date of the entry will depend on.

Comment lines

lines beginning with ‘#’ or empty lines are comment lines

File entries

Each entry is defined by one line in this file. Each line is formatted as:

<Description>|<URL>|<file 1>|<file2>|....|<file n>
  • The <Description> is the text that will show up in the results page.
  • The <URL> is the URL that this description links to
  • The remaining entries are files that define the date that is attached to this entry. The date will be the date for the file that was most recently changed.
Directory entries

As of version 1.1, you can also scan a directory on your site for changed/created subdirectories. This will typically be used when you add new projects/stories/galleries/etc. into one or more directories, each new addition in its own subdirectory. This ability was added to let the entries under the ‘Evenementen’ directory of our school site appear automagically in the whatsnew-list (I can’t seem to educate the other people who manage the site to enter their projects in the whatsnew.db:-).

To have a directory scanned, simply add a line to the whatsnew.db. The line is formatted as:

!DIR!|<directory>
  • The !DIR! is a literal and needs to be in all caps.
  • The <directory> is any directory you want to use, but it needs to be under the $BASEDIR.

NOTE: directories specified by the !DIR!-lines are scanned for subdirectories only, i.e. regular files in this directory will not be evaluated, nor will subdirectories at lower levels (it does NOT work recursively).

URL entries

As of version 1.2 it is possible to refer to files on other servers than the server the script is running on. Whatsnew will use the LWP::Simple package to get information on external links.

An entry referring to external links is formatted as:

!URL!|<description>|<URL>|<URL file1>|<URL file2>|...|<URL filen>|
  • The !URL! is a literal and needs to be in all caps.
  • The <description> is what you want to show up in the resulting page.
  • <URL> is a directory on the external server. It must be possible to refer to the URL by this directory name (without the trailing slash), i.e. the directory must hold a default file (index.html, default.htm, etc.).
  • The <URL file.> entries represent file in said directory. When getting the info from the other servers, these filenames are concatenated to the directory names, and the resulting date will be that of the most recent of the files in the directory.

NOTE: Do not use large numbers of files on an external server, as there is a severe performance penalty on accessing external files.

Leave a Reply