annotate makeWeb.sh @ 943:d6e2a281cceb build-default-344

Change web page layout. Put tune contents under 'tunes/<name>' or 'tunes-<instrument>/<name>'. That way they won't move if the tune gets moved between Bookes. For now I have not attempted to redirect old URLs.
author Jim Hague <jim.hague@acm.org>
date Mon, 05 Aug 2019 23:25:28 +0100
parents b83b49f2a0a0
children 0f4ba68d6059
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
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
32 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
33 # 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
34 buildno=${buildno%%%}
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
35 subtitle=
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
36 intro=
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
37 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
38 subtitle=`cat $bookedir/subtitle.txt`
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
39 fi
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
40
223
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
41 if [ -n "$instrument" ]; then
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
42 title="${title} ($instrument)"
0ef955669a9a Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents: 217
diff changeset
43 subtitle="${subtitle} ($instrument)"
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
44 basetunedir="${basetunedir}-${instrument}"
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
45 fi
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
46
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
47 mkdir -p $bookewebdir
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
48
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
49 sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
50 -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
51
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
52 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
53 do
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
54 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
55 if [ -r $bookedir/$item.md ]; then
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
56 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
57 else
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
58 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
59 fi
01ded8741361 Use server-side includes (with Apache XBitHack setting) in web.
Jim Hague <jim.hague@acm.org>
parents: 359
diff changeset
60 done
43
d92717f8130c First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
61
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
62 # 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
63 if [ -r $masterbookedir/htaccess ]; then
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
64 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
65 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
66
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 191
diff changeset
67 # 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
68 # to be already generated.
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
69 cp $1-*.pdf $bookewebdir
45
689026e2de0c Web. Add download links for book.
Jim Hague <jim.hague@laicatc.com>
parents: 43
diff changeset
70
382
04bd083eed29 Ratchet up the IE8 attempt.
Jim Hague <jim.hague@acm.org>
parents: 366
diff changeset
71 # Now, for each tune, make the tune page.
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
72 rm -f $bookewebdir/$tunelist
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
73 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
74 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
75 nofiles=${#filenames[@]}
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
76 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
77 do
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
78 filename=${filenames[$i]}
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
79 name=`basename $filename .abc`
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
80 tunedir=$basetunedir/$name
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
81 tunewebdir=$basewebdir/$tunedir
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
82 mkdir -p $tunewebdir
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
83
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
84 # Copy the ABC into the web.
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
85 cp $filename $tunewebdir
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
86
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
87 # Generate MusicXML into the web.
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
88 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
89
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
90 # 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
91 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
92
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
93 # 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
94 prevarg=""
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
95 prevpage=""
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
96 nextarg=""
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
97 nextpage=""
484
4fab69a1027d Add MusicXML conversion to tune pages.
Jim Hague <jim.hague@acm.org>
parents: 474
diff changeset
98
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
99 if [ $i -gt 0 ]; then
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
100 prev=${filenames[$((i - 1))]}
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
101 prevpage=`basename $prev .abc`
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
102 prevarg="--prev $prev"
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
103 fi
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
104 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
105 next=${filenames[$((i + 1))]}
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
106 nextpage=`basename $next .abc`
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
107 nextarg="--next $next"
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
108 fi
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
109
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
110 # Generate the tune web page.
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
111 $dir/abctemplate.py \
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
112 --value "booke=${booke}" \
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
113 --value "mastertunedir=${mastertunedir}" \
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
114 --value "lastchanged=${lastchanged}" \
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
115 --value "prevpage=${prevpage}" \
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
116 --value "nextpage=${nextpage}" \
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
117 ${prevarg} ${nextarg} \
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
118 --template dottes.html.tune \
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
119 $filename > $tunewebdir/index.html
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
120 $dir/abctemplate.py \
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
121 --value "booke=${booke}" \
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
122 --value "mastertunedir=${mastertunedir}" \
722
f8ab14cc9d8d Add previous and next tune links to website.
Jim Hague <jim.hague@acm.org>
parents: 651
diff changeset
123 --value "lastchanged=${lastchanged}" \
732
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
124 --value "prevpage=${prevpage}" \
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
125 --value "nextpage=${nextpage}" \
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
126 ${prevarg} ${nextarg} \
c81a1ed21877 Move prev/next field reading into abctemplate.py.
Jim Hague <jim.hague@acm.org>
parents: 727
diff changeset
127 --template dottes.html.learnertune \
943
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
128 $filename > $tunewebdir/learner.html
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
129 $dir/abctemplate.py \
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
130 --value "tunedir=${tunedir}" \
d6e2a281cceb Change web page layout.
Jim Hague <jim.hague@acm.org>
parents: 753
diff changeset
131 --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
132 done