#! /usr/local/bin/perl

# This script runs the $fixhtml script (pathname specified below)
#   to insert the standard Geometry Center header/footer info
#   into the .html files in the current directory.

# usage: fixhtml   (no args --- acts on all .html files in the current dir)

$fixhtml="/u/www/root/admin/fix/fix-html";
$fixhtmlcmd="$fixhtml -noURL -author 'Mark Phillips'";

if (! -x $fixhtml) {
    die "You don't seem to have the program $fixhtml on your
system, which is required in order to run this script (fixhtml).";
}

while (<*.class>) {
    s/\.class$//;
    $file = "$_.html";
    if (-f "$file") {
	&sys("$fixhtmlcmd -up 'source.html' -uptitle 'Java Kali Source Code and Documentation' $file");
	$f{"$file"} = 1;
    } else {
	print "WARNING: missing html file for class $class\n";
    }
}

&sys("$fixhtmlcmd -up '..' -uptitle 'JAVA Gallery of Interactive On-Line Geometry' welcome.html");
$f{"welcome.html"} = 1;

$files = "";
while (<*.html>) {
    $htmlfile = $_;
    if (! defined($f{$htmlfile})) {
	$files .= " " . $htmlfile;
    }
}
if ($files ne "") {
    &sys("$fixhtmlcmd -up 'welcome.html' -uptitle 'Java Kali Home Page' $files");
}


sub sys {
    local($cmd) = @_;
    print "$cmd\n";
    return system($cmd);
}

