annotate makeWeb.sh @ 1015:50086890a50c build-default-367

Sue reckons Nonesuch is a different tune. In Playford, anyway.
author Jim Hague <jim.hague@acm.org>
date Sat, 21 Dec 2019 20:33:37 +0000
parents 40b43075a421
children 18f0e45207ef
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
484
4fab69a1027d Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents: 474
diff changeset
4 # to be already built. This generates the MusicXML and the page HTML
4fab69a1027d Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents: 474
diff changeset
5 # and shuffles other files ino the right place.
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
6 #
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
7
238
8bea9fdeba40 Revert tracing change than slipped into the archive.
Jim Hague <jim.hague@laicatc.com>
parents: 237
diff changeset
8 #set -x
229
1e4443d58177 Modify Change tune handling.
Jim Hague <jim.hague@acm.org>
parents: 223
diff changeset
9
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
10 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
11 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
12 exit 1
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
13 fi
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
14
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
15 dir=`pwd`
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
16
504
4cc739fe13ab Fix last changed item on web pages for transposed instruments.
Jim Hague <jim.hague@acm.org>
parents: 496
diff changeset
17 booke=$1
4cc739fe13ab Fix last changed item on web pages for transposed instruments.
Jim Hague <jim.hague@acm.org>
parents: 496
diff changeset
18 masterbooke=$2
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
19 bookedir=$dir/$1
504
4cc739fe13ab Fix last changed item on web pages for transposed instruments.
Jim Hague <jim.hague@acm.org>
parents: 496
diff changeset
20 masterbookedir=$dir/$2
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
21 basewebdir=$dir/web
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
22 mastertunedir=tunes
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
23 basetunedir=$mastertunedir
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
24 bookewebdir=$dir/web/$1
43
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
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
28 title=$booke
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
29 instrument=$3
484
4fab69a1027d Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents: 474
diff changeset
30 abc2xml=$dir/abc2xml/abc2xml.py
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
31
946
0f4ba68d6059 Fix target generation for transposed booke web items.
Jim Hague <jim.hague@acm.org>
parents: 943
diff changeset
32 instrumentSuffix="${1##*-}"
0f4ba68d6059 Fix target generation for transposed booke web items.
Jim Hague <jim.hague@acm.org>
parents: 943
diff changeset
33 if [ "$1" != "$instrumentSuffix" ]; then
970
40b43075a421 Add web links to the Bumper Booke.
Jim Hague <jim.hague@acm.org>
parents: 946
diff changeset
34 instrumentSuffix="-${instrumentSuffix}"
40b43075a421 Add web links to the Bumper Booke.
Jim Hague <jim.hague@acm.org>
parents: 946
diff changeset
35 basetunedir="${basetunedir}${instrumentSuffix}"
40b43075a421 Add web links to the Bumper Booke.
Jim Hague <jim.hague@acm.org>
parents: 946
diff changeset
36 else
40b43075a421 Add web links to the Bumper Booke.
Jim Hague <jim.hague@acm.org>
parents: 946
diff changeset
37 instrumentSuffix=""
946
0f4ba68d6059 Fix target generation for transposed booke web items.
Jim Hague <jim.hague@acm.org>
parents: 943
diff changeset
38 fi
0f4ba68d6059 Fix target generation for transposed booke web items.
Jim Hague <jim.hague@acm.org>
parents: 943
diff changeset
39
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
40 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
41 # 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
42 buildno=${buildno%%%}
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
43 subtitle=
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
44 intro=
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
45 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
46 subtitle=`cat $bookedir/subtitle.txt`
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
47 fi
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
48
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
49 if [ -n "$instrument" ]; then
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
50 title="${title} ($instrument)"
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
51 subtitle="${subtitle} ($instrument)"
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
52 fi
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
53
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
54 mkdir -p $bookewebdir
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
55
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
56 sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \
970
40b43075a421 Add web links to the Bumper Booke.
Jim Hague <jim.hague@acm.org>
parents: 946
diff changeset
57 -e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" \
40b43075a421 Add web links to the Bumper Booke.
Jim Hague <jim.hague@acm.org>
parents: 946
diff changeset
58 -e "s/@INSTRUMENT@/$instrumentSuffix/" dottes.html > $bookewebdir/$output
360
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
59
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
60 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
61 do
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
62 rm -f $bookewebdir/$item.html
651
4e92928fcfc2 Enable a tune book to have a htaccess file, copied to .htaccess in web.
Jim Hague <jim.hague@acm.org>
parents: 588
diff changeset
63 if [ -r $bookedir/$item.md ]; then
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
64 pandoc --from=markdown --to=html --output=$bookewebdir/$item.html $bookedir/$item.md
360
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
65 else
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
66 touch $bookewebdir/$item.html
360
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
67 fi
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
68 done
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
69
651
4e92928fcfc2 Enable a tune book to have a htaccess file, copied to .htaccess in web.
Jim Hague <jim.hague@acm.org>
parents: 588
diff changeset
70 # Copy in any htaccess.
4e92928fcfc2 Enable a tune book to have a htaccess file, copied to .htaccess in web.
Jim Hague <jim.hague@acm.org>
parents: 588
diff changeset
71 if [ -r $masterbookedir/htaccess ]; then
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
72 cp $masterbookedir/htaccess $bookewebdir/.htaccess
651
4e92928fcfc2 Enable a tune book to have a htaccess file, copied to .htaccess in web.
Jim Hague <jim.hague@acm.org>
parents: 588
diff changeset
73 fi
4e92928fcfc2 Enable a tune book to have a htaccess file, copied to .htaccess in web.
Jim Hague <jim.hague@acm.org>
parents: 588
diff changeset
74
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
75 # 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
76 # to be already generated.
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
77 cp $1-*.pdf $bookewebdir
45
689026e2de0c Web. Add download links for book.
Jim Hague <jim.hague@laicatc.com>
parents: 43
diff changeset
78
382
04bd083eed29 Ratchet up the IE8 attempt.
Jim Hague <jim.hague@acm.org>
parents: 366
diff changeset
79 # Now, for each tune, make the tune page.
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
80 rm -f $bookewebdir/$tunelist
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
81 declare -a filenames
753
b83b49f2a0a0 Correct Mac-ism. find -maxdepth n, not find -depth n.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
82 filenames=(`find $bookedir -maxdepth 1 -name "*.abc" | sort`)
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
83 nofiles=${#filenames[@]}
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
84 for (( i=0; i < ${nofiles}; i++ ))
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
85 do
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
86 filename=${filenames[$i]}
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
87 name=`basename $filename .abc`
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
88 tunedir=$basetunedir/$name
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
89 tunewebdir=$basewebdir/$tunedir
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
90 mkdir -p $tunewebdir
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
91
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
92 # Copy the ABC into the web.
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
93 cp $filename $tunewebdir
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
94
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
95 # Generate MusicXML into the web.
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
96 python $abc2xml $filename > ${tunewebdir}/${name}.xml
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
97
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
98 # Get date and time of last change to tune.
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
99 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc`
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
100
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
101 # Get previous and next tunes, if available.
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
102 prevarg=""
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
103 prevpage=""
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
104 nextarg=""
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
105 nextpage=""
484
4fab69a1027d Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents: 474
diff changeset
106
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
107 if [ $i -gt 0 ]; then
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
108 prev=${filenames[$((i - 1))]}
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
109 prevpage=`basename $prev .abc`
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
110 prevarg="--prev $prev"
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
111 fi
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
112 if [ $i -lt $((nofiles - 1)) ]; then
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
113 next=${filenames[$((i + 1))]}
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
114 nextpage=`basename $next .abc`
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
115 nextarg="--next $next"
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
116 fi
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
117
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
118 # Generate the tune web page.
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
119 $dir/abctemplate.py \
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
120 --value "booke=${booke}" \
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
121 --value "mastertunedir=${mastertunedir}" \
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
122 --value "lastchanged=${lastchanged}" \
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
123 --value "prevpage=${prevpage}" \
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
124 --value "nextpage=${nextpage}" \
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
125 ${prevarg} ${nextarg} \
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
126 --template dottes.html.tune \
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
127 $filename > $tunewebdir/index.html
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
128 $dir/abctemplate.py \
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
129 --value "booke=${booke}" \
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
130 --value "mastertunedir=${mastertunedir}" \
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
131 --value "lastchanged=${lastchanged}" \
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
132 --value "prevpage=${prevpage}" \
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
133 --value "nextpage=${nextpage}" \
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
134 ${prevarg} ${nextarg} \
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
135 --template dottes.html.learnertune \
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
136 $filename > $tunewebdir/learner.html
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
137 $dir/abctemplate.py \
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
138 --value "tunedir=${tunedir}" \
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
139 --template dottes.html.tuneindex $filename >> $bookewebdir/$tunelist
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
140 done