Mercurial > dottes
diff makeWeb.sh @ 400:f1c4abe4fc75 build-default-175
First go at adding the tune learner page.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Mon, 02 Sep 2013 11:48:16 +0100 |
parents | e09ff88ab469 |
children | f7dbde7c9661 |
line wrap: on
line diff
--- a/makeWeb.sh Mon Sep 02 10:15:56 2013 +0100 +++ b/makeWeb.sh Mon Sep 02 11:48:16 2013 +0100 @@ -13,6 +13,37 @@ retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"` } +# Format a key in ABC (G, Gmin, etc.) in standard presentation format. +fixkey() +{ + letter=${1:0:1} + accidental=${1:1:1} + if [ "$accidental" != "#" -a "$accidental" != "b" ]; then + accidental="" + mode=${1:1:3} + else + mode=${1:2:3} + fi + mode=${mode,,} + mode=${mode/ //g} + if [ "$mode" = "m" -o "$mode" = "min" ]; then + mode="Minor" + elif [ "$mode" = "mix" ]; then + mode="Mixolydian" + elif [ "$mode" = "dor" ]; then + mode="Dorian" + elif [ "$mode" = "phr" ]; then + mode="Phrygian" + elif [ "$mode" = "lyd" ]; then + mode="Lydian" + elif [ "$mode" = "loc" ]; then + mode="Locrian" + else + mode="Major" + fi + retval="${letter}${accidental} ${mode}" +} + if [ $# -lt 2 -o $# -gt 3 ]; then echo "Usage: makeWeb.sh <book dir name> <master book dir name> [<instrument name>]" exit 1 @@ -64,6 +95,7 @@ cp $1-*.pdf $webdir # Now, for each tune, make the tune page. +rm -f $webdir/$tunelist find $bookedir -name "*.abc" | sort | while read filename do @@ -90,28 +122,33 @@ creditvisibility="yes" fi lastchanged=`hg log --limit 1 --template "{date|shortdate}" $filename` + key=`$dir/abcfield.py --field K $filename` + fixkey $key + key=$retval # Copy the ABC into the web. cp $filename $webdir - # If we are not the master booke, link the mp3 in from the + # If we are not the master booke, link the mp3s in from the # master page in a desperate attempt to make IE8 work. # The Jenkins archive will dereference the soft link, it seems, # but I guess I can live with copies of the MP3 for now. if [ "$booke" != "$masterbooke" ]; then pushd ${webdir} > /dev/null - ln -f -s ../${masterbooke}/${name}.mp3 + ln -f -s ../${masterbooke}/*${name}.mp3 popd > /dev/null fi # Generate the tune web page. tunepage=${name}.html + learnerpage=learner-${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/@KEY@/${key}/" \ -e "s/@MASTERBOOKE@/${masterbooke}/" \ -e "s/@CHANGETITLE@/${changetitle//&/\&}/" \ -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \ @@ -122,5 +159,18 @@ -e "s/@TUNE@/${name}/" dottes.html.tune > $webdir/$tunepage sed -e "s/@TITLE@/${title//&/\&}/" \ + -e "s/@SUBTITLE@/${subtitle}/" \ + -e "s/@COMPOSER@/${composer}/" \ + -e "s/@KEY@/${key}/" \ + -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.learnertune > $webdir/$learnerpage + + sed -e "s/@TITLE@/${title//&/\&}/" \ -e "s/@TUNE@/${name}/" dottes.html.tuneindex >> $webdir/$tunelist done