Mercurial > dottes
annotate makeWeb.sh @ 319:cbe9c10b5a3e
Render tune title, subtitle and composer in Latex/HTML and not in the image.
This way the titles remains a constant size even if the image needs to be scaled.
And we have that text appearance under our control.
I can't find a way of switching off the tune title in abcm2ps, and have worked around
by setting the title format to Y0. Y is not a defined ABC header and is not found in
any Dottes tune.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Tue, 16 Jul 2013 16:35:07 +0100 |
parents | 07e9fa311c6f |
children | b61c39beac5f |
rev | line source |
---|---|
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
1 #!/bin/bash |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
2 # |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
3 # Build the website. The common items and the web items are assumed |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
4 # to be already built. |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
5 # |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
6 |
238
8bea9fdeba40
Revert tracing change than slipped into the archive.
Jim Hague <jim.hague@laicatc.com>
parents:
237
diff
changeset
|
7 #set -x |
229 | 8 |
9 # Restore titles like 'Exploding Potato, The' to the | |
10 # expected 'The Exploding Potato'. | |
11 fixtitle() | |
12 { | |
13 retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"` | |
14 } | |
15 | |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
16 if [ $# -lt 2 -o $# -gt 3 ]; then |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
17 echo "Usage: makeWeb.sh <book dir name> <master book dir name> [<instrument name>]" |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
18 exit 1 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
19 fi |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
20 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
21 dir=`pwd` |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
22 |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
23 bookedir=$dir/$1 |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
24 webdir=$dir/web/$1 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
25 graphicsdir=$dir/graphics/$1 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
26 output=index.html |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
27 booke=$1 |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
28 masterbooke=$2 |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
29 title=$booke |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
30 instrument=$3 |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
31 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
32 buildno=`cat buildno.txt` |
309
07e9fa311c6f
% added to buildno.txt needs to be removed for web.
Jim Hague <jim.hague@acm.org>
parents:
238
diff
changeset
|
33 # Remove trailing % added for Latex purposes. |
07e9fa311c6f
% added to buildno.txt needs to be removed for web.
Jim Hague <jim.hague@acm.org>
parents:
238
diff
changeset
|
34 buildno=${buildno%%%} |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
35 subtitle= |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
36 intro= |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
37 if [ -r $bookedir/subtitle.txt ]; then |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
38 subtitle=`cat $bookedir/subtitle.txt` |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
39 fi |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
40 if [ -r $bookedir/intro.txt ]; then |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
41 intro=`cat $bookedir/intro.txt` |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
42 fi |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
43 |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
44 if [ -n "$instrument" ]; then |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
45 title="${title} ($instrument)" |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
46 subtitle="${subtitle} ($instrument)" |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
47 fi |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
48 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
49 mkdir -p $webdir |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
50 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
51 sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \ |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
52 -e "s/@TITLE@/$title/" -e "s/@INTRO@/$intro/" \ |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
53 -e "s/@BOOK@/$booke/" dottes.html.header > $webdir/$output |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
54 |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
55 # Copy in the book PDFs. Like the graphics, Midi etc. these are assumed |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
56 # to be already generated. |
199
b8d18ccdc6e4
Fix up typo from last commit of this file.
Jim Hague <jim.hague@acm.org>
parents:
197
diff
changeset
|
57 cp $1-*.pdf $webdir |
45
689026e2de0c
Web. Add download links for book.
Jim Hague <jim.hague@laicatc.com>
parents:
43
diff
changeset
|
58 |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
59 # Now, for each tune, make the tune graphic and sound. |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
60 find $bookedir -name "*.abc" | sort | |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
61 while read filename |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
62 do |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
63 name=`basename $filename .abc` |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
64 |
229 | 65 title=`$dir/abcfield.py --field T --html $filename` |
66 fixtitle "$title" | |
67 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:
309
diff
changeset
|
68 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:
309
diff
changeset
|
69 composer=`$dir/abcfield.py --field C --latex $filename` |
229 | 70 changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"` |
71 changetitle="" | |
72 changevisibility="no" | |
73 if [ -n "$changefile" ]; then | |
74 changetitle=`$dir/abcfield.py --field T --html $bookedir/$changefile` | |
75 changevisibility="yes" | |
76 | |
77 fixtitle "$changetitle" | |
78 changetitle=$retval | |
79 fi | |
212
9502f4883006
When listing titles for web, straighten out ones of the form 'Something, The'.
Jim Hague <jim.hague@laicatc.com>
parents:
202
diff
changeset
|
80 |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
81 # Copy tune PDF from common graphics. |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
82 cp $graphicsdir/${name}.pdf $webdir |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
83 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
84 # And copy the ABC. |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
85 cp $filename $webdir |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
86 |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
87 # Generate the tune web page. |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
88 tunepage=${name}.html |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
89 |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
90 # If the title contains HTML character entities, escape |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
91 # initial '&' in the title - it means things to sed. |
202
540511b14c73
Handle '&' appearing in HTML output from tune titles.
Jim Hague <jim.hague@acm.org>
parents:
199
diff
changeset
|
92 sed -e "s/@TITLE@/${title//&/\&}/" \ |
319
cbe9c10b5a3e
Render tune title, subtitle and composer in Latex/HTML and not in the image.
Jim Hague <jim.hague@acm.org>
parents:
309
diff
changeset
|
93 -e "s/@SUBTITLE@/${subtitle}/" \ |
cbe9c10b5a3e
Render tune title, subtitle and composer in Latex/HTML and not in the image.
Jim Hague <jim.hague@acm.org>
parents:
309
diff
changeset
|
94 -e "s/@COMPOSER@/${composer}/" \ |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
95 -e "s/@MASTERBOOKE@/${masterbooke}/" \ |
229 | 96 -e "s/@CHANGETITLE@/${changetitle//&/\&}/" \ |
97 -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \ | |
98 -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \ | |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
99 -e "s/@TUNE@/${name}/" dottes.html.tune > $webdir/$tunepage |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
100 |
202
540511b14c73
Handle '&' appearing in HTML output from tune titles.
Jim Hague <jim.hague@acm.org>
parents:
199
diff
changeset
|
101 sed -e "s/@TITLE@/${title//&/\&}/" \ |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
102 -e "s/@TUNE@/${name}/" dottes.html.tuneindex >> $webdir/$output |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
103 done |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
104 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
105 cat dottes.html.footer >> $webdir/$output |