Mercurial > dottes
view makeWeb.sh @ 727:772402f5f8ea
Provide full titles for next and previous tunes in web pages.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Wed, 11 Oct 2017 17:45:27 +0100 |
parents | f8ab14cc9d8d |
children | c81a1ed21877 |
line wrap: on
line source
#!/bin/bash # # Build the website. The common items and the web items are assumed # to be already built. This generates the MusicXML and the page HTML # and shuffles other files ino the right place. # #set -x 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` booke=$1 masterbooke=$2 bookedir=$dir/$1 masterbookedir=$dir/$2 webdir=$dir/web/$1 graphicsdir=$dir/graphics/$1 output=index.html tunelist=tunelist.html title=$booke instrument=$3 abc2xml=$dir/abc2xml/abc2xml.py 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 [ -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/@BOOK@/$booke/" dottes.html > $webdir/$output for item in intro do rm -f $webdir/$item.html if [ -r $bookedir/$item.md ]; then pandoc --from=markdown --to=html --output=$webdir/$item.html $bookedir/$item.md else touch $webdir/$item.html fi done # Copy in any htaccess. if [ -r $masterbookedir/htaccess ]; then cp $masterbookedir/htaccess $webdir/.htaccess fi # 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 page. rm -f $webdir/$tunelist 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 # 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 # 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="" prevfulltitle="" nextpage="" nexttitle="" nextfulltitle="" if [ $i -gt 0 ]; then prev=${filenames[$((i - 1))]} prevpage=`basename $prev .abc`.html prevtitle=`./abcfield.py --display --field="T" $prev` prevfulltitle=`./abcfield.py --display --field="FT" $prev` fi if [ $i -lt $((nofiles - 1)) ]; then next=${filenames[$((i + 1))]} nextpage=`basename $next .abc`.html nexttitle=`./abcfield.py --display --field="T" $next` nextfulltitle=`./abcfield.py --display --field="FT" $next` fi # Generate the tune web page. tunepage=${name}.html learnerpage=learner-${name}.html $dir/abctemplate.py \ --value "masterbooke=${masterbooke}" \ --value "lastchanged=${lastchanged}" \ --value "prevpage=${prevpage}" \ --value "prevtitle=${prevtitle}" \ --value "prevfulltitle=${prevfulltitle}" \ --value "nextpage=${nextpage}" \ --value "nexttitle=${nexttitle}" \ --value "nextfulltitle=${nextfulltitle}" \ --template dottes.html.tune $filename > $webdir/$tunepage $dir/abctemplate.py \ --value "masterbooke=${masterbooke}" \ --value "lastchanged=${lastchanged}" \ --value "prevpage=learner-${prevpage}" \ --value "prevtitle=${prevtitle}" \ --value "prevfulltitle=${prevfulltitle}" \ --value "nextpage=learner-${nextpage}" \ --value "nexttitle=${nexttitle}" \ --value "nextfulltitle=${nextfulltitle}" \ --template dottes.html.learnertune $filename > $webdir/$learnerpage $dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist done