Mercurial > dottes
annotate makeWeb.sh @ 722:f8ab14cc9d8d build-default-281
Add previous and next tune links to website.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Tue, 10 Oct 2017 15:01:22 +0100 |
parents | 4e92928fcfc2 |
children | 772402f5f8ea |
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 |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
21 webdir=$dir/web/$1 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
22 graphicsdir=$dir/graphics/$1 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
23 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
|
24 tunelist=tunelist.html |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
25 title=$booke |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
26 instrument=$3 |
484
4fab69a1027d
Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents:
474
diff
changeset
|
27 abc2xml=$dir/abc2xml/abc2xml.py |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
28 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
29 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
|
30 # 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
|
31 buildno=${buildno%%%} |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
32 subtitle= |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
33 intro= |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
34 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
|
35 subtitle=`cat $bookedir/subtitle.txt` |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
36 fi |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
37 |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
38 if [ -n "$instrument" ]; then |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
39 title="${title} ($instrument)" |
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
40 subtitle="${subtitle} ($instrument)" |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
41 fi |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
42 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
43 mkdir -p $webdir |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
44 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
45 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
|
46 -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
|
47 |
01ded8741361
Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents:
359
diff
changeset
|
48 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
|
49 do |
01ded8741361
Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents:
359
diff
changeset
|
50 rm -f $webdir/$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
|
51 if [ -r $bookedir/$item.md ]; then |
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
|
52 pandoc --from=markdown --to=html --output=$webdir/$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
|
53 else |
01ded8741361
Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents:
359
diff
changeset
|
54 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
|
55 fi |
01ded8741361
Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents:
359
diff
changeset
|
56 done |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
57 |
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
|
58 # 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
|
59 if [ -r $masterbookedir/htaccess ]; then |
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
|
60 cp $masterbookedir/htaccess $webdir/.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
|
61 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
|
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 | 67 # Now, for each tune, make the tune page. |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
68 rm -f $webdir/$tunelist |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
69 declare -a filenames |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
70 filenames=(`find $bookedir -name "*.abc" | sort`) |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
71 nofiles=${#filenames[@]} |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
72 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
|
73 do |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
74 filename=${filenames[$i]} |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
75 name=`basename $filename .abc` |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
76 |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
77 # Copy the ABC into the web. |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
78 cp $filename $webdir |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
79 |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
80 # Generate MusicXML into the web. |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
81 python $abc2xml $filename > ${webdir}/${name}.xml |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
82 |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
83 # If we are not the master booke, link the mp3s in from the |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
84 # master page in a desperate attempt to make IE8 work. |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
85 # The Jenkins archive will dereference the soft link, it seems, |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
86 # but I guess I can live with copies of the MP3 for now. |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
87 if [ "$booke" != "$masterbooke" ]; then |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
88 pushd ${webdir} > /dev/null |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
89 ln -f -s ../${masterbooke}/*${name}.mp3 . |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
90 popd > /dev/null |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
91 fi |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
92 |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
93 # 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
|
94 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
|
95 |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
96 # Get previous and next tune page names and titles. |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
97 prevpage="" |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
98 prevtitle="" |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
99 nextpage="" |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
100 nexttitle="" |
484
4fab69a1027d
Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents:
474
diff
changeset
|
101 |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
102 if [ $i -gt 0 ]; then |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
103 prev=${filenames[$((i - 1))]} |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
104 prevpage=`basename $prev .abc`.html |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
105 prevtitle=`./abcfield.py --display --field="T" $prev` |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
106 fi |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
107 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
|
108 next=${filenames[$((i + 1))]} |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
109 nextpage=`basename $next .abc`.html |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
110 nexttitle=`./abcfield.py --display --field="T" $next` |
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 |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
113 # Generate the tune web page. |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
114 tunepage=${name}.html |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
115 learnerpage=learner-${name}.html |
382 | 116 |
722
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
117 $dir/abctemplate.py \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
118 --value "masterbooke=${masterbooke}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
119 --value "lastchanged=${lastchanged}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
120 --value "prevpage=${prevpage}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
121 --value "prevtitle=${prevtitle}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
122 --value "nextpage=${nextpage}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
123 --value "nexttitle=${nexttitle}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
124 --template dottes.html.tune $filename > $webdir/$tunepage |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
125 $dir/abctemplate.py \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
126 --value "masterbooke=${masterbooke}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
127 --value "lastchanged=${lastchanged}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
128 --value "prevpage=learner-${prevpage}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
129 --value "prevtitle=${prevtitle}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
130 --value "nextpage=learner-${nextpage}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
131 --value "nexttitle=${nexttitle}" \ |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
132 --template dottes.html.learnertune $filename > $webdir/$learnerpage |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
133 $dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist |
f8ab14cc9d8d
Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents:
651
diff
changeset
|
134 done |