view makeWeb.sh @ 356:6d4b2dab5fcc build-default-158

Corrections from Mick. 1. Add missing two last notes in final bar of B tune. 2. Move 'no chord' marker to start of 2nd repeat in A tune. 3. Mark middle B in last line of Horse's Brawl as Bb. 4. Last note of 4th bar of King of the Fairies should be quaver. 5. 4th bar of B tune should be same as 4th bar of A tune in Plane Tree. 6. Railway has change to Fiery Clock Face.
author Jim Hague <jim.hague@acm.org>
date Mon, 19 Aug 2013 10:09:02 +0100
parents b233893b4c51
children 265539086836
line wrap: on
line source

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

#set -x

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

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

dir=`pwd`

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

buildno=`cat buildno.txt`
# Remove trailing % added for Latex purposes.
buildno=${buildno%%%}
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 "$instrument" ]; then
    title="${title} ($instrument)"
    subtitle="${subtitle} ($instrument)"
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
        name=`basename $filename .abc`

        title=`$dir/abcfield.py --field T --html $filename`
        fixtitle "$title"
        title=$retval
        subtitle=`$dir/abcfield.py --index 2 --field T --latex $filename`
        composer=`$dir/abcfield.py --field C --latex $filename`
        changefile=`$dir/abcfield.py --field N --contains "Change:" $filename | sed -e "s/Change: *//"`
        changetitle=""
        changevisibility="no"
        if [ -n "$changefile" ]; then
            changetitle=`$dir/abcfield.py --field T --html $bookedir/$changefile`
            changevisibility="yes"

            fixtitle "$changetitle"
            changetitle=$retval
        fi
        credit=`$dir/abcfield.py --field N --contains "Credit:" $filename | sed -e "s/Credit: *//"`
        creditvisibility="no"
        if [ -n "$credit" ]; then
            creditvisibility="yes"
        fi
        lastchanged=`hg log --limit 1 --template "{date|shortdate}" $filename`

        # Copy the ABC into the web.
        cp $filename $webdir

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

        # If the title contains HTML character entities, escape
        # initial '&' in the title - it means things to sed.
        sed -e "s/@TITLE@/${title//&/\&}/" \
            -e "s/@SUBTITLE@/${subtitle}/" \
            -e "s/@COMPOSER@/${composer}/" \
            -e "s/@MASTERBOOKE@/${masterbooke}/" \
            -e "s/@CHANGETITLE@/${changetitle//&/\&}/" \
            -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \
            -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \
            -e "s/@CREDIT@/${credit}/" \
            -e "s/@CREDITVISIBILITY@/${creditvisibility}/" \
            -e "s/@LASTCHANGED@/${lastchanged}/" \
            -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