diff makeWeb.sh @ 588:afc031477784

Replace sed substitution with Python templating for HTML and LaTeX output.
author Jim Hague <jim.hague@acm.org>
date Wed, 02 Nov 2016 00:21:18 +0000
parents daa3b76bd11f
children 4e92928fcfc2
line wrap: on
line diff
--- a/makeWeb.sh	Mon Oct 31 23:55:28 2016 +0000
+++ b/makeWeb.sh	Wed Nov 02 00:21:18 2016 +0000
@@ -66,25 +66,6 @@
     do
         name=`basename $filename .abc`
 
-        # Extract items to substitute in the web page.
-        title=`$dir/abcfield.py --field T --display $filename`
-        subtitle=`$dir/abcfield.py --index 2 --field T --display $filename`
-        composer=`$dir/abcfield.py --field C  $filename`
-        changefile=`$dir/abcfield.py --field N --starts "Change:" $filename`
-        changetitle=""
-        changevisibility="no"
-        if [ -n "$changefile" ]; then
-            changetitle=`$dir/abcfield.py --field T --display $bookedir/$changefile`
-            changevisibility="yes"
-        fi
-        credit=`$dir/abcfield.py --field N --starts "Credit:" $filename`
-        creditvisibility="no"
-        if [ -n "$credit" ]; then
-            creditvisibility="yes"
-        fi
-        lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc`
-        key=`$dir/abcfield.py --field K --display $filename`
-
         # Copy the ABC into the web.
         cp $filename $webdir
 
@@ -101,38 +82,14 @@
             popd > /dev/null
         fi
 
+        # Get date and time of last change to tune.
+        lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc`
+
         # 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}/" \
-            -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/@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
+        $dir/abctemplate.py --value "masterbooke=${masterbooke}" --value "lastchanged=${lastchanged}" --template dottes.html.tune $filename > $webdir/$tunepage
+        $dir/abctemplate.py --value "masterbooke=${masterbooke}" --value "lastchanged=${lastchanged}" --template dottes.html.learnertune $filename > $webdir/$learnerpage
+        $dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist
     done