Mercurial > dottes
annotate makeWeb.sh @ 587:1b79867b4f35
Convert remaining Python to Python3 and add +: support.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Mon, 31 Oct 2016 23:55:28 +0000 |
parents | daa3b76bd11f |
children | afc031477784 |
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 |
582
0206ab9fd6ba
Switch from txt2tags to using pandoc with Markdown (Pandoc flavour) input.
Jim Hague <jim.hague@acm.org>
parents:
581
diff
changeset
|
51 if [ -r $booke/$item.md ]; then |
0206ab9fd6ba
Switch from txt2tags to using pandoc with Markdown (Pandoc flavour) input.
Jim Hague <jim.hague@acm.org>
parents:
581
diff
changeset
|
52 pandoc --from=markdown --to=html --output=$webdir/$item.html $booke/$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 |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
58 # 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
|
59 # 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
|
60 cp $1-*.pdf $webdir |
45
689026e2de0c
Web. Add download links for book.
Jim Hague <jim.hague@laicatc.com>
parents:
43
diff
changeset
|
61 |
382 | 62 # 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
|
63 rm -f $webdir/$tunelist |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
64 find $bookedir -name "*.abc" | sort | |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
65 while read filename |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
66 do |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
67 name=`basename $filename .abc` |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
68 |
484
4fab69a1027d
Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents:
474
diff
changeset
|
69 # Extract items to substitute in the web page. |
586
daa3b76bd11f
More abcfield.py updates and mark it Python 3.
Jim Hague <jim.hague@acm.org>
parents:
582
diff
changeset
|
70 title=`$dir/abcfield.py --field T --display $filename` |
daa3b76bd11f
More abcfield.py updates and mark it Python 3.
Jim Hague <jim.hague@acm.org>
parents:
582
diff
changeset
|
71 subtitle=`$dir/abcfield.py --index 2 --field T --display $filename` |
581
760d0ae5acea
Revise abcfield.py to recognise continuation fields.
Jim Hague <jim.hague@acm.org>
parents:
533
diff
changeset
|
72 composer=`$dir/abcfield.py --field C $filename` |
760d0ae5acea
Revise abcfield.py to recognise continuation fields.
Jim Hague <jim.hague@acm.org>
parents:
533
diff
changeset
|
73 changefile=`$dir/abcfield.py --field N --starts "Change:" $filename` |
229 | 74 changetitle="" |
75 changevisibility="no" | |
76 if [ -n "$changefile" ]; then | |
586
daa3b76bd11f
More abcfield.py updates and mark it Python 3.
Jim Hague <jim.hague@acm.org>
parents:
582
diff
changeset
|
77 changetitle=`$dir/abcfield.py --field T --display $bookedir/$changefile` |
229 | 78 changevisibility="yes" |
79 fi | |
581
760d0ae5acea
Revise abcfield.py to recognise continuation fields.
Jim Hague <jim.hague@acm.org>
parents:
533
diff
changeset
|
80 credit=`$dir/abcfield.py --field N --starts "Credit:" $filename` |
326
27f29e8aafea
Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents:
321
diff
changeset
|
81 creditvisibility="no" |
27f29e8aafea
Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents:
321
diff
changeset
|
82 if [ -n "$credit" ]; then |
27f29e8aafea
Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents:
321
diff
changeset
|
83 creditvisibility="yes" |
27f29e8aafea
Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents:
321
diff
changeset
|
84 fi |
504
4cc739fe13ab
Fix last changed item on web pages for transposed instruments.
Jim Hague <jim.hague@acm.org>
parents:
496
diff
changeset
|
85 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc` |
586
daa3b76bd11f
More abcfield.py updates and mark it Python 3.
Jim Hague <jim.hague@acm.org>
parents:
582
diff
changeset
|
86 key=`$dir/abcfield.py --field K --display $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
|
87 |
321
b61c39beac5f
Generate different tune PDF for web site download.
Jim Hague <jim.hague@acm.org>
parents:
319
diff
changeset
|
88 # 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
|
89 cp $filename $webdir |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
90 |
484
4fab69a1027d
Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents:
474
diff
changeset
|
91 # Generate MusicXML into the web. |
4fab69a1027d
Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents:
474
diff
changeset
|
92 python $abc2xml $filename > ${webdir}/${name}.xml |
4fab69a1027d
Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents:
474
diff
changeset
|
93 |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
94 # If we are not the master booke, link the mp3s in from the |
382 | 95 # master page in a desperate attempt to make IE8 work. |
384
ce5dccdd45bd
Comment on soft link creation. Jenkins archive will dereference them.
Jim Hague <jim.hague@acm.org>
parents:
382
diff
changeset
|
96 # The Jenkins archive will dereference the soft link, it seems, |
ce5dccdd45bd
Comment on soft link creation. Jenkins archive will dereference them.
Jim Hague <jim.hague@acm.org>
parents:
382
diff
changeset
|
97 # but I guess I can live with copies of the MP3 for now. |
382 | 98 if [ "$booke" != "$masterbooke" ]; then |
386
e09ff88ab469
Pigwidgeon doesn't have -r in ln. So do it another way.
Jim Hague <jim.hague@acm.org>
parents:
384
diff
changeset
|
99 pushd ${webdir} > /dev/null |
402
f7dbde7c9661
Fix command error linking MP3s into transposed directory.
Jim Hague <jim.hague@acm.org>
parents:
400
diff
changeset
|
100 ln -f -s ../${masterbooke}/*${name}.mp3 . |
386
e09ff88ab469
Pigwidgeon doesn't have -r in ln. So do it another way.
Jim Hague <jim.hague@acm.org>
parents:
384
diff
changeset
|
101 popd > /dev/null |
382 | 102 fi |
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 |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
106 learnerpage=learner-${name}.html |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
107 |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
108 # 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
|
109 # initial '&' in the title - it means things to sed. |
533 | 110 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
|
111 -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
|
112 -e "s/@COMPOSER@/${composer}/" \ |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
113 -e "s/@KEY@/${key}/" \ |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
217
diff
changeset
|
114 -e "s/@MASTERBOOKE@/${masterbooke}/" \ |
533 | 115 -e "s/@CHANGETITLE@/${changetitle//&/\\&}/" \ |
229 | 116 -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \ |
117 -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \ | |
326
27f29e8aafea
Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents:
321
diff
changeset
|
118 -e "s/@CREDIT@/${credit}/" \ |
27f29e8aafea
Add --contains flag to abcfield.py.
Jim Hague <jim.hague@acm.org>
parents:
321
diff
changeset
|
119 -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
|
120 -e "s/@LASTCHANGED@/${lastchanged}/" \ |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
191
diff
changeset
|
121 -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
|
122 |
533 | 123 sed -e "s/@TITLE@/${title//&/\\&}/" \ |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
124 -e "s/@SUBTITLE@/${subtitle}/" \ |
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
125 -e "s/@COMPOSER@/${composer}/" \ |
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
126 -e "s/@KEY@/${key}/" \ |
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
127 -e "s/@MASTERBOOKE@/${masterbooke}/" \ |
533 | 128 -e "s/@CHANGETITLE@/${changetitle//&/\\&}/" \ |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
129 -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \ |
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
130 -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \ |
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
131 -e "s/@CREDIT@/${credit}/" \ |
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
132 -e "s/@CREDITVISIBILITY@/${creditvisibility}/" \ |
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
133 -e "s/@LASTCHANGED@/${lastchanged}/" \ |
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
134 -e "s/@TUNE@/${name}/" dottes.html.learnertune > $webdir/$learnerpage |
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
386
diff
changeset
|
135 |
533 | 136 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
|
137 -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
|
138 done |