#! /usr/bin/perl
#
# This script makes an HTML page which lists all of the VRML pages in this
# directory.  For each file, it tries to find a description in the file
# vrmls.txt

$output_file="vrmls.html";
$description_file="vrmls.txt";
$prefix="http://www.commercialventvac.com/~jeffs/";

open DF, "<".$description_file || die "unable to open the description file $description_file for reading\n";

while( <DF> ) {
  ($file,$description) = split /\|/i, $_, 2;
  $description_table{$file} = $description;
  print "File is $file, description is $description \n";
};

close DF || die "unable to close the description file $description_file for reading\n";

my @wrl_files = glob("*.wrl");

open OF, ">".$output_file || die "unable to open the output file $output_file for writing\n";
print OF<<EOF;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<head>
<meta name="generator" content="$0">
<meta name="author" content="Jeff Silverman">
<title>Jeff Silverman's VRML files</title>
</head>
<body>
<script type="javascript">document.writeln("This document last modified "+document.lastModified);</script>
<H1>The VRML files</H1>

<H2>The links</h2>

<H2>The list</h2>
EOF

foreach $file (@wrl_files) {
  print $file."\n";
  if ( exists($description_table{$file}) ) {
    print OF '<A href="'.$prefix.$file.'">'.$description_table{$file}."</A>.<br>\n";
  }
  else {
    print OF '<A href="'.$prefix.$file.'">'.$file."</A>.<br>\n";
  };
}
print OF<<EOF;
<hr>
Return to <A href="$prefix">Jeff's home page</A>.<br>
The W3C <A href="http://validator.w3.org/">HTML validation </A> service.
<p>
    <a href="http://validator.w3.org/check/referer"><img border=0
        src="http://www.w3.org/Icons/valid-html401"
        alt="Valid HTML 4.01!" height=31 width=88></a>
  </p>
</body>
</html>
EOF
close OF || die "unable to close the output file $output_file\n";

