#! /bin/bash

SCRIPTDIR=`dirname $0`
ADVENEHOME=`dirname $SCRIPTDIR`
output=${ADVENEHOME}/share/web/user.html
shortcuts=${ADVENEHOME}/share/web/shortcuts.html

if [ ! -d "${ADVENEHOME}/doc" ]
then
  echo "Unable to find the Advene directory"
  exit 1
fi

# Shortcuts
wget --quiet 'http://liris.cnrs.fr/advene/wiki/index.php/AdveneShortcuts' -O $shortcuts

if [ $? == 0 ]
then
    perl -pi -e 's/<(style|link|script).+?<\/\1>//; s/<span class=.editsection.+?<\/span>//; s/<div id=.jump-to-nav.+?<\/div>//; s/.+siteSub.+//; s!<head>!<head><link rel="stylesheet" type="text/css"  href="http://liris.cnrs.fr/advene/advene.css" />!; exit(0) if /Retrieved/' $shortcuts
	echo "Shortcuts help updated in $shortcuts"
else
	echo "Wget error. $shortcuts is now corrupted."
fi


