#!/bin/bash
#
# gal
# Neil Gershenfeld 12/20/03
# script to make HTML galleries
#
ls *jpg > files
#ls *JPG >> files
echo "convert thumbnails:"
awk "{ print \"convert -resize 140x100 \"\$0 \" th_\"\$0 \"\necho  \" \$0}" files > conv
sh conv
rm conv
echo "convert screen images:"
awk "{ print \"convert -resize 1024x768 \"\$0 \" sc_\"\$0 \"\necho  \" \$0}" files > conv
sh conv
rm conv

awk "{ system(\"echo '<A href=index.html>index</A> ' > \" \$0 \".html\" ) }" files

echo '<A href=index.html>last</A> ' > last
awk "{ system(\"cat last >> \" \$0 \".html\"); system(\"echo '<A href=\" \$0 \".html>last</A> ' > last\") }" files

awk "{ line[NR] = \$0 } END { for (i = NR; i > 0; i--) print line[i] > \"revfiles\" }" files
echo '<A href=index.html>next</A><br>' > next
awk "{ system(\"cat next >> \" \$0 \".html\"); system(\"echo '<A href=\" \$0 \".html>next</A><br>' > next\") }" revfiles

awk "{ print \"<A href=\" \$0 \".html><img src=th_\"\$0 \"></A>\" }" files > index.html
awk "{ system(\"echo '<A href=\" \$0 \"><img src=sc_\" \$0 \"><br>\n\" \$0 \"</A>' >> \" \$0 \".html\" ) }" files

rm -f files revfiles last next