#!/bin/sh

#set -x

output="index.wml"

if [ -f "${output}" ]; then
	mv "${output}" "${output}_bak"
fi

cat >"${output}" <<EOF
<html>
<body bgcolor="#ffffff">
EOF

for i in $(ls -1a); do
	if [ -d "${i}" -a -f "${i}/index.html" -a "${i}" != "." ]; then
		echo "<a href=\"${i}/index.html\">${i}</a><br>" >>${output}
	fi
done

echo "<div align=\"center\">" >>"${output}"

for i in $(ls -1a); do
	if [ "x$(file ${i} | grep 'image data')" != "x" ]; then
		echo "<img align=\"center\" src=\"${i}\"><br>" >>${output}
	fi
done

cat >>"${output}" <<EOF
</div>
</body>
</html>
EOF

wml -o index.html ${output}

