Mercurial > dottes
annotate makeBookeA5.sh @ 229:1e4443d58177
Modify Change tune handling.
Change all change notes to reference the filename of the tune to change to.
Modify web and document generators to pull the change note out of the abc
and generate an appropiate bit of content. This is now, in both cases,
a hyperlink.
In the process, remove the tune-specific .tex facility. It wasn't being
used.
I could really do with a proper templating system, and using some sort
of templating in the LaTeX generation.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Sat, 23 Feb 2013 13:10:58 +0000 |
parents | 6a0bdabfb255 |
children | 440172d9f5d6 |
rev | line source |
---|---|
37
72b5d67756e1
Fix up troubles with \. echo -E disables expansion.
Jim Hague <jim.hague@laicatc.com>
parents:
34
diff
changeset
|
1 #!/bin/bash |
13 | 2 # |
3 # Build the Booke. First assemble the book LaTeX, then build it | |
4 # into a PDF. | |
5 # | |
42
0e7d2830cb8b
Put making tune graphics required by web and book into separate dir and make separately.
Jim Hague <jim.hague@laicatc.com>
parents:
40
diff
changeset
|
6 # All EPS and PDF tune graphics must be present already. Run |
0e7d2830cb8b
Put making tune graphics required by web and book into separate dir and make separately.
Jim Hague <jim.hague@laicatc.com>
parents:
40
diff
changeset
|
7 # makeGraphics.sh to make these. |
0e7d2830cb8b
Put making tune graphics required by web and book into separate dir and make separately.
Jim Hague <jim.hague@laicatc.com>
parents:
40
diff
changeset
|
8 # |
0 | 9 |
229 | 10 # Restore titles like 'Exploding Potato, The' to the |
11 # expected 'The Exploding Potato'. | |
12 fixtitle() | |
13 { | |
14 retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"` | |
15 } | |
16 | |
0 | 17 if [ $# != 1 ]; then |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
18 echo "Usage: makeBookeA5.sh <book dir name>" |
0 | 19 exit 1 |
20 fi | |
21 | |
16 | 22 dir=`pwd` |
23 | |
24 booke=$dir/$1 | |
25 builddir=$dir/build | |
42
0e7d2830cb8b
Put making tune graphics required by web and book into separate dir and make separately.
Jim Hague <jim.hague@laicatc.com>
parents:
40
diff
changeset
|
26 graphicsdir=$dir/graphics/$1 |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
27 output=dottesA5.tex |
119
15ce1ecb5ba3
Fix page size issue on xetex on Squeeze.
Jim Hague <jim.hague@acm.org>
parents:
118
diff
changeset
|
28 outputxdv=${output/%.tex/.xdv} |
15ce1ecb5ba3
Fix page size issue on xetex on Squeeze.
Jim Hague <jim.hague@acm.org>
parents:
118
diff
changeset
|
29 outputpdf=${output/%.tex/.pdf} |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
30 outputa4=dottesA5onA4booklet.tex |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
31 outputa4pdf=dottesA5onA4booklet.pdf |
0 | 32 |
16 | 33 mkdir -p $builddir |
34 | |
40
93955def7313
Revise page footers, and add build number.
Jim Hague <jim.hague@laicatc.com>
parents:
39
diff
changeset
|
35 cp buildno.txt $builddir |
39
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
36 if [ -r $booke/subtitle.txt ]; then |
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
37 cp $booke/subtitle.txt $builddir |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
38 else |
39
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
39 touch $builddir/subtitle.txt |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
40 fi |
39
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
41 if [ -r $booke/intro.txt ]; then |
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
42 cp $booke/intro.txt $builddir |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
43 else |
39
9681f6cd9c2b
Change subtitle and intro files to .txt extension.
Jim Hague <jim.hague@laicatc.com>
parents:
38
diff
changeset
|
44 touch $builddir/intro.txt |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
45 fi |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
46 cp dottes.tex.a5header $builddir/$output |
13 | 47 |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
48 # Now, for each tune, make the tune graphic and add it, inside a |
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
49 # centre section, so the document. Then add a TOC entry. |
13 | 50 find $booke -name "*.abc" | sort | |
51 while read filename | |
52 do | |
229 | 53 name=`basename $filename .abc` |
122
295ba8275ab4
Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents:
120
diff
changeset
|
54 title=`$dir/abcfield.py --field T --latex $filename` |
229 | 55 fixtitle "$title" |
56 title=$retval | |
57 | |
122
295ba8275ab4
Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents:
120
diff
changeset
|
58 echo -E "\newpage" >> $builddir/$output |
37
72b5d67756e1
Fix up troubles with \. echo -E disables expansion.
Jim Hague <jim.hague@laicatc.com>
parents:
34
diff
changeset
|
59 echo -E "\begin{center}" >> $builddir/$output |
115
c4efe8b5eea1
Add internal hyperlinks to the book.
Jim Hague <jim.hague@acm.org>
parents:
110
diff
changeset
|
60 echo -E "\phantomsection" >> $builddir/$output |
229 | 61 echo -E "\hypertarget{$name}{\includegraphics[width=\textwidth,height=0.85\textheight,keepaspectratio]{$graphicsdir/$name}}" >> $builddir/$output |
37
72b5d67756e1
Fix up troubles with \. echo -E disables expansion.
Jim Hague <jim.hague@laicatc.com>
parents:
34
diff
changeset
|
62 echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output |
72b5d67756e1
Fix up troubles with \. echo -E disables expansion.
Jim Hague <jim.hague@laicatc.com>
parents:
34
diff
changeset
|
63 echo -E "\end{center}" >> $builddir/$output |
229 | 64 |
65 changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"` | |
66 changetitle="" | |
67 if [ -n "$changefile" ]; then | |
68 changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile` | |
69 fixtitle "$changetitle" | |
70 changetitle=$retval | |
71 changename=`basename $changefile .abc` | |
72 echo -E "Change: \hyperlink{$changename}{$changetitle}" >> $builddir/$output | |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
73 fi |
13 | 74 done |
75 | |
50
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
76 cat dottes.tex.firstlines >> $builddir/$output |
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
77 |
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
78 find $booke -name "*.abc" | sort | |
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
79 while read filename |
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
80 do |
229 | 81 name=`basename $filename .abc` |
122
295ba8275ab4
Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents:
120
diff
changeset
|
82 title=`$dir/abcfield.py --field T --latex $filename` |
229 | 83 fixtitle "$title" |
84 title=$retval | |
115
c4efe8b5eea1
Add internal hyperlinks to the book.
Jim Hague <jim.hague@acm.org>
parents:
110
diff
changeset
|
85 echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.6\textwidth]{$graphicsdir/firstline-$name}} \\\\" >> $builddir/$output |
50
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
86 done |
e666306c5ab1
Add list of tune first lines.
Jim Hague <jim.hague@laicatc.com>
parents:
42
diff
changeset
|
87 |
16 | 88 cat dottes.tex.footer >> $builddir/$output |
13 | 89 |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
90 cp $outputa4 $builddir |
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
91 |
16 | 92 cd $builddir |
119
15ce1ecb5ba3
Fix page size issue on xetex on Squeeze.
Jim Hague <jim.hague@acm.org>
parents:
118
diff
changeset
|
93 |
15ce1ecb5ba3
Fix page size issue on xetex on Squeeze.
Jim Hague <jim.hague@acm.org>
parents:
118
diff
changeset
|
94 # The version of xetex on Squeeze doesn't do pass the A5 landscape instruction |
15ce1ecb5ba3
Fix page size issue on xetex on Squeeze.
Jim Hague <jim.hague@acm.org>
parents:
118
diff
changeset
|
95 # down to the PDF generator. So split out and do manually. |
120
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
96 # |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
97 # And, sigh, this fails on Sid. The first page comes out as A4 portrait. |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
98 # So try to work out which we are using and run the appropriate command. |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
99 ver=`xetex -version | head -n 1` |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
100 ver=${ver/*TeX Live /} |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
101 ver=${ver/\/*/} |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
102 if [ "$ver" == "2009" ]; then |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
103 xelatex -no-pdf $output |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
104 xelatex -no-pdf $output |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
105 xdvipdfmx -p a5 -l $outputxdv |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
106 else |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
107 xelatex $output |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
108 xelatex $output |
4b0025be9d22
Try to cope with Squeeze and Sid xetex problems.
Jim Hague <jim.hague@acm.org>
parents:
119
diff
changeset
|
109 fi |
118
8f3b50ede59c
Switch to XeTeX to render. Opens up random OpenType fonts and UTF-8.
Jim Hague <jim.hague@acm.org>
parents:
116
diff
changeset
|
110 xelatex $outputa4 |
38
01c4d873153f
Quick attempt to parameterise different book builds.
Jim Hague <jim.hague@laicatc.com>
parents:
37
diff
changeset
|
111 |
181
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
112 mv $outputpdf $dir/$1-A5.pdf |
6a0bdabfb255
Add a A4 portrait book with multiple tunes per page.
Jim Hague <jim.hague@acm.org>
parents:
122
diff
changeset
|
113 mv $outputa4pdf $dir/${1}-A5bookletA4.pdf |
21
b61b090cd4c7
Produce an A4 PDF document with the A5 pages in booklet form.
Jim Hague <jim.hague@acm.org>
parents:
16
diff
changeset
|
114 |
b61b090cd4c7
Produce an A4 PDF document with the A5 pages in booklet form.
Jim Hague <jim.hague@acm.org>
parents:
16
diff
changeset
|
115 cd $dir |