# The idea is to have a directory with GIF files in it and to
# getnerate all the related html files from that dir and this script.
# 
# Make these lists:
#	mklt 02 to $+1
#	mkrt 00 to $-1
#	mkfn 01 to $
#
#	tblt 02 to $+1
#	tbct 01 to $
#	tbrt 00 to $-1
#	tbfn 01 to $
#	 
#	leftlist 02 to $+1
#	cntrlist 01 to $
#	ritelist 00 to $-1
#	filelist 01 to $

## Make Lists:

/bin/rm -rf list mklt mkrt tblt tbrt tbct tbfn [0-9][0-9] 

ls -1 [0-9]*.gif | sed -e 's/.gif//' > list

set TAILN = `tail -1 list`

echo "00" > fntmp
cat list | grep -v $TAILN >> fntmp
cat fntmp | sed -e 's/$/.html/' > mkrt
/bin/rm -rf fntmp

cp mkrt tbrt

cat list | sed \
	-e '/01/d' \
	-e 's/$/.html/' \
		> mklt
echo "00.html" >> mklt

cp mklt tblt

cat list | sed -e 's/$/.html/' > mkfn
cp mkfn tbfn
cp mkfn tbct

## Make Files:

foreach f (`cat list`)

if (-e $f.html) /bin/rm -f $f.html

cat head > $f.html

cat tblhead >> $f.html

end

/bin/rm -rf tblz tblist

pr -m tblt tbct tbrt tbfn > tblist

cat tblist | sed \
	-e '/Page/d' \
	-e '/^$/d' \
	-e 's/		*/ /g' \
	-e 's/   */ /g' \
	-e 's/	 *//g' \
	-e 's/^/echo "<tr><td><img src=+/' \
	-e 's/html /gif+><\/td><td><img src=+/' \
	-e 's/html /gif+><\/td><td><img src=+/' \
	-e 's/html /gif+><\/td><\/tr>" >> /' \
> tblz

echo "csh tblz"
csh tblz

foreach f (`cat list`)
echo "</table>" >> $f.html
echo "<p><hr width=+75%+><p>" >> $f.html
end

/bin/rm -rf mklist mkarrows

pr -m mklt mkrt mkfn > mklist

cat mklist | sed \
	-e '/Page/d' \
	-e '/^$/d' \
	-e 's/		*/ /g' \
	-e 's/  */ /g' \
	-e 's/^/echo "<a href=+/' \
	-e 's/html /html+><img src=+arl.gif+>/' \
	-e 's/gif+>/&<\/a><a href=+/' \
	-e 's/html /html+><img src=+arr.gif+><\/a>" >> /' \
> mkarrows

echo "csh mkarrows"
csh mkarrows

foreach f (`cat list`)
mv $f.html tmp
cat tmp \
	| sed -e 's/+/"/g' \
	> $f.html
/bin/rm -f tmp
cat tail >> $f.html
end

exit(0)

