annotate makeWeb.sh @ 382:04bd083eed29

Ratchet up the IE8 attempt. Thanks to http://www.yourwebskills.com/htmlobject.php.
author Jim Hague <jim.hague@acm.org>
date Fri, 30 Aug 2013 23:55:22 +0100
parents 5628fcd6c692
children ce5dccdd45bd
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
360
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
27 tunelist=tunelist.html
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
28 booke=$1
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
29 masterbooke=$2
382
04bd083eed29 Ratchet up the IE8 attempt.
Jim Hague <jim.hague@acm.org>
parents: 366
diff changeset
30 masterwebdir=$dir/web/$2
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
31 title=$booke
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
32 instrument=$3
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
33
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
34 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
35 # 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
36 buildno=${buildno%%%}
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
37 subtitle=
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
38 intro=
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
39 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
40 subtitle=`cat $bookedir/subtitle.txt`
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
41 fi
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
42
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
43 if [ -n "$instrument" ]; then
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
44 title="${title} ($instrument)"
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
45 subtitle="${subtitle} ($instrument)"
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
46 fi
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
47
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
48 mkdir -p $webdir
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
49
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
50 sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \
360
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
51 -e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" dottes.html > $webdir/$output
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
52
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
53 for item in intro
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
54 do
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
55 rm -f $webdir/$item.html
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
56 if [ -r $booke/$item.txt ]; then
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
57 txt2tags --no-headers --target=html --outfile=$webdir/$item.html $booke/$item.txt
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
58 else
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
59 touch $webdir/$item.html
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
60 fi
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
61 done
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
62
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
63 # 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
64 # 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
65 cp $1-*.pdf $webdir
45
689026e2de0c Web. Add download links for book.
Jim Hague <jim.hague@laicatc.com>
parents: 43
diff changeset
66
382
04bd083eed29 Ratchet up the IE8 attempt.
Jim Hague <jim.hague@acm.org>
parents: 366
diff changeset
67 # Now, for each tune, make the tune page.
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
68 find $bookedir -name "*.abc" | sort |
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
69 while read filename
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
70 do
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
71 name=`basename $filename .abc`
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
72
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
73 title=`$dir/abcfield.py --field T --html $filename`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
74 fixtitle "$title"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
75 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
76 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
77 composer=`$dir/abcfield.py --field C --latex $filename`
326
27f29e8aafea Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents: 321
diff changeset
78 changefile=`$dir/abcfield.py --field N --contains "Change:" $filename | sed -e "s/Change: *//"`
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
79 changetitle=""
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
80 changevisibility="no"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
81 if [ -n "$changefile" ]; then
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
82 changetitle=`$dir/abcfield.py --field T --html $bookedir/$changefile`
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
83 changevisibility="yes"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
84
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
85 fixtitle "$changetitle"
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
86 changetitle=$retval
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
87 fi
326
27f29e8aafea Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents: 321
diff changeset
88 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: 321
diff changeset
89 creditvisibility="no"
27f29e8aafea Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents: 321
diff changeset
90 if [ -n "$credit" ]; then
27f29e8aafea Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents: 321
diff changeset
91 creditvisibility="yes"
27f29e8aafea Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents: 321
diff changeset
92 fi
355
b233893b4c51 Add date of last change to bottom of web tune page.
Jim Hague <jim.hague@acm.org>
parents: 326
diff changeset
93 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $filename`
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
94
321
b61c39beac5f Generate different tune PDF for web site download.
Jim Hague <jim.hague@acm.org>
parents: 319
diff changeset
95 # Copy the ABC into the web.
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
96 cp $filename $webdir
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
97
382
04bd083eed29 Ratchet up the IE8 attempt.
Jim Hague <jim.hague@acm.org>
parents: 366
diff changeset
98 # If we are not the master booke, link the mp3 in from the
04bd083eed29 Ratchet up the IE8 attempt.
Jim Hague <jim.hague@acm.org>
parents: 366
diff changeset
99 # master page in a desperate attempt to make IE8 work.
04bd083eed29 Ratchet up the IE8 attempt.
Jim Hague <jim.hague@acm.org>
parents: 366
diff changeset
100 if [ "$booke" != "$masterbooke" ]; then
04bd083eed29 Ratchet up the IE8 attempt.
Jim Hague <jim.hague@acm.org>
parents: 366
diff changeset
101 ln -s -r ${masterwebdir}/${name}.mp3 ${webdir}
04bd083eed29 Ratchet up the IE8 attempt.
Jim Hague <jim.hague@acm.org>
parents: 366
diff changeset
102 fi
04bd083eed29 Ratchet up the IE8 attempt.
Jim Hague <jim.hague@acm.org>
parents: 366
diff changeset
103
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
104 # Generate the tune web page.
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
105 tunepage=${name}.html
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
106
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
107 # 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
108 # 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
109 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
110 -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
111 -e "s/@COMPOSER@/${composer}/" \
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
112 -e "s/@MASTERBOOKE@/${masterbooke}/" \
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
113 -e "s/@CHANGETITLE@/${changetitle//&/\&}/" \
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
114 -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
115 -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \
326
27f29e8aafea Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents: 321
diff changeset
116 -e "s/@CREDIT@/${credit}/" \
27f29e8aafea Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents: 321
diff changeset
117 -e "s/@CREDITVISIBILITY@/${creditvisibility}/" \
355
b233893b4c51 Add date of last change to bottom of web tune page.
Jim Hague <jim.hague@acm.org>
parents: 326
diff changeset
118 -e "s/@LASTCHANGED@/${lastchanged}/" \
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
119 -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
120
202
540511b14c73 Handle '&' appearing in HTML output from tune titles.
Jim Hague <jim.hague@acm.org>
parents: 199
diff changeset
121 sed -e "s/@TITLE@/${title//&/\&}/" \
360
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
122 -e "s/@TUNE@/${name}/" dottes.html.tuneindex >> $webdir/$tunelist
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
123 done