view makeWeb.sh @ 217:a8a46fd79d5c

Fix up problems in Horn in F transposition. 1. Ensure makeWeb.sh gets its second parameter quoted, to allow for spaces in it. 2. Don't forget to copy the component text items into the horn dir. 3. Fix removing transposition tag from page title.
author Jim Hague <jim.hague@laicatc.com>
date Wed, 20 Feb 2013 13:45:58 +0000
parents 9502f4883006
children 0ef955669a9a
line wrap: on
line source

#!/bin/bash
#
# Build the website. The common items and the web items are assumed
# to be already built.
#

if [ $# -lt 1 -o $# -gt 2 ]; then
    echo "Usage: makeWeb.sh <book dir name> [<instrument name>]"
    exit 1
fi

dir=`pwd`

bookedir=$dir/$1
webdir=$dir/web/$1
graphicsdir=$dir/graphics/$1
output=index.html
title=$1
booke=$1

buildno=`cat buildno.txt`
subtitle=
intro=
if [ -r $bookedir/subtitle.txt ]; then
    subtitle=`cat $bookedir/subtitle.txt`
fi
if [ -r $bookedir/intro.txt ]; then
    intro=`cat $bookedir/intro.txt`
fi

if [ -n "$2" ]; then
    # Remove any transposition tag from title.
    title="${title/-*/} ($2)"
    subtitle="${subtitle} ($2)"
fi

mkdir -p $webdir

sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \
    -e "s/@TITLE@/$title/" -e "s/@INTRO@/$intro/" \
    -e "s/@BOOK@/$booke/" dottes.html.header > $webdir/$output

# Copy in the book PDFs. Like the graphics, Midi etc. these are assumed
# to be already generated.
cp $1-*.pdf $webdir

# Now, for each tune, make the tune graphic and sound.
find $bookedir -name "*.abc" | sort |
    while read filename
    do
        title=`$dir/abcfield.py --field T --html $filename`
        name=`basename $filename .abc`

        # Restore titles like 'Exploding Potato, The' to the
        # expected 'The Exploding Potato'.
        title=`echo $title | sed -e "s/\(.*\), *\(.*\)/\2 \1/"`

        # Copy tune PDF from common graphics.
        cp $graphicsdir/${name}.pdf $webdir

        # And copy the ABC.
        cp $filename $webdir

        # Generate the tune web page.
        tunepage=${name}.html

        sed -e "s/@TITLE@/${title//&/\&}/" \
            -e "s/@TUNE@/${name}/" dottes.html.tune > $webdir/$tunepage

        sed -e "s/@TITLE@/${title//&/\&}/" \
            -e "s/@TUNE@/${name}/" dottes.html.tuneindex >> $webdir/$output
    done

cat dottes.html.footer >> $webdir/$output