#!/bin/bash

dst_dir=../../web/ext/tabletop-dl

echo ""
echo "****"
echo "Rsyncing extension files to: $dst_dir"
echo "****"
echo ""

dst_dir=../../web/ext/tabletop-dl

if [ ! -d $dst_dir ] ; then
    echo "Making directory $dst_dir"
    mkdir $dst_dir
fi

rsync -pav \
      interactjs-dist \
      winbox-interact.js  \
      tabletop*.*  \
      backgrounds  \
      $dst_dir/.

rsync -pav \
      src/winbox-with-interactjs/dist/ $dst_dir/winbox-with-interactjs-dist


rsync -pav tabletop.xsl ../../web/interfaces/default/transform/pages/tabletop.xsl

num_lines=`fgrep tabletop.xsl ../../web/interfaces/default/interfaceConfig.xml | wc -l`

if [ $num_lines != "1" ] ; then
    echo ""
    echo "****"
    echo "To use Tabletop-DL in Greenstone3 in the default interface,"
    echo "ensure the following file:"
    echo ""
    echo "    ../../web/interfaces/default/interfaceConfig.xml"
    echo ""
    echo "has a child entry of:"
    echo ""
    echo '    <action class="PageAction" name="p">'
    echo ""
    echo "includes the line:"
    echo ""
    echo '      <subaction name="tabletop" xslt="pages/tabletop.xsl"/>'
    echo "Now restart your Greenstone3 server, and in your browser visit the URL:"
    echo ""
    echo "      http://localhost:8383/greenstone3/library?a=p&sa=tabletop"
    echo "****"
    echo ""
fi
    

