comparison makeWeb.sh @ 400:f1c4abe4fc75 build-default-175

First go at adding the tune learner page.
author Jim Hague <jim.hague@acm.org>
date Mon, 02 Sep 2013 11:48:16 +0100
parents e09ff88ab469
children f7dbde7c9661
comparison
equal deleted inserted replaced
399:aeef7b1ca0ad 400:f1c4abe4fc75
9 # Restore titles like 'Exploding Potato, The' to the 9 # Restore titles like 'Exploding Potato, The' to the
10 # expected 'The Exploding Potato'. 10 # expected 'The Exploding Potato'.
11 fixtitle() 11 fixtitle()
12 { 12 {
13 retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"` 13 retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"`
14 }
15
16 # Format a key in ABC (G, Gmin, etc.) in standard presentation format.
17 fixkey()
18 {
19 letter=${1:0:1}
20 accidental=${1:1:1}
21 if [ "$accidental" != "#" -a "$accidental" != "b" ]; then
22 accidental=""
23 mode=${1:1:3}
24 else
25 mode=${1:2:3}
26 fi
27 mode=${mode,,}
28 mode=${mode/ //g}
29 if [ "$mode" = "m" -o "$mode" = "min" ]; then
30 mode="Minor"
31 elif [ "$mode" = "mix" ]; then
32 mode="Mixolydian"
33 elif [ "$mode" = "dor" ]; then
34 mode="Dorian"
35 elif [ "$mode" = "phr" ]; then
36 mode="Phrygian"
37 elif [ "$mode" = "lyd" ]; then
38 mode="Lydian"
39 elif [ "$mode" = "loc" ]; then
40 mode="Locrian"
41 else
42 mode="Major"
43 fi
44 retval="${letter}${accidental} ${mode}"
14 } 45 }
15 46
16 if [ $# -lt 2 -o $# -gt 3 ]; then 47 if [ $# -lt 2 -o $# -gt 3 ]; then
17 echo "Usage: makeWeb.sh <book dir name> <master book dir name> [<instrument name>]" 48 echo "Usage: makeWeb.sh <book dir name> <master book dir name> [<instrument name>]"
18 exit 1 49 exit 1
62 # Copy in the book PDFs. Like the graphics, Midi etc. these are assumed 93 # Copy in the book PDFs. Like the graphics, Midi etc. these are assumed
63 # to be already generated. 94 # to be already generated.
64 cp $1-*.pdf $webdir 95 cp $1-*.pdf $webdir
65 96
66 # Now, for each tune, make the tune page. 97 # Now, for each tune, make the tune page.
98 rm -f $webdir/$tunelist
67 find $bookedir -name "*.abc" | sort | 99 find $bookedir -name "*.abc" | sort |
68 while read filename 100 while read filename
69 do 101 do
70 name=`basename $filename .abc` 102 name=`basename $filename .abc`
71 103
88 creditvisibility="no" 120 creditvisibility="no"
89 if [ -n "$credit" ]; then 121 if [ -n "$credit" ]; then
90 creditvisibility="yes" 122 creditvisibility="yes"
91 fi 123 fi
92 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $filename` 124 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $filename`
125 key=`$dir/abcfield.py --field K $filename`
126 fixkey $key
127 key=$retval
93 128
94 # Copy the ABC into the web. 129 # Copy the ABC into the web.
95 cp $filename $webdir 130 cp $filename $webdir
96 131
97 # If we are not the master booke, link the mp3 in from the 132 # If we are not the master booke, link the mp3s in from the
98 # master page in a desperate attempt to make IE8 work. 133 # master page in a desperate attempt to make IE8 work.
99 # The Jenkins archive will dereference the soft link, it seems, 134 # The Jenkins archive will dereference the soft link, it seems,
100 # but I guess I can live with copies of the MP3 for now. 135 # but I guess I can live with copies of the MP3 for now.
101 if [ "$booke" != "$masterbooke" ]; then 136 if [ "$booke" != "$masterbooke" ]; then
102 pushd ${webdir} > /dev/null 137 pushd ${webdir} > /dev/null
103 ln -f -s ../${masterbooke}/${name}.mp3 138 ln -f -s ../${masterbooke}/*${name}.mp3
104 popd > /dev/null 139 popd > /dev/null
105 fi 140 fi
106 141
107 # Generate the tune web page. 142 # Generate the tune web page.
108 tunepage=${name}.html 143 tunepage=${name}.html
144 learnerpage=learner-${name}.html
109 145
110 # If the title contains HTML character entities, escape 146 # If the title contains HTML character entities, escape
111 # initial '&' in the title - it means things to sed. 147 # initial '&' in the title - it means things to sed.
112 sed -e "s/@TITLE@/${title//&/\&}/" \ 148 sed -e "s/@TITLE@/${title//&/\&}/" \
113 -e "s/@SUBTITLE@/${subtitle}/" \ 149 -e "s/@SUBTITLE@/${subtitle}/" \
114 -e "s/@COMPOSER@/${composer}/" \ 150 -e "s/@COMPOSER@/${composer}/" \
151 -e "s/@KEY@/${key}/" \
115 -e "s/@MASTERBOOKE@/${masterbooke}/" \ 152 -e "s/@MASTERBOOKE@/${masterbooke}/" \
116 -e "s/@CHANGETITLE@/${changetitle//&/\&}/" \ 153 -e "s/@CHANGETITLE@/${changetitle//&/\&}/" \
117 -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \ 154 -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \
118 -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \ 155 -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \
119 -e "s/@CREDIT@/${credit}/" \ 156 -e "s/@CREDIT@/${credit}/" \
120 -e "s/@CREDITVISIBILITY@/${creditvisibility}/" \ 157 -e "s/@CREDITVISIBILITY@/${creditvisibility}/" \
121 -e "s/@LASTCHANGED@/${lastchanged}/" \ 158 -e "s/@LASTCHANGED@/${lastchanged}/" \
122 -e "s/@TUNE@/${name}/" dottes.html.tune > $webdir/$tunepage 159 -e "s/@TUNE@/${name}/" dottes.html.tune > $webdir/$tunepage
123 160
124 sed -e "s/@TITLE@/${title//&/\&}/" \ 161 sed -e "s/@TITLE@/${title//&/\&}/" \
162 -e "s/@SUBTITLE@/${subtitle}/" \
163 -e "s/@COMPOSER@/${composer}/" \
164 -e "s/@KEY@/${key}/" \
165 -e "s/@MASTERBOOKE@/${masterbooke}/" \
166 -e "s/@CHANGETITLE@/${changetitle//&/\&}/" \
167 -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \
168 -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \
169 -e "s/@CREDIT@/${credit}/" \
170 -e "s/@CREDITVISIBILITY@/${creditvisibility}/" \
171 -e "s/@LASTCHANGED@/${lastchanged}/" \
172 -e "s/@TUNE@/${name}/" dottes.html.learnertune > $webdir/$learnerpage
173
174 sed -e "s/@TITLE@/${title//&/\&}/" \
125 -e "s/@TUNE@/${name}/" dottes.html.tuneindex >> $webdir/$tunelist 175 -e "s/@TUNE@/${name}/" dottes.html.tuneindex >> $webdir/$tunelist
126 done 176 done