Mercurial > dottes
comparison makeBookeTunePages.sh @ 266:06e140f48543
Revise scripts for building printed Bookes.
A lot of stuff was being duplicated between different page size. Consolidate where
possible, and in particular put as much into a single source file (dottes.tex) as
possible. Making a single Booke is now potentially quicker, as the tune pages
don't necessarily have to be regenerate every time.
| author | Jim Hague <jim.hague@acm.org> |
|---|---|
| date | Wed, 26 Jun 2013 23:37:45 +0100 |
| parents | |
| children | ced1d1ba42f6 |
comparison
equal
deleted
inserted
replaced
| 265:3e5335396f48 | 266:06e140f48543 |
|---|---|
| 1 #!/bin/bash | |
| 2 # | |
| 3 # Generate the LaTeX for the Booke tune pages (tunes.tex) and the index | |
| 4 # of first lines (firstlines.tex). These are generated into the build | |
| 5 # directory. | |
| 6 # | |
| 7 # All EPS and PDF tune graphics must be present already. Run | |
| 8 # makeGraphics.sh to make these. | |
| 9 # | |
| 10 | |
| 11 # Restore titles like 'Exploding Potato, The' to the | |
| 12 # expected 'The Exploding Potato'. | |
| 13 fixtitle() | |
| 14 { | |
| 15 retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"` | |
| 16 } | |
| 17 | |
| 18 if [ $# != 1 ]; then | |
| 19 echo "Usage: makeBookeTunePages.sh <book dir name>" | |
| 20 exit 1 | |
| 21 fi | |
| 22 | |
| 23 dir=`pwd` | |
| 24 | |
| 25 booke=$dir/$1 | |
| 26 builddir=$dir/build | |
| 27 graphicsdir=$dir/graphics/$1 | |
| 28 tunesoutput=$builddir/tunes.tex | |
| 29 indexoutput=$builddir/firstlines.tex | |
| 30 | |
| 31 mkdir -p $builddir | |
| 32 | |
| 33 rm -f $tunesoutput $indexoutput | |
| 34 | |
| 35 # Now, for each tune, make the tune graphic and add it, inside a | |
| 36 # centre section, so the document. Then add a TOC entry. | |
| 37 find $booke -name "*.abc" | sort | | |
| 38 while read filename | |
| 39 do | |
| 40 name=`basename $filename .abc` | |
| 41 title=`$dir/abcfield.py --field T --latex $filename` | |
| 42 fixtitle "$title" | |
| 43 title=$retval | |
| 44 | |
| 45 echo -E "\vfill \begin{center}" >> $tunesoutput | |
| 46 echo -E "\phantomsection" >> $tunesoutput | |
| 47 echo -E "\hypertarget{$name}{\includegraphics[width=\textwidth,height=0.85\textheight,keepaspectratio]{$graphicsdir/$name}}" >> $tunesoutput | |
| 48 echo -E "\addcontentsline{toc}{subsection}{$title}" >> $tunesoutput | |
| 49 echo -E "\end{center}" >> $tunesoutput | |
| 50 | |
| 51 changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"` | |
| 52 changetitle="" | |
| 53 if [ -n "$changefile" ]; then | |
| 54 changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile` | |
| 55 fixtitle "$changetitle" | |
| 56 changetitle=$retval | |
| 57 changename=`basename $changefile .abc` | |
| 58 echo -E "Change: \hyperlink{$changename}{$changetitle}" >> $tunesoutput | |
| 59 fi | |
| 60 | |
| 61 echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.6\textwidth]{$graphicsdir/firstline-$name}} \\\\" >> $indexoutput | |
| 62 done |
