:
# htmlpiclist - generate a HTML list of pictures
# Author:	Heiner Steven (heiner.steven@odn.de) 1/97
# Category:	HTML

if [ $# -lt 1 ]
then
    set -- `pwd`
else
    # Resolve relative directory names to absolute names
    Dirs=
    for Dir
    do
	[ -d "$Dir" ] || continue
	case "$Dir" in
	    /*)	Dirs="$Dirs $Dir";;
	    *)	Dirs="$Dirs `cd $Dir >/dev/null 2>&1 && pwd`";;
	esac
    done
    set -- $Dirs
fi

# Print HTML header
cat <<-!
	<HTML>
	<HEAD><TITLE>Pictures in $1</TITLE></HEAD>
	<BODY>
	!

# Print all GIF and JPG images
find "$@" \( -name '*.gif' -o -name '*.jpg' -o -name '*.jpeg' \
	-o -name '*.xbm' -o -name '*.xpm' -o -name  '*.png' \) -print |
	nawk '
	    {
		#print "<P>" $0 ":<BR>"
		#print "<IMG SRC=file:" $0 ">"<BR>"
		base = $0
		gsub (/.*\//, "", base)
		#print $0
		print base
		print "<IMG SRC=\"file:" $0 "\" ALIGN=MIDDLE>&nbsp;"
		# Uncomment the next line to generate links to
		# the pictures instead of including the pictures
		# themselves
		#print "<A HREF=\"file:" $0 "\">" $0 "</A><BR>"
	    }
	'

# Print HTML footer
cat <<-!
	</BODY>
	</HTML>
	!
