#!/bin/sh

# list the newest html files in the tree

# License: LGPLv2

exclude_re='(\.git/|xvpics|priv/|tmp/|timeline\.html|modified\.html|head\.html|footer\.html|footer-home\.html|adds\.html|last\.html|header.html|menu.html|left-blank.html|.htaccess)' #don't show these paths

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head><title>sitemap/timeline</title>
<META NAME="generator" CONTENT="gen_timeline (a bash script)">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--#include virtual="/head.html"-->
<style type="text/css">
table.align td {
    padding: 0px;
    border: 0px;
}
</style>
</head>
<body>
        <div id="content">
                <div class="contentText">'

echo '<pre>
<table class="pixelbeat">
<tr class="pbtitle"><td align="center"><b>By Date</b></td><td align="center"><b>By Name</b></td></tr>
<tr>
<td><table class="align">'
find $1 -type f -printf "%P\t%T@\n" |
sort -k2,2nr |
cut -f1 |
#files starting with . | files without a . | files ending in .c .cpp ...
grep -E "(^|/)[.].+|(^|/)[^.]+$|[.](c|cpp|py|sh|rc|tips|fortune|html)$" |
grep -Ev "$exclude_re" |
while read file; do
    time=`date --reference="$file" "+%b %e %Y"`
    file=`echo "$file" | sed 's/\(.*\)\/index.html/\1\//'`
    echo "<tr><td>$time </td><td><a href=\"$file\">$file</a></td></tr>"
done
echo '</table></td>
<td><table class="align">'
find $1 -type f -printf "%P\n" |
sed 's#\(.*/.*\)#¬\1#' | #setup to group paths in sort
LANG=C sort |
tr -d ¬ |
#files starting with . | files without a . | files ending in .c .cpp ...
grep -E "(^|/)[.].+|(^|/)[^.]+$|[.](c|cpp|py|sh|rc|tips|fortune|html)$" |
grep -Ev "$exclude_re" |
sed 's/\(.*\)\/index.html/\1\//' |
while read file; do
    echo "<tr><td><a href=\"$file\">$file</a></td></tr>"
done
echo '</table></td>
</tr>'
echo '</table>'
echo '</pre>'
echo '<br>'
echo 'This sitemap/timeline was generated by <a href="scripts/gen_timeline">gen_timeline</a>'

echo '</div>
</div>

<div id="sidebar">
<!--#include virtual="/header.html"-->

<!--#include virtual="/footer.html"-->
</div>
</body>
</html>'