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