# HG changeset patch # User Jim Hague # Date 1565043928 -3600 # Node ID d6e2a281cceb3591eb9446f783734eca46a29e08 # Parent a774b3b3cad7ef560b445880f05202833a515820 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. diff -r a774b3b3cad7 -r d6e2a281cceb Session/htaccess --- a/Session/htaccess Mon Aug 05 23:22:04 2019 +0100 +++ b/Session/htaccess Mon Aug 05 23:25:28 2019 +0100 @@ -1,1 +1,1 @@ -RedirectMatch permanent "(.*)/MazurkaAvignon\.html$" "$1/MazurkaAuvergne.html" +RedirectMatch permanent "(.*)/MazurkaAvignon\.html$" "tunes/MazurkaAuvergne/index.html" diff -r a774b3b3cad7 -r d6e2a281cceb abcfield.py --- a/abcfield.py Mon Aug 05 23:22:04 2019 +0100 +++ b/abcfield.py Mon Aug 05 23:25:28 2019 +0100 @@ -175,7 +175,7 @@ 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 -r a774b3b3cad7 -r d6e2a281cceb dottes.html.learnertune --- a/dottes.html.learnertune Mon Aug 05 23:22:04 2019 +0100 +++ b/dottes.html.learnertune Mon Aug 05 23:25:28 2019 +0100 @@ -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 -r a774b3b3cad7 -r d6e2a281cceb dottes.html.tune --- a/dottes.html.tune Mon Aug 05 23:22:04 2019 +0100 +++ b/dottes.html.tune Mon Aug 05 23:25:28 2019 +0100 @@ -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 -r a774b3b3cad7 -r d6e2a281cceb dottes.html.tuneindex --- a/dottes.html.tuneindex Mon Aug 05 23:22:04 2019 +0100 +++ b/dottes.html.tuneindex Mon Aug 05 23:25:28 2019 +0100 @@ -1,15 +1,15 @@
    diff -r a774b3b3cad7 -r d6e2a281cceb makeAll.sh --- a/makeAll.sh Mon Aug 05 23:22:04 2019 +0100 +++ b/makeAll.sh Mon Aug 05 23:25:28 2019 +0100 @@ -48,7 +48,7 @@ makeBookePrint "$1" # Web output. Uses audio from main booke. - ./makeWebGraphics.sh "$1" + ./makeWebGraphics.sh "$1" "$3" ./makeWeb.sh "$1" "$2" "$3" } diff -r a774b3b3cad7 -r d6e2a281cceb makeWeb.sh --- a/makeWeb.sh Mon Aug 05 23:22:04 2019 +0100 +++ b/makeWeb.sh Mon Aug 05 23:25:28 2019 +0100 @@ -18,7 +18,10 @@ 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 @@ 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 @@ 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 @@ 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 -r a774b3b3cad7 -r d6e2a281cceb makeWebAudio.sh --- a/makeWebAudio.sh Mon Aug 05 23:22:04 2019 +0100 +++ b/makeWebAudio.sh Mon Aug 05 23:25:28 2019 +0100 @@ -12,39 +12,46 @@ 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 @@ 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 -r a774b3b3cad7 -r d6e2a281cceb makeWebGraphics.sh --- a/makeWebGraphics.sh Mon Aug 05 23:22:04 2019 +0100 +++ b/makeWebGraphics.sh Mon Aug 05 23:25:28 2019 +0100 @@ -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 @@ while read filename do name=`basename $filename .abc` + tunedir=$basetunedir/$name + mkdir -p $tunedir + 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 + 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 $builddir/${tmpname}.png $builddir/${name}.png - mv $builddir/firstline-${tmpname}.png $builddir/firstline-${name}.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