annotate makeWeb.sh @ 291:1f5eada75f10

Add timing to Caddam Wood.
author Jim Hague <jim.hague@acm.org>
date Fri, 05 Jul 2013 20:19:53 +0100
parents 8bea9fdeba40
children 07e9fa311c6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
8
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
9 # Restore titles like 'Exploding Potato, The' to the
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
10 # expected 'The Exploding Potato'.
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
11 fixtitle()
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
12 {
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
13 retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
14 }
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
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`
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
33 subtitle=
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
34 intro=
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
35 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
36 subtitle=`cat $bookedir/subtitle.txt`
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
37 fi
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
38 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
39 intro=`cat $bookedir/intro.txt`
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
40 fi
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
41
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
42 if [ -n "$instrument" ]; then
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
43 title="${title} ($instrument)"
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
44 subtitle="${subtitle} ($instrument)"
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
45 fi
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
46
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
47 mkdir -p $webdir
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 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
50 -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
51 -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
52
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
53 # 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
54 # 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
55 cp $1-*.pdf $webdir
45
689026e2de0c Web. Add download links for book.
Jim Hague <jim.hague@laicatc.com>
parents: 43
diff changeset
56
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
57 # 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
58 find $bookedir -name "*.abc" | sort |
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
59 while read filename
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
60 do
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
61 name=`basename $filename .abc`
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
62
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
63 title=`$dir/abcfield.py --field T --html $filename`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
64 fixtitle "$title"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
65 title=$retval
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
66 changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
67 changetitle=""
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
68 changevisibility="no"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
69 if [ -n "$changefile" ]; then
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
70 changetitle=`$dir/abcfield.py --field T --html $bookedir/$changefile`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
71 changevisibility="yes"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
72
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
73 fixtitle "$changetitle"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
74 changetitle=$retval
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
75 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
76
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
77 # Copy tune PDF from common graphics.
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
78 cp $graphicsdir/${name}.pdf $webdir
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
79
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
80 # And copy the ABC.
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
81 cp $filename $webdir
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
82
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
83 # Generate the tune web page.
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
84 tunepage=${name}.html
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
85
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
86 # 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
87 # 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
88 sed -e "s/@TITLE@/${title//&/\&}/" \
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
89 -e "s/@MASTERBOOKE@/${masterbooke}/" \
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
90 -e "s/@CHANGETITLE@/${changetitle//&/\&}/" \
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
91 -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
92 -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
93 -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
94
202
540511b14c73 Handle '&' appearing in HTML output from tune titles.
Jim Hague <jim.hague@acm.org>
parents: 199
diff changeset
95 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
96 -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
97 done
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
98
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
99 cat dottes.html.footer >> $webdir/$output