#!/bin/sh 
# Zim.genweb.sh
#
# generate static web pages from Fedora.notes Zim notebook

PROJ=Technical
INDEX=Start
#INDEX=index
SRC=/home/harker/${PROJ}
DEST=/home/harker/${PROJ}/HTML
#DEST=/var/www/html/${PROJ}

# basenames of files to protect
PRFXPROTECT="Start"

cd $SRC

# show git status
git status

# commit and outstanding changes
#git commit

# push our changes to the master
#git push origin

# pull current version from the master
#git pull origin master

# generate a new Start.txt file
mv -f Start.txt Start.old
cat > Start.txt << EOF
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4

====== Zim Wiki Index for Robert Harker $PROJ ======

EOF

ls *.txt | sed -e 's/.txt$//' | awk '{print "[[" $1 "]]"}' >> Start.txt

# clean out the $DEST dir of old files
rm -f ${DEST}/*.html
# use zim to generate new .html files
# if you get an error about the display,
#  try "ssh -Y" to give zim a display to chew on, bug
zim --export --format=html --index-page=$INDEX \
  --template=${SRC}/templates/zim-harker-tmplt.html \
  --root-url=http://harker.com/${PROJ}/ \
  --output=$DEST $SRC

# Lock down files not for public web consumption
#chmod 640 ${DEST}/Start.*

# Copy non-html files I want to publish
for FILE in Readme.zim bin/Zim.genweb.sh templates/zim-harker-tmplt.html
do
  cp -rf $FILE ${DEST}/${FILE}
done


/usr/bin/rsync -av --del \
  --exclude=Save \
  --exclude=SSN \
  $DEST/ harker.com:/var/www/html/$PROJ

