#!/usr/local/bin/perl
require "ctime.pl";
$intab= "data.txt";
$file_dir = '/usr/local/docs/utexas/tsha/handbook/online';
$cite_file_dir = 'http://www.tsha.utexas.edu/handbook/online/articles/view';
$ID= $ENV{'PATH_INFO'};
$ID=~ s/\/handbook\/online\///;
$full_path = $file_dir . $ID;
$view_full_path = $cite_file_dir . $ID;
$head_replace = "
";
open (ARTICLE, $full_path);
print "Content-type: text/html\n\n";
while () {
# chop($_);
# chop changed to chomp by E Hahn 12/10/2001
chomp($_);
if ($_ =~ $head_replace) {
open (HEAD, "print-head.html");
@head = ;
close HEAD;
print "@head\n";
print "return to handbook view
\n";
} elsif ($_ =~ $foot_replace) {
&cite;
open (FOOT, "print-foot.html");
while () {
$_ =~ s//$cite_url/;
print "$_\n";
}
close FOOT;
} elsif ($_ =~ "") {
next;
} else {
print "$_\n";
}
}
close (ARTICLE);
sub cite {
$accessdate = (January,February,March,April,May,June,July,August,September,October,November,December)[(localtime)[4]] . " " . (localtime)[3] . ", " . ((localtime)[5] + 1900);
&gencite;
print "
\n";
print "\n";
print "- The following, adapted from the Chicago Manual of Style, 15th edition, is the preferred citation for this article.\n";
print "\n";
print "
\n";
print " - \n";
print <Handbook of Texas Online, s.v. "$TITLE,"
EOF
print "$full_path<\/a> (accessed $accessdate).\n";
print "
";
print "(NOTE: \"s.v.\" stands for sub verbo, \"under the word.\")";
print "
\n";
};
sub gencite {
$ID=~ s/\/handbook\/online\///;
($junk,$junk,$NUMBER) = split(/\//,$ID);
($NUMBER, $junk) = split(/\./,$NUMBER);
$NUMBER = uc($NUMBER);
open(TSF, "$intab") || die "Can't Open $intab $!";
while() {
chop($_);
($ti,$id,$au) = split(/\t/);
$id =~ s/0(\d)/\1/;
if ($id eq $NUMBER) {
$TITLE = $ti;
$TITLE =~ s/\.//;
next;
}
}
$full_path = $cite_file_dir . $ID;
$tempdate= &ctime(time);
}