#!/usr/bin/ksh
OUT_DIR=./site/
if [ ! -d $OUT_DIR ];then
	mkdir ./site
else
	rm -rf ./site/*
fi

# First, take care of generic stuff
cp *css $OUT_DIR
cp robots.txt $OUT_DIR
cp -r ./junkcode $OUT_DIR

# Now generate the html pages from skeleton.html and the .body files
for fl in *body
do
	OUTFILE=$OUT_DIR/${fl%.body}.html
	if [ ${fl%.body} == "index" ];then
		PAGENAME="TITLE GOES HERE"
	else
		PAGENAME=`echo ${fl%.body} | cut -c1 | tr '[a-z]' '[A-Z]'``echo ${fl%.body} | cut -c2-`
	fi
	sed -n "s/##PAGENAME##/$PAGENAME/;1,/CONTENT GOES HERE/p"	skeleton.html | sed '$d' > $OUTFILE
	cat $fl >> $OUTFILE
	sed -n '/CONTENT GOES HERE/,$p'	skeleton.html | sed '1d' >> $OUTFILE
	tidy -i -f /dev/null $OUTFILE > $$
	mv $$ $OUTFILE
done