diff makeWeb.sh @ 722:f8ab14cc9d8d build-default-281

Add previous and next tune links to website.
author Jim Hague <jim.hague@acm.org>
date Tue, 10 Oct 2017 15:01:22 +0100
parents 4e92928fcfc2
children 772402f5f8ea
line wrap: on
line diff
--- a/makeWeb.sh	Mon Oct 09 19:07:36 2017 +0100
+++ b/makeWeb.sh	Tue Oct 10 15:01:22 2017 +0100
@@ -66,35 +66,69 @@
 
 # Now, for each tune, make the tune page.
 rm -f $webdir/$tunelist
-find $bookedir -name "*.abc" | sort |
-    while read filename
-    do
-        name=`basename $filename .abc`
+declare -a filenames
+filenames=(`find $bookedir -name "*.abc" | sort`)
+nofiles=${#filenames[@]}
+for (( i=0; i < ${nofiles}; i++ ))
+do
+    filename=${filenames[$i]}
+    name=`basename $filename .abc`
+
+    # Copy the ABC into the web.
+    cp $filename $webdir
+
+    # Generate MusicXML into the web.
+    python $abc2xml $filename > ${webdir}/${name}.xml
 
-        # Copy the ABC into the web.
-        cp $filename $webdir
+    # 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 .
+        popd > /dev/null
+    fi
 
-        # Generate MusicXML into the web.
-        python $abc2xml $filename > ${webdir}/${name}.xml
+    # Get date and time of last change to tune.
+    lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc`
+
+    # Get previous and next tune page names and titles.
+    prevpage=""
+    prevtitle=""
+    nextpage=""
+    nexttitle=""
 
-        # 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 .
-            popd > /dev/null
-        fi
+    if [ $i -gt 0 ]; then
+        prev=${filenames[$((i - 1))]}
+        prevpage=`basename $prev .abc`.html
+        prevtitle=`./abcfield.py --display --field="T" $prev`
+    fi
+    if [ $i -lt $((nofiles - 1)) ]; then
+        next=${filenames[$((i + 1))]}
+        nextpage=`basename $next .abc`.html
+        nexttitle=`./abcfield.py --display --field="T" $next`
+    fi
+
+    # Generate the tune web page.
+    tunepage=${name}.html
+    learnerpage=learner-${name}.html
 
-        # 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
-
-        $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
+    $dir/abctemplate.py \
+        --value "masterbooke=${masterbooke}" \
+        --value "lastchanged=${lastchanged}" \
+        --value "prevpage=${prevpage}" \
+        --value "prevtitle=${prevtitle}" \
+        --value "nextpage=${nextpage}" \
+        --value "nexttitle=${nexttitle}" \
+        --template dottes.html.tune $filename > $webdir/$tunepage
+    $dir/abctemplate.py \
+        --value "masterbooke=${masterbooke}" \
+        --value "lastchanged=${lastchanged}" \
+        --value "prevpage=learner-${prevpage}" \
+        --value "prevtitle=${prevtitle}" \
+        --value "nextpage=learner-${nextpage}" \
+        --value "nexttitle=${nexttitle}" \
+        --template dottes.html.learnertune $filename > $webdir/$learnerpage
+    $dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist
+done