From aa97e0f688175be0935fad16e617fcc4b48f6dd0 Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Mon, 5 Aug 2019 23:25:28 +0100 Subject: [PATCH] Change web page layout. Put tune contents under 'tunes/' or 'tunes-/'. That way they won't move if the tune gets moved between Bookes. For now I have not attempted to redirect old URLs. --- Session/htaccess | 2 +- abcfield.py | 2 +- dottes.html.learnertune | 58 ++++++++++++++++++------------------- dottes.html.tune | 26 ++++++++--------- dottes.html.tuneindex | 8 +++--- makeAll.sh | 2 +- makeWeb.sh | 60 +++++++++++++++++++-------------------- makeWebAudio.sh | 63 ++++++++++++++++++++++++----------------- makeWebGraphics.sh | 33 ++++++++++++--------- 9 files changed, 135 insertions(+), 119 deletions(-) diff --git a/Session/htaccess b/Session/htaccess index b11dc98..d0caba0 100644 --- a/Session/htaccess +++ b/Session/htaccess @@ -1 +1 @@ -RedirectMatch permanent "(.*)/MazurkaAvignon\.html$" "$1/MazurkaAuvergne.html" +RedirectMatch permanent "(.*)/MazurkaAvignon\.html$" "tunes/MazurkaAuvergne/index.html" diff --git a/abcfield.py b/abcfield.py index 7a4df2e..65692bf 100755 --- a/abcfield.py +++ b/abcfield.py @@ -175,7 +175,7 @@ def convertMarkdown(t, latex): if latex: res = re.sub(r'\\href{(.*?).abc}', r'\\hyperlink{\1}', res) else: - res = re.sub(r'href="(.*?).abc"', r'href="\1.html"', res) + res = re.sub(r'href="(.*?).abc"', r'href="../\1/index.html"', res) return res.strip() # Implement a custom Markdown shorthand for referencing ABC files. diff --git a/dottes.html.learnertune b/dottes.html.learnertune index 140bbf6..9e3e601 100644 --- a/dottes.html.learnertune +++ b/dottes.html.learnertune @@ -4,7 +4,7 @@ Cry Havoc tunes - learning ${title} - + @@ -13,13 +13,13 @@
- Learner tune image + Learner tune image Work out the melody or play along with these audio players. They play the melody repeatedly. There's a variety of speeds to choose from. You can also download the @@ -59,18 +59,18 @@
  • MIDI
  • + href="../../${mastertunedir}/${name}/${name}.mid">MIDI
  • MP3
  • + href="../../${mastertunedir}/${name}/${name}.mp3">MP3
  • OGG
  • + href="../../${mastertunedir}/${name}/${name}.ogg">OGG
@@ -80,18 +80,18 @@
  • MIDI
  • + href="../../${mastertunedir}/${name}/littleslow-${name}.mid">MIDI
  • MP3
  • + href="../../${mastertunedir}/${name}/littleslow-${name}.mp3">MP3
  • OGG
  • + href="../../${mastertunedir}/${name}/littleslow-${name}.ogg">OGG
@@ -101,18 +101,18 @@
  • MIDI
  • + href="../../${mastertunedir}/${name}/slow-${name}.mid">MIDI
  • MP3
  • + href="../../${mastertunedir}/${name}/slow-${name}.mp3">MP3
  • OGG
  • + href="../../${mastertunedir}/${name}/slow-${name}.ogg">OGG
@@ -122,18 +122,18 @@
  • MIDI
  • + href="../../${mastertunedir}/${name}/veryslow-${name}.mid">MIDI
  • MP3
  • + href="../../${mastertunedir}/${name}/veryslow-${name}.mp3">MP3
  • OGG
  • + href="../../${mastertunedir}/${name}/veryslow-${name}.ogg">OGG
@@ -144,20 +144,20 @@ diff --git a/dottes.html.tune b/dottes.html.tune index 2fc7c4b..03e338a 100644 --- a/dottes.html.tune +++ b/dottes.html.tune @@ -4,7 +4,7 @@ Cry Havoc tunes - ${title} - + @@ -13,7 +13,7 @@
@@ -55,11 +55,11 @@
  • PDF
  • MIDI
  • + href="../../${mastertunedir}/${name}/${name}.mid">MIDI
  • MP3
  • + href="../../${mastertunedir}/${name}/${name}.mp3">MP3
  • OGG
  • + href="../../${mastertunedir}/${name}/${name}.ogg">OGG
  • ABC
  • diff --git a/dottes.html.tuneindex b/dottes.html.tuneindex index 7371101..87c7014 100644 --- a/dottes.html.tuneindex +++ b/dottes.html.tuneindex @@ -1,15 +1,15 @@
    diff --git a/makeAll.sh b/makeAll.sh index 57538a4..b35bcce 100755 --- a/makeAll.sh +++ b/makeAll.sh @@ -48,7 +48,7 @@ makeATransposedBooke() makeBookePrint "$1" # Web output. Uses audio from main booke. - ./makeWebGraphics.sh "$1" + ./makeWebGraphics.sh "$1" "$3" ./makeWeb.sh "$1" "$2" "$3" } diff --git a/makeWeb.sh b/makeWeb.sh index 1c89b08..48c0c34 100755 --- a/makeWeb.sh +++ b/makeWeb.sh @@ -18,7 +18,10 @@ booke=$1 masterbooke=$2 bookedir=$dir/$1 masterbookedir=$dir/$2 -webdir=$dir/web/$1 +basewebdir=$dir/web +mastertunedir=tunes +basetunedir=$mastertunedir +bookewebdir=$dir/web/$1 graphicsdir=$dir/graphics/$1 output=index.html tunelist=tunelist.html @@ -38,34 +41,35 @@ fi if [ -n "$instrument" ]; then title="${title} ($instrument)" subtitle="${subtitle} ($instrument)" + basetunedir="${basetunedir}-${instrument}" fi -mkdir -p $webdir +mkdir -p $bookewebdir sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \ - -e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" dottes.html > $webdir/$output + -e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" dottes.html > $bookewebdir/$output for item in intro do - rm -f $webdir/$item.html + rm -f $bookewebdir/$item.html if [ -r $bookedir/$item.md ]; then - pandoc --from=markdown --to=html --output=$webdir/$item.html $bookedir/$item.md + pandoc --from=markdown --to=html --output=$bookewebdir/$item.html $bookedir/$item.md else - touch $webdir/$item.html + touch $bookewebdir/$item.html fi done # Copy in any htaccess. if [ -r $masterbookedir/htaccess ]; then - cp $masterbookedir/htaccess $webdir/.htaccess + cp $masterbookedir/htaccess $bookewebdir/.htaccess fi # Copy in the book PDFs. Like the graphics, Midi etc. these are assumed # to be already generated. -cp $1-*.pdf $webdir +cp $1-*.pdf $bookewebdir # Now, for each tune, make the tune page. -rm -f $webdir/$tunelist +rm -f $bookewebdir/$tunelist declare -a filenames filenames=(`find $bookedir -maxdepth 1 -name "*.abc" | sort`) nofiles=${#filenames[@]} @@ -73,22 +77,15 @@ for (( i=0; i < ${nofiles}; i++ )) do filename=${filenames[$i]} name=`basename $filename .abc` + tunedir=$basetunedir/$name + tunewebdir=$basewebdir/$tunedir + mkdir -p $tunewebdir # Copy the ABC into the web. - cp $filename $webdir + cp $filename $tunewebdir # 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 + python $abc2xml $filename > ${tunewebdir}/${name}.xml # Get date and time of last change to tune. lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc` @@ -101,34 +98,35 @@ do if [ $i -gt 0 ]; then prev=${filenames[$((i - 1))]} - prevpage=`basename $prev .abc`.html + prevpage=`basename $prev .abc` prevarg="--prev $prev" fi if [ $i -lt $((nofiles - 1)) ]; then next=${filenames[$((i + 1))]} - nextpage=`basename $next .abc`.html + nextpage=`basename $next .abc` nextarg="--next $next" fi # Generate the tune web page. - tunepage=${name}.html - learnerpage=learner-${name}.html - $dir/abctemplate.py \ - --value "masterbooke=${masterbooke}" \ + --value "booke=${booke}" \ + --value "mastertunedir=${mastertunedir}" \ --value "lastchanged=${lastchanged}" \ --value "prevpage=${prevpage}" \ --value "nextpage=${nextpage}" \ ${prevarg} ${nextarg} \ --template dottes.html.tune \ - $filename > $webdir/$tunepage + $filename > $tunewebdir/index.html $dir/abctemplate.py \ - --value "masterbooke=${masterbooke}" \ + --value "booke=${booke}" \ + --value "mastertunedir=${mastertunedir}" \ --value "lastchanged=${lastchanged}" \ --value "prevpage=${prevpage}" \ --value "nextpage=${nextpage}" \ ${prevarg} ${nextarg} \ --template dottes.html.learnertune \ - $filename > $webdir/$learnerpage - $dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist + $filename > $tunewebdir/learner.html + $dir/abctemplate.py \ + --value "tunedir=${tunedir}" \ + --template dottes.html.tuneindex $filename >> $bookewebdir/$tunelist done diff --git a/makeWebAudio.sh b/makeWebAudio.sh index 1d6da1b..f696d1f 100755 --- a/makeWebAudio.sh +++ b/makeWebAudio.sh @@ -12,39 +12,46 @@ fi dir=`pwd` booke=$dir/$1 -builddir=$dir/web/$1 - -mkdir -p $builddir +basewebdir=$dir/web +basetunedir=$basewebdir/tunes # Make MP3 and OGG files for the input .abc. Since we're listening to # a doorbell playing the tunes, go for lowest quality (and hence smallest) -# MP3 and OGG. $1 is the input filename, $2 is optional args for timidity. +# MP3 and OGG. $1 is the input filename, $2 is the output directory, +# $3 is optional args for timidity. makeaudiofiles() { name=`basename $1 .abc` + tunedir="$2" - abc2midi $1 -o $builddir/${name}.mid - timidity -OwM $2 -o $builddir/${name}.wav $builddir/${name}.mid - lame -m m -V 9 --quiet $builddir/${name}.wav $builddir/${name}.mp3 + abc2midi $1 -o $tunedir/${name}.tmp.mid + mv $tunedir/${name}.tmp.mid $tunedir/${name}.mid + timidity -OwM $3 -o $tunedir/${name}.wav $tunedir/${name}.mid + lame -m m -V 9 --quiet $tunedir/${name}.wav $tunedir/${name}.tmp.mp3 + mv $tunedir/${name}.tmp.mp3 $tunedir/${name}.mp3 # Timidity can generate OGG directly. But we need to generate WAV # for lame, and oggenc produces smaller output. OGG is needed for # Firefox's audio tag. FF doesn't support MP3, some others support # MP3 but not OGG. - oggenc -Q -q 0 -o $builddir/${name}.ogg $builddir/${name}.wav + oggenc -Q -q 0 -o $tunedir/${name}.tmp.ogg $tunedir/${name}.wav + mv $tunedir/${name}.tmp.ogg $tunedir/${name}.ogg - rm $builddir/${name}.wav + rm $tunedir/${name}.wav } -# Make audio for a new tempo for the abc file $1, giving the output files -# the same name with a prefix $2. The new tempo is the original tempo -# (120 used if not specified), multiplied by $3 and divided by $4. -# These audio files are for Learner use; I've found that having the -# chords thumping away can make it hard to distinguish the melody, so -# arrange for timidity to mute everything except the melody track. +# Make audio for a new tempo for the abc file $1, giving the output +# files the same name with a prefix $3 in output directory $2. The new +# tempo is the original tempo (120 used if not specified), multiplied +# by $4 and divided by $5. These audio files are for Learner use; +# I've found that having the chords thumping away can make it hard to +# distinguish the melody, so arrange for timidity to mute everything +# except the melody track. makeaudiofortempo() { - name=`basename $filename .abc` - newspeedfilename="$2-${name}.abc" + name=`basename $1 .abc` + tunedir="$2" + newspeedfilename="$3-${name}.abc" + mkdir -p $tunedir # Prepare new speed audio files. # The tempo is either a plain number, or =. @@ -57,23 +64,27 @@ makeaudiofortempo() numtempo=${tempo:pos} notelenprefix=${tempo:0:pos} # Calculate new tempo. - newtempo=$(( ( $numtempo * $3 ) / $4 )) + newtempo=$(( ( $numtempo * $4 ) / $5 )) # Insert new tempo and delete old. Old may not exist, # so do this rather than overwrite. - sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $builddir/$newspeedfilename - makeaudiofiles $builddir/$newspeedfilename --mute=0,-1 - rm $builddir/$newspeedfilename + sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $tunedir/$newspeedfilename + makeaudiofiles $tunedir/$newspeedfilename $tunedir --mute=0,-1 + rm $tunedir/$newspeedfilename } # Generate audio files and slow speed (currently half speed) audio files. find $booke -maxdepth 1 -name "*.abc" | sort | while read filename do - makeaudiofiles $filename + name=`basename $filename .abc` + tunedir=$basetunedir/$name + mkdir -p $tunedir + + makeaudiofiles $filename $tunedir # Now make 1/4, 1/2 and 3/4 speed audio. - makeaudiofortempo $filename "veryslow" 1 4 - makeaudiofortempo $filename "slow" 2 4 - makeaudiofortempo $filename "littleslow" 3 4 - makeaudiofortempo $filename "normal" 4 4 + makeaudiofortempo $filename $tunedir "veryslow" 1 4 + makeaudiofortempo $filename $tunedir "slow" 2 4 + makeaudiofortempo $filename $tunedir "littleslow" 3 4 + makeaudiofortempo $filename $tunedir "normal" 4 4 done diff --git a/makeWebGraphics.sh b/makeWebGraphics.sh index 5828711..546f86b 100755 --- a/makeWebGraphics.sh +++ b/makeWebGraphics.sh @@ -1,21 +1,25 @@ #!/bin/bash # # Make graphics required for the website but not for the book. -# They go into web/. +# They go into web/tunes/, or web/tunes-/. # -if [ $# != 1 ]; then - echo "Usage: makeWebGraphics.sh " +if [[ $# -lt 1 ]]; then + echo "Usage: makeWebGraphics.sh []" exit 1 fi dir=`pwd` booke=$dir/$1 -builddir=$dir/web/$1 +basewebdir=$dir/web +basetunedir=$basewebdir/tunes graphicsdir=$dir/graphics/$1 +instrument=$2 -mkdir -p $builddir +if [ -n "$instrument" ]; then + basetunedir="${basetunedir}-${instrument}" +fi # Now, for each tune, make the main tune and tune first line bitmaps. # Do this to temp files and rename into place to make updates as @@ -24,16 +28,19 @@ find $booke -maxdepth 1 -name "*.abc" | sort | while read filename do name=`basename $filename .abc` - tmpname=${name}.tmp - convert -colors 256 -quality 90 -density 200 $graphicsdir/${name}.pdf $builddir/${tmpname}.png - convert -colors 256 -quality 90 -density 200 $graphicsdir/firstline-${name}.pdf $builddir/firstline-${tmpname}.png + tunedir=$basetunedir/$name + mkdir -p $tunedir - mv $builddir/${tmpname}.png $builddir/${name}.png - mv $builddir/firstline-${tmpname}.png $builddir/firstline-${name}.png + tmpname=${name}.tmp + convert -colors 256 -quality 90 -density 200 $graphicsdir/${name}.pdf $tunedir/${tmpname}.png + convert -colors 256 -quality 90 -density 200 $graphicsdir/firstline-${name}.pdf $tunedir/firstline-${tmpname}.png + + mv $tunedir/${tmpname}.png $tunedir/${name}.png + mv $tunedir/firstline-${tmpname}.png $tunedir/firstline-${name}.png # Make the web downloadable PDF with the tune title. - abcm2ps -E -F singletuneweb -O $builddir/$name.eps $filename + abcm2ps -E -F singletuneweb -O $tunedir/$name.eps $filename # And make the corresponding PDF. - epstopdf --outfile=$builddir/$name.pdf $builddir/${name}001.eps - rm $builddir/${name}001.eps + epstopdf --outfile=$tunedir/$name.pdf $tunedir/${name}001.eps + rm $tunedir/${name}001.eps done