#!/bin/bash
#
# ./create_index *.jpg
#

echo "<!DOCTYPE html>" >index.jsp
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">" >>index.jsp
echo "<head></head>" >>index.jsp
echo "<body>" >>index.jsp
echo "  <h1><center>Pictures</center></h1>" >>index.jsp
echo ""

#
# Processing jpgs
#  <a href="DSCN2802.jpg"><img src="thumb.DSCN2802.jpg"></a>
#
rm thumb_*.jpg

FILES="$@"
for i in $FILES
do
	echo "Processing image $i ..."
	echo "  <a href=\"$i\"><img src=\"thumb_$i\"></a>" >>index.jsp
done

echo ""
echo "  <hr>" >>index.jsp
echo "  <hr>" >>index.jsp
echo "  <h1><center>Videos</center></h1>" >>index.jsp
echo "  <center>(Videos can take a minute to load)</center>" >>index.jsp

#
# Processing mp4s
#  <a href="DSCN2801.mp4">DSCN2801.mp4</a><br/>
#
FILES=*.mp4
for i in $FILES
do
	echo "Processing image $i ..."
	echo "  <a href=\"$i\">$i</a><br/>" >>index.jsp
done

echo "</body>" >>index.jsp
echo "</html>" >>index.jsp

#
# Create thumbnails
#
./create_thumbnails.ksh *.jpg

exit 0
