Mercurial > dottes
annotate makeBookeTunePages.sh @ 456:0ed2d244b024 build-default-196
Revise New Road to Alston to match Jane's book.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Tue, 25 Feb 2014 21:13:47 +0000 |
parents | 27f29e8aafea |
children | b44fbcaeba38 |
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 |
319
cbe9c10b5a3e
Render tune title, subtitle and composer in Latex/HTML and not in the image.
Jim Hague <jim.hague@acm.org>
parents:
312
diff
changeset
|
44 subtitle=`$dir/abcfield.py --index 2 --field T --latex $filename` |
cbe9c10b5a3e
Render tune title, subtitle and composer in Latex/HTML and not in the image.
Jim Hague <jim.hague@acm.org>
parents:
312
diff
changeset
|
45 composer=`$dir/abcfield.py --field C --latex $filename` |
266
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
46 |
326
27f29e8aafea
Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents:
323
diff
changeset
|
47 changefile=`$dir/abcfield.py --field N --contains "Change:" $filename | sed -e "s/Change: *//"` |
323
1a240d1e2032
Go back to using the filename as the hyperlink name.
Jim Hague <jim.hague@acm.org>
parents:
319
diff
changeset
|
48 changename="" |
266
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
49 changetitle="" |
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
50 if [ -n "$changefile" ]; then |
323
1a240d1e2032
Go back to using the filename as the hyperlink name.
Jim Hague <jim.hague@acm.org>
parents:
319
diff
changeset
|
51 changename=`basename $changefile .abc` |
266
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
52 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
|
53 fixtitle "$changetitle" |
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
54 changetitle=$retval |
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
55 fi |
326
27f29e8aafea
Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents:
323
diff
changeset
|
56 |
27f29e8aafea
Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents:
323
diff
changeset
|
57 credit=`$dir/abcfield.py --field N --contains "Credit:" $filename | sed -e "s/Credit: *//"` |
27f29e8aafea
Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents:
323
diff
changeset
|
58 echo -E "\showtune{$name}{$title}{$subtitle}{$composer}{$graphicsdir/$name}{$changename}{$changetitle}{$credit}" >> $tunesoutput |
266
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
59 |
323
1a240d1e2032
Go back to using the filename as the hyperlink name.
Jim Hague <jim.hague@acm.org>
parents:
319
diff
changeset
|
60 echo -E "\showfirstline{$name}{$title}{$graphicsdir/firstline-$name}" >> $indexoutput |
266
06e140f48543
Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff
changeset
|
61 done |