Mercurial > dottes
annotate makeBookeTunePages.sh @ 312:8bc92e044e0a
Move tune and first line inclusion code into macros.
Also use tune title, not name, as hyperlink targets. This removes the need to pass
the name into the macros.
| author | Jim Hague <jim.hague@acm.org> |
|---|---|
| date | Fri, 12 Jul 2013 11:36:14 +0100 |
| parents | c3b300378738 |
| children | cbe9c10b5a3e |
| 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 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
|
46 changetitle="" |
|
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
47 if [ -n "$changefile" ]; then |
|
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
48 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
|
49 fixtitle "$changetitle" |
|
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
50 changetitle=$retval |
|
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
51 fi |
|
312
8bc92e044e0a
Move tune and first line inclusion code into macros.
Jim Hague <jim.hague@acm.org>
parents:
306
diff
changeset
|
52 echo -E "\showtune[$changetitle]{$title}{$graphicsdir/$name}" >> $tunesoutput |
|
266
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
53 |
|
312
8bc92e044e0a
Move tune and first line inclusion code into macros.
Jim Hague <jim.hague@acm.org>
parents:
306
diff
changeset
|
54 echo -E "\showfirstline{$title}{$graphicsdir/firstline-$name}" >> $indexoutput |
|
266
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
55 done |
