Mercurial > dottes
annotate makeWeb.sh @ 958:5efe424fbff6 build-default-348
Automated merge with ssh://hg.cryhavoc.org.uk/dottes
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Wed, 07 Aug 2019 08:21:26 +0100 |
parents | 0f4ba68d6059 |
children | 40b43075a421 |
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 | 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 | 21 basewebdir=$dir/web |
22 mastertunedir=tunes | |
23 basetunedir=$mastertunedir | |
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 |
0f4ba68d6059
Fix target generation for transposed booke web items.
Jim Hague <jim.hague@acm.org>
parents:
943
diff
changeset
|
34 basetunedir="${basetunedir}-${instrumentSuffix}" |
0f4ba68d6059
Fix target generation for transposed booke web items.
Jim Hague <jim.hague@acm.org>
parents:
943
diff
changeset
|
35 fi |
0f4ba68d6059
Fix target generation for transposed booke web items.
Jim Hague <jim.hague@acm.org>
parents:
943
diff
changeset
|
36 |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
37 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
|
38 # 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
|
39 buildno=${buildno%%%} |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
40 subtitle= |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
41 intro= |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
42 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
|
43 subtitle=`cat $bookedir/subtitle.txt` |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
44 fi |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
45 |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
46 if [ -n "$instrument" ]; then |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
47 title="${title} ($instrument)" |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
48 subtitle="${subtitle} ($instrument)" |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
49 fi |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
50 |
943 | 51 mkdir -p $bookewebdir |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
52 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
53 sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \ |
943 | 54 -e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" 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
|
55 |
01ded8741361
Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents:
359
diff
changeset
|
56 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
|
57 do |
943 | 58 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
|
59 if [ -r $bookedir/$item.md ]; then |
943 | 60 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
|
61 else |
943 | 62 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
|
63 fi |
01ded8741361
Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents:
359
diff
changeset
|
64 done |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
65 |
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
|
66 # 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
|
67 if [ -r $masterbookedir/htaccess ]; then |
943 | 68 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
|
69 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
|
70 |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
71 # 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
|
72 # to be already generated. |
943 | 73 cp $1-*.pdf $bookewebdir |
45
689026e2de0c
Web. Add download links for book.
Jim Hague <jim.hague@laicatc.com>
parents:
43
diff
changeset
|
74 |
382 | 75 # Now, for each tune, make the tune page. |
943 | 76 rm -f $bookewebdir/$tunelist |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
77 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
|
78 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
|
79 nofiles=${#filenames[@]} |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
80 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
|
81 do |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
82 filename=${filenames[$i]} |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
83 name=`basename $filename .abc` |
943 | 84 tunedir=$basetunedir/$name |
85 tunewebdir=$basewebdir/$tunedir | |
86 mkdir -p $tunewebdir | |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
87 |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
88 # Copy the ABC into the web. |
943 | 89 cp $filename $tunewebdir |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
90 |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
91 # Generate MusicXML into the web. |
943 | 92 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
|
93 |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
94 # 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
|
95 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
|
96 |
732
c81a1ed21877
Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents:
727
diff
changeset
|
97 # 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
|
98 prevarg="" |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
99 prevpage="" |
732
c81a1ed21877
Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents:
727
diff
changeset
|
100 nextarg="" |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
101 nextpage="" |
484
4fab69a1027d
Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents:
474
diff
changeset
|
102 |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
103 if [ $i -gt 0 ]; then |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
104 prev=${filenames[$((i - 1))]} |
943 | 105 prevpage=`basename $prev .abc` |
732
c81a1ed21877
Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents:
727
diff
changeset
|
106 prevarg="--prev $prev" |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
107 fi |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
108 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
|
109 next=${filenames[$((i + 1))]} |
943 | 110 nextpage=`basename $next .abc` |
732
c81a1ed21877
Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents:
727
diff
changeset
|
111 nextarg="--next $next" |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
112 fi |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
113 |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
114 # Generate the tune web page. |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
115 $dir/abctemplate.py \ |
943 | 116 --value "booke=${booke}" \ |
117 --value "mastertunedir=${mastertunedir}" \ | |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
118 --value "lastchanged=${lastchanged}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
119 --value "prevpage=${prevpage}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
120 --value "nextpage=${nextpage}" \ |
732
c81a1ed21877
Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents:
727
diff
changeset
|
121 ${prevarg} ${nextarg} \ |
c81a1ed21877
Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents:
727
diff
changeset
|
122 --template dottes.html.tune \ |
943 | 123 $filename > $tunewebdir/index.html |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
124 $dir/abctemplate.py \ |
943 | 125 --value "booke=${booke}" \ |
126 --value "mastertunedir=${mastertunedir}" \ | |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
127 --value "lastchanged=${lastchanged}" \ |
732
c81a1ed21877
Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents:
727
diff
changeset
|
128 --value "prevpage=${prevpage}" \ |
c81a1ed21877
Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents:
727
diff
changeset
|
129 --value "nextpage=${nextpage}" \ |
c81a1ed21877
Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents:
727
diff
changeset
|
130 ${prevarg} ${nextarg} \ |
c81a1ed21877
Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents:
727
diff
changeset
|
131 --template dottes.html.learnertune \ |
943 | 132 $filename > $tunewebdir/learner.html |
133 $dir/abctemplate.py \ | |
134 --value "tunedir=${tunedir}" \ | |
135 --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
|
136 done |