#!/usr/bin/perl # # dkr # # Eugene Eric Kim # http://www.eekim.com/software/purple/ # # $Id: dkr,v 1.2 2001/04/09 22:11:09 eekim Exp $ # # Copyright (c) Eugene Eric Kim 2000-2001. All rights reserved. # See COPYING for licensing terms. =head1 NAME dkr - Displays different versions of documents. =head1 SYNOPSIS http://someurl.com/cgi-bin/dkr?fn=/some/file.html http://someurl.com/cgi-bin/dkr?fn=/some/file.html&v=2.3 =head1 DESCRIPTION Loads specified version of a file. If the version is not specified, loads the latest version of the file. =head1 MANAGING FILES In order to use dkr, you need to configure your file system properly. Specify your root HTML directory in $HTML_ROOT below. In order to add version 1.0 of $HTML_ROOT/some/file.html: 1. mkdir $HTML_ROOT/some/file.html 2. Save the file in $HTML_ROOT/some/file.html/1.0 3. ln -s $HTML_ROOT/some/file.html/1.0 $HTML_ROOT/some/file.html/latest =cut use CGI; my $VERSION = '0.1'; ### configuration variables my $HTML_ROOT = '/home/eekim/devel/ohsdkr/docs'; ### main my $q = new CGI; if ($q->param) { $file = $q->param('v'); if (!$file) { $file = 'latest'; } open(FH, $HTML_ROOT . '/' . $q->param('fn') . '/' . $file) or &error; print $q->header; while () { print; } close(FH); } else { &error; } # fini ### subroutines sub error { print $q->header, $q->start_html('Error'), $q->h1('Error'), $q->end_html; exit; } =head1 TO DO =head2 Checkin utility Write a utility that automatically adds new versions of a file to the system. =head2 More robust error handling Return more useful error messages. =head2 Smarter version handling If no such version exists, return the version that's closest. =head2 Handle XML natively Parse XML files, automatically update the registry, and convert the XML file to HTML, adding HTML controls to the header and/or footer for controlling the dkr script (such as showing all available versions). =head1 AUTHOR Eugene Eric Kim =cut