#!/usr/bin/perl
############################################################################
#
# Generate the html table file from the *.xml files in the searches directory
#
# Monty Scroggins
#
############################################################################
## +++++++++++++++++++++++++++ Maintenance Log +++++++++++++++++++++++++++++
# Monty Scroggins Thu Sep 19 19:25:06 GMT 2002 Script created.
$|=1; # set output buffering to off
$[=0; # set array base to 0
$,=" "; # set output field separator
$\="\n"; # set output record separator
#path to the searches directory
my $searchdir="/usr/home/dqsd/public_html/searches";
#my $gendate=localtime(time());
#instead of printing out the stylesheet data, we could link to a standalone stylesheet.
#
#
#begin html
print "Content-type: text/html", "\n\n";
print q{
DQSD Searches
};
#get the list of xml files
opendir(searchdir, "$searchdir") or die "searchdir not found: $!";
@datafiles = grep /\.xml$/,readdir searchdir;
closedir searchdir;
#start the table
my (@html,@categories);
#generate a record for each xml file
foreach $datafile (@datafiles) {
next if ($datafile=~/^configure.xml/);
my ($name,$desctext,$category,$link)=();
my $filedata=read_file("$searchdir/$datafile");
for ($t=0; $t tags
if (@$filedata[$t]=~/*/i,"@$filedata[$t]"))[1];
}#if
#----------------------------------------------
#trigger if the line contains the tag
if (@$filedata[$t]=~/\/i) {
$desctext=(split(/<*\/*description>*/i,"@$filedata[$t]"))[1];
}else{
@$filedata[$t]=~s/\< *description *\>//i;
$advance=0;
until (@$filedata[$t+$advance]=~/\/description *>/i) {
$desctext.="@$filedata[$t+$advance]";
$advance++;
}#until
}#else
}#if
#----------------------------------------------
#trigger if the line contains the category tags
if (@$filedata[$t]=~/*/i,"@$filedata[$t]"))[1];
push(@categories,"$category");
}#if
#----------------------------------------------
#trigger if the line contains the link tags
if (@$filedata[$t]=~/*/i,"@$filedata[$t]"))[1];
$link="";
}#if
}#for
push(@html,"
\n");
}#foreach
#sort by the categories
@html=sort(@html);
#remove any duplicates from the categories list
@categories=grep(($Last eq $_ ? 0 : ($Last = $_, 1)),sort @categories);
#build the category link string to go above and below the table
$categorylink="";
for ($t=0; $t<=scalar(@categories); $t++) {
next if ($categories[$t]=~/^ *$/);
$categorylink .="\n$categories[$t]";
}
print "
DQSD Searches
";
print scalar(@html)." Total $categorylink";
print "
\n
Category
File
Name
Description
";
for ($t=1; $t<=scalar(@html); $t++) {
print "\n
\n
$t
\n$html[$t-1]";
}
#end html
print qq{
$categorylink
};
#slurp in a file and return the data array
sub read_file {
my($file) = @_;
open(INF, "<$file") or return();
my(@data) = ;
close(INF);
chomp @data;
return(\@data);
}#sub