#!/bin/bash

function generate_html
{
LC_ALL=nl_NL
##
# Generate structure
##
echo "<html>
	<head>
		<title> Index of /</title>
		<style type='text/css'>
body {
width: 60%;
}
a {
display: table-cell;

float: left;
}
#type {
float: left;
display:table-cell;
width: 10em;
float: left;
display:table-cell;
			}
#moddate {
float: right;
display:table-cell;
}

#entry {
display:table;
width: 100%;
border-bottom: 1px gray solid;
}
		</style>
	</head>
	<body>
	";


##
# Title
##
echo "
		<H2>Index of /</H2>
		<HL/>
" ;

for a in `ls -t`; do
	if [ $a != "index.html" ]; then
		TYPE=$(file -ib $a)
		TYPE=${TYPE%%;*}
		MODDATE=$(stat -c %y $a)
		MODDATE=${MODDATE%%:[0-9][0-9]\.[0-9+- ]*}
		echo "
		      <div id=\"entry\">
			<div id='type'>$TYPE</div>
			<a href=\"$a\">$a</a> 
			<div id='moddate'>$MODDATE</div>
		      </div>
		";
	fi
done

##
# Generate closing structure
##
echo "	</body>
</html>" ;
}

generate_html

