#/bin/bash

#set -x

for i in 200* ; do
  cd $i ; 
  ln -fs ../FOOTER.html . ; 
  ln -fs ../HEADER.html . ; 
  cd - ; 
done

cat <<EOF > .htaccess
IndexOptions +SuppressHTMLPreamble 
IndexOptions +FancyIndexing
IndexOptions +HTMLTable
IndexOptions +SuppressColumnsorting 
ReadmeName FOOTER.html 
IndexIgnore FOOTER.html HEADER.html indexes.sh
EOF

for f in *.svg ; do
  echo "AddDescription \"&nbsp;&nbsp;&nbsp;&nbsp;<a href=\\\"http://www.mancoosi.org/measures/autozoom/autozoom.svg?file=/measures/dominators/$f\\\">explore</a>\" $f" >> .htaccess
done

#chmod g+rw FOOTER.html HEADER.html .htaccess

for d in 200* ; do
  cd $d ;
  echo "Building indexes"
  rm .htaccess
  for f in *.svg ; do
    echo "AddDescription \"&nbsp;&nbsp;&nbsp;&nbsp;<a href=\\\"http://www.mancoosi.org/measures/autozoom/autozoom.svg?file=/measures/dominators/$d/$f\\\">explore</a>\" $f" >> .htaccess
  done
#  chmod g+rw FOOTER.html HEADER.html .htaccess
  cd -
done
