#! /usr/local/bin/bash
#set -x
usage='usage: htmlify'
#
dirname=`pwd`
# /a/spelunke/export/vol1
dirname=`expr ${dirname} : '/a/spelunke/export/vol1/gaertner/\(.*\)'`
input="index.list"
output="index.html"
#

if [ $# -gt 0 ]
   then echo $usage >&2
	exit 1
   fi

umask 0
rm -f ${output}.tmp

echo "Outputting to ${output}.tmp" >&2

cat > ${output}.tmp << EOD

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
  <head>
    <title>Index file for directory "DIR" of Pretzel distribution</title>
  </head>

  <body>
    <h1>Index file for directory "DIR" of Pretzel distribution</h1>

	Files and directories are:<p>

EOD


awk 'BEGIN { FS="&" }
  { print "<a href=\"" $1 "\">" $1 "</a><ul>" $2" </ul>" }' ${input} >> ${output}.tmp

cat >> ${output}.tmp << EOD

    <hr>
    <address><a
    href="mailto:theedge@rbg.informatik.th-darmstadt.de">Felix
    Gaertner</a></address>
    <P>
      To <a
      href="http://www.iti.informatik.th-darmstadt.de/~gaertner/pretzel">Pretzel
 Homepage</a>.
      <P>
Last modified: LASTMOD
  </body>
</html>

EOD

echo "purging to " ${output} >&2

sed -e "s%DIR%${dirname}%" -e "s/LASTMOD/`date`/" ${output}.tmp > ${output}

rm ${output}.tmp

echo "done." >&2



