#!/bin/sh

echo '<TITLE>The TeX System</TITLE>'
echo '<H1>The TeX System</H1>'

for i in *; do
	if [ $i = help ]; then
		echo "<h2>$i</h2>"
		echo '<ul>'
		for j in $i/*; do
			echo "<li><a href=$j>`basename $j`</a>"
		done
		echo '</ul>'
		continue
	fi
	if [ -d $i ]; then
		echo "<h2>$i</h2>"
		echo '<ul>'
		for j in $i/*.html $i/*.html.gz $i/*.dvi $i/*.ps $i/*.tex $i/*.dvi.gz $i/*.ps.gz $i/*.tex.gz; do
			test -f $j && echo "<li><a href=$j>`basename $j`</a>"
		done
		for j in $i/*; do
			test -d $j || continue
			test -f `echo $j/*.html | sed 's/ .*//'` ||
			test -f `echo $j/*.html.gz | sed 's/ .*//'` ||
			test -f `echo $j/*.ps.gz | sed 's/ .*//'` ||
			test -f `echo $j/*.dvi.gz | sed 's/ .*//'` ||
			test -f `echo $j/*.dvi | sed 's/ .*//'` ||
			test -f `echo $j/*.ps | sed 's/ .*//'` || continue
			echo '<li>'`basename $j`
			echo '<ul>'
			for k in $i/*.html $i/*.html.gz $j/*.dvi $j/*.ps $j/*.tex $j/*.dvi.gz $j/*.ps.gz $j/*.tex.gz; do
				test -f $k || continue
				echo "<li><a href=$k>`basename $k`</a>"
			done
			echo '</ul>'
		done
		echo '</ul>'
	fi
done
