<!--#include virtual="/ssi/cvs_version.pl" -->
I also have it configured so that all webpage can use server side includes commands by putting this into my apache httpd.conf file.
<Directory "/usr/local/apache_gnujobs/htdocs"> Options All Indexes FollowSymLinks MultiViews ExecCGI Includes AllowOverride All Order allow,deny Allow from all </Directory> AddType text/html .shtml AddHandler server-parsed .shtml .html .htm .shtm
Here is a text version of the perl script, or you can also copy and paste it from this document below.
#!/usr/bin/perl print "Content-type: text/html\n\n\n\n"; ### Get the name of the file being requested. my $Temp = $ENV{'REQUEST_URI'}; my $Cvs = $Temp; ### Split the url by "/". my (@Junk) = split(/\//, $Cvs); ### Get the end of the url, which is the filename. my $File = pop @Junk; $Cvs =~ s/[^\/]+$//g; ### Attach the document root directory so we get the complete path to the ### file on our computer server. Also, attach the CVS/Entries name so that ### we get the CVS information. $Cvs = $ENV{'DOCUMENT_ROOT'} . $Cvs . "CVS/Entries"; ### Open the file, and if we find a match, record it to $Match my $Match = ""; open(FILE,$Cvs); while (my $Line = <FILE>) { if ($Line =~ /$File/) {$Match = $Line; chomp $Line} } close FILE; ### If match is not found, print not found, otherwise get the information. if ($Match eq "") {print "No CVS information found. '$File'\n";} else { ### Get the information we want and print it out. my ($Junk,$File,$Version,$Date,@Junk) = split(/\//, $Match); print "Version <b>$Version</b> : Date Last Changed <b>$Date</b>\n"; }
<Files ~ "CVS$"> Order allow,deny Deny from all </Files> <Files ~ "Root$"> Order allow,deny Deny from all </Files> <Files ~ "Repository$"> Order allow,deny Deny from all </Files> <Files ~ "Entries$"> Order allow,deny Deny from all </Files>
Some silly things to do:
Lars Kellogg-Stedman mentions that there are simpler ways to include revision information in your documentation using CVS options
I've just recently been glancing over your Linuz Gazette article, and I can't help but think that you've gone to a lot of trouble -- and wasted CPU cycles -- to do something that's relatively simple. CVS, based on RCS, supports certain keywords that can be placed in your documents that get automatically expanded when a document is checked out or comittted. Of particular interest, given the content of your article, are the follow two tags: (1) $Revision: 1.5 $ (2) $Date: 2001/03/15 17:21:01 $ For example, if I was to create a document that looked like this: This is a test document. Article version: $Revision: 1.5 $ Date: $Date: 2001/03/15 17:21:01 $ And this article was under control of CVS, then when after a checkin the document might actually look something like this: This is a test document. Article version: $Revision: 1.5 $ Date: $Date: 2001/03/15 17:21:01 $ This contains almost exactly the information you want. It may not allow the same control over appearance that your solution does -- but it doesn't involve running a script *every time* the page is loaded. You can find a list of these rcs tags in the 'co' man page, and I assume they're also in the CVS documentation.
Mark works as an independent consultant donating time to causes like GNUJobs.com, writing articles, writing free software, and working as a volunteer at eastmont.net.
Copyright © 1/2001 Mark Nielsen
Article