2013-06-26 23:37:45 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Generate the LaTeX for the Booke tune pages (tunes.tex) and the index
|
|
|
|
# of first lines (firstlines.tex). These are generated into the build
|
|
|
|
# directory.
|
|
|
|
#
|
|
|
|
# All EPS and PDF tune graphics must be present already. Run
|
|
|
|
# makeGraphics.sh to make these.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Restore titles like 'Exploding Potato, The' to the
|
|
|
|
# expected 'The Exploding Potato'.
|
|
|
|
fixtitle()
|
|
|
|
{
|
|
|
|
retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"`
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# != 1 ]; then
|
|
|
|
echo "Usage: makeBookeTunePages.sh <book dir name>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
dir=`pwd`
|
|
|
|
|
|
|
|
booke=$dir/$1
|
|
|
|
builddir=$dir/build
|
|
|
|
graphicsdir=$dir/graphics/$1
|
|
|
|
tunesoutput=$builddir/tunes.tex
|
|
|
|
indexoutput=$builddir/firstlines.tex
|
|
|
|
|
|
|
|
mkdir -p $builddir
|
|
|
|
|
|
|
|
rm -f $tunesoutput $indexoutput
|
|
|
|
|
|
|
|
# Now, for each tune, make the tune graphic and add it, inside a
|
|
|
|
# centre section, so the document. Then add a TOC entry.
|
|
|
|
find $booke -name "*.abc" | sort |
|
|
|
|
while read filename
|
|
|
|
do
|
|
|
|
name=`basename $filename .abc`
|
|
|
|
title=`$dir/abcfield.py --field T --latex $filename`
|
|
|
|
fixtitle "$title"
|
|
|
|
title=$retval
|
|
|
|
|
|
|
|
echo -E "\vfill \begin{center}" >> $tunesoutput
|
|
|
|
echo -E "\phantomsection" >> $tunesoutput
|
|
|
|
echo -E "\hypertarget{$name}{\includegraphics[width=\textwidth,height=0.85\textheight,keepaspectratio]{$graphicsdir/$name}}" >> $tunesoutput
|
2013-07-05 18:56:34 +01:00
|
|
|
echo -E "\addcontentsline{toc}{section}{$title}" >> $tunesoutput
|
2013-06-26 23:37:45 +01:00
|
|
|
echo -E "\end{center}" >> $tunesoutput
|
|
|
|
|
|
|
|
changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"`
|
|
|
|
changetitle=""
|
|
|
|
if [ -n "$changefile" ]; then
|
|
|
|
changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile`
|
|
|
|
fixtitle "$changetitle"
|
|
|
|
changetitle=$retval
|
|
|
|
changename=`basename $changefile .abc`
|
|
|
|
echo -E "Change: \hyperlink{$changename}{$changetitle}" >> $tunesoutput
|
|
|
|
fi
|
|
|
|
|
2013-07-07 20:40:03 +01:00
|
|
|
echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.65\textwidth,height=1.3cm]{$graphicsdir/firstline-$name}} \\\\" >> $indexoutput
|
2013-06-26 23:37:45 +01:00
|
|
|
done
|