#!/bin/sh

for DIR in $(find ./gh-pages -type d); do
  (
    echo "<html>\n<body>\n<h1>EME Schemas</h1>\n<hr/>\n<pre>"
    ls -1pa "${DIR}" | egrep "(../|json)" | grep -v "^\./$" | grep -v "index.html" | awk '{ printf "<a href=\"%s\">%s</a>\n",$1,$1 }'
    echo "</pre>\n</body>\n</html>"
  ) > "${DIR}/index.html"
done

git add -A
git commit -m "Updated gh-pages directory listing"
git push -f origin

git subtree split --prefix gh-pages/ -b gh-pages
git push -f origin gh-pages:gh-pages
git branch -D gh-pages
