#!/bin/bash

POSTS=`find ./posts -mindepth 1 -type d | sort -r`
INDEX_TOC=`pwd`/toc.inc


rm -f $INDEX_TOC
for I in $POSTS; do
  (
    echo $I;
    cd $I;
    TITLE=`cat article.html | grep '<title>' | sed 's!^[[:space:]]*<title>\(.*\)</title>!\1!'`
    DATE=`cat article.html | grep '<meta name="date"' | sed 's!^[[:space:]]*<meta name="date" content="\(.*\)"/>!\1!'`
    PATH=`echo $I | sed 's!^\./!!'`
    echo "<li><a href=\"$PATH/article.html\">$DATE - $TITLE</a></li>" >> $INDEX_TOC
  )
done

cat index.header toc.inc index.footer > index.html


rsync -av --delete --exclude-from excludes.lst . /var/www/html

