2012-03-04 12:39:12 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Build the website. The common items and the web items are assumed
|
|
|
|
# to be already built.
|
|
|
|
#
|
|
|
|
|
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`
|
|
|
|
|
2013-02-17 00:27:07 +00:00
|
|
|
bookedir=$dir/$1
|
2012-03-04 12:39:12 +00:00
|
|
|
webdir=$dir/web/$1
|
|
|
|
graphicsdir=$dir/graphics/$1
|
|
|
|
output=index.html
|
2013-02-17 00:27:07 +00:00
|
|
|
booke=$1
|
2013-02-22 01:09:37 +00:00
|
|
|
masterbooke=$2
|
|
|
|
title=$booke
|
|
|
|
instrument=$3
|
2012-03-04 12:39:12 +00:00
|
|
|
|
|
|
|
buildno=`cat buildno.txt`
|
|
|
|
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
|
|
|
if [ -r $bookedir/intro.txt ]; then
|
|
|
|
intro=`cat $bookedir/intro.txt`
|
|
|
|
fi
|
|
|
|
|
2013-02-22 01:09:37 +00:00
|
|
|
if [ -n "$instrument" ]; then
|
2013-02-20 13:45:58 +00:00
|
|
|
# Remove any transposition tag from title.
|
2013-02-22 01:09:37 +00:00
|
|
|
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-02-17 00:27:07 +00:00
|
|
|
-e "s/@TITLE@/$title/" -e "s/@INTRO@/$intro/" \
|
|
|
|
-e "s/@BOOK@/$booke/" dottes.html.header > $webdir/$output
|
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
|
|
|
|
2012-03-04 12:39:12 +00:00
|
|
|
# Now, for each tune, make the tune graphic and sound.
|
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
|
2012-04-21 19:47:30 +01:00
|
|
|
title=`$dir/abcfield.py --field T --html $filename`
|
2012-03-04 12:39:12 +00:00
|
|
|
name=`basename $filename .abc`
|
|
|
|
|
2013-02-18 22:37:46 +00:00
|
|
|
# Restore titles like 'Exploding Potato, The' to the
|
|
|
|
# expected 'The Exploding Potato'.
|
|
|
|
title=`echo $title | sed -e "s/\(.*\), *\(.*\)/\2 \1/"`
|
|
|
|
|
2012-03-04 12:39:12 +00:00
|
|
|
# Copy tune PDF from common graphics.
|
|
|
|
cp $graphicsdir/${name}.pdf $webdir
|
|
|
|
|
|
|
|
# And copy the ABC.
|
|
|
|
cp $filename $webdir
|
|
|
|
|
2013-02-17 00:27:07 +00:00
|
|
|
# Generate the tune web page.
|
|
|
|
tunepage=${name}.html
|
|
|
|
|
2013-02-22 01:09:37 +00:00
|
|
|
# If the title contains HTML character entities, escape
|
|
|
|
# initial '&' in the title - it means things to sed.
|
2013-02-17 01:29:44 +00:00
|
|
|
sed -e "s/@TITLE@/${title//&/\&}/" \
|
2013-02-22 01:09:37 +00:00
|
|
|
-e "s/@MASTERBOOKE@/${masterbooke}/" \
|
2013-02-17 00:27:07 +00:00
|
|
|
-e "s/@TUNE@/${name}/" dottes.html.tune > $webdir/$tunepage
|
|
|
|
|
2013-02-17 01:29:44 +00:00
|
|
|
sed -e "s/@TITLE@/${title//&/\&}/" \
|
2013-02-17 00:27:07 +00:00
|
|
|
-e "s/@TUNE@/${name}/" dottes.html.tuneindex >> $webdir/$output
|
2012-03-04 12:39:12 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
cat dottes.html.footer >> $webdir/$output
|