diff makeWeb.sh @ 229:1e4443d58177

Modify Change tune handling. Change all change notes to reference the filename of the tune to change to. Modify web and document generators to pull the change note out of the abc and generate an appropiate bit of content. This is now, in both cases, a hyperlink. In the process, remove the tune-specific .tex facility. It wasn't being used. I could really do with a proper templating system, and using some sort of templating in the LaTeX generation.
author Jim Hague <jim.hague@acm.org>
date Sat, 23 Feb 2013 13:10:58 +0000
parents 0ef955669a9a
children c61e76799e51
line wrap: on
line diff
--- a/makeWeb.sh	Sat Feb 23 11:38:35 2013 +0000
+++ b/makeWeb.sh	Sat Feb 23 13:10:58 2013 +0000
@@ -4,6 +4,15 @@
 # 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
@@ -31,7 +40,6 @@
 fi
 
 if [ -n "$instrument" ]; then
-    # Remove any transposition tag from title.
     title="${title} ($instrument)"
     subtitle="${subtitle} ($instrument)"
 fi
@@ -50,12 +58,21 @@
 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/"`
+        title=`$dir/abcfield.py --field T --html $filename`
+        fixtitle "$title"
+        title=$retval
+        changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | 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
 
         # Copy tune PDF from common graphics.
         cp $graphicsdir/${name}.pdf $webdir
@@ -70,6 +87,9 @@
         # initial '&' in the title - it means things to sed.
         sed -e "s/@TITLE@/${title//&/\&}/" \
             -e "s/@MASTERBOOKE@/${masterbooke}/" \
+            -e "s/@CHANGETITLE@/${changetitle//&/\&}/" \
+            -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \
+            -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \
             -e "s/@TUNE@/${name}/" dottes.html.tune > $webdir/$tunepage
 
         sed -e "s/@TITLE@/${title//&/\&}/" \