2012-03-04 12:39:12 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Build the website. The common items and the web items are assumed
|
2014-06-17 09:11:38 +01:00
|
|
|
# to be already built. This generates the MusicXML and the page HTML
|
|
|
|
# and shuffles other files ino the right place.
|
2012-03-04 12:39:12 +00:00
|
|
|
#
|
|
|
|
|
2013-04-02 09:47:20 +01:00
|
|
|
#set -x
|
2013-02-23 13:10:58 +00:00
|
|
|
|
2013-02-22 01:09:37 +00:00
|
|
|
if [ $# -lt 2 -o $# -gt 3 ]; then
|
|
|
|
echo "Usage: makeWeb.sh <book dir name> <master book dir name> [<instrument name>]"
|
2012-03-04 12:39:12 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
dir=`pwd`
|
|
|
|
|
2014-06-30 10:01:51 +01:00
|
|
|
booke=$1
|
|
|
|
masterbooke=$2
|
2013-02-17 00:27:07 +00:00
|
|
|
bookedir=$dir/$1
|
2014-06-30 10:01:51 +01:00
|
|
|
masterbookedir=$dir/$2
|
2012-03-04 12:39:12 +00:00
|
|
|
webdir=$dir/web/$1
|
|
|
|
graphicsdir=$dir/graphics/$1
|
|
|
|
output=index.html
|
2013-08-21 10:32:50 +01:00
|
|
|
tunelist=tunelist.html
|
2013-02-22 01:09:37 +00:00
|
|
|
title=$booke
|
|
|
|
instrument=$3
|
2014-06-17 09:11:38 +01:00
|
|
|
abc2xml=$dir/abc2xml/abc2xml.py
|
2012-03-04 12:39:12 +00:00
|
|
|
|
|
|
|
buildno=`cat buildno.txt`
|
2013-07-08 14:57:15 +01:00
|
|
|
# Remove trailing % added for Latex purposes.
|
|
|
|
buildno=${buildno%%%}
|
2012-03-04 12:39:12 +00:00
|
|
|
subtitle=
|
|
|
|
intro=
|
2013-02-17 00:27:07 +00:00
|
|
|
if [ -r $bookedir/subtitle.txt ]; then
|
|
|
|
subtitle=`cat $bookedir/subtitle.txt`
|
2012-03-04 12:39:12 +00:00
|
|
|
fi
|
2013-02-17 00:27:07 +00:00
|
|
|
|
2013-02-22 01:09:37 +00:00
|
|
|
if [ -n "$instrument" ]; then
|
|
|
|
title="${title} ($instrument)"
|
|
|
|
subtitle="${subtitle} ($instrument)"
|
2012-03-04 12:39:12 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p $webdir
|
|
|
|
|
|
|
|
sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \
|
2013-08-21 10:32:50 +01:00
|
|
|
-e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" dottes.html > $webdir/$output
|
|
|
|
|
|
|
|
for item in intro
|
|
|
|
do
|
|
|
|
rm -f $webdir/$item.html
|
2016-10-29 21:51:59 +01:00
|
|
|
if [ -r $booke/$item.md ]; then
|
|
|
|
pandoc --from=markdown --to=html --output=$webdir/$item.html $booke/$item.md
|
2013-08-21 10:32:50 +01:00
|
|
|
else
|
|
|
|
touch $webdir/$item.html
|
|
|
|
fi
|
|
|
|
done
|
2012-03-04 12:39:12 +00:00
|
|
|
|
2013-02-17 00:27:07 +00:00
|
|
|
# Copy in the book PDFs. Like the graphics, Midi etc. these are assumed
|
|
|
|
# to be already generated.
|
2013-02-17 00:39:59 +00:00
|
|
|
cp $1-*.pdf $webdir
|
2012-03-04 13:07:50 +00:00
|
|
|
|
2013-08-30 23:55:22 +01:00
|
|
|
# Now, for each tune, make the tune page.
|
2013-09-02 11:48:16 +01:00
|
|
|
rm -f $webdir/$tunelist
|
2013-02-17 00:27:07 +00:00
|
|
|
find $bookedir -name "*.abc" | sort |
|
2012-03-04 12:39:12 +00:00
|
|
|
while read filename
|
|
|
|
do
|
|
|
|
name=`basename $filename .abc`
|
|
|
|
|
2013-07-17 18:28:07 +01:00
|
|
|
# Copy the ABC into the web.
|
2012-03-04 12:39:12 +00:00
|
|
|
cp $filename $webdir
|
|
|
|
|
2014-06-17 09:11:38 +01:00
|
|
|
# Generate MusicXML into the web.
|
|
|
|
python $abc2xml $filename > ${webdir}/${name}.xml
|
|
|
|
|
2013-09-02 11:48:16 +01:00
|
|
|
# If we are not the master booke, link the mp3s in from the
|
2013-08-30 23:55:22 +01:00
|
|
|
# master page in a desperate attempt to make IE8 work.
|
2013-08-30 23:59:41 +01:00
|
|
|
# The Jenkins archive will dereference the soft link, it seems,
|
|
|
|
# but I guess I can live with copies of the MP3 for now.
|
2013-08-30 23:55:22 +01:00
|
|
|
if [ "$booke" != "$masterbooke" ]; then
|
2013-08-31 00:38:45 +01:00
|
|
|
pushd ${webdir} > /dev/null
|
2013-09-02 12:34:58 +01:00
|
|
|
ln -f -s ../${masterbooke}/*${name}.mp3 .
|
2013-08-31 00:38:45 +01:00
|
|
|
popd > /dev/null
|
2013-08-30 23:55:22 +01:00
|
|
|
fi
|
|
|
|
|
2016-11-02 00:21:18 +00:00
|
|
|
# Get date and time of last change to tune.
|
|
|
|
lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc`
|
|
|
|
|
2013-02-17 00:27:07 +00:00
|
|
|
# Generate the tune web page.
|
|
|
|
tunepage=${name}.html
|
2013-09-02 11:48:16 +01:00
|
|
|
learnerpage=learner-${name}.html
|
2013-02-17 00:27:07 +00:00
|
|
|
|
2016-11-02 00:21:18 +00:00
|
|
|
$dir/abctemplate.py --value "masterbooke=${masterbooke}" --value "lastchanged=${lastchanged}" --template dottes.html.tune $filename > $webdir/$tunepage
|
|
|
|
$dir/abctemplate.py --value "masterbooke=${masterbooke}" --value "lastchanged=${lastchanged}" --template dottes.html.learnertune $filename > $webdir/$learnerpage
|
|
|
|
$dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist
|
2012-03-04 12:39:12 +00:00
|
|
|
done
|