comparison 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
comparison
equal deleted inserted replaced
942:a774b3b3cad7 943:d6e2a281cceb
16 16
17 booke=$1 17 booke=$1
18 masterbooke=$2 18 masterbooke=$2
19 bookedir=$dir/$1 19 bookedir=$dir/$1
20 masterbookedir=$dir/$2 20 masterbookedir=$dir/$2
21 webdir=$dir/web/$1 21 basewebdir=$dir/web
22 mastertunedir=tunes
23 basetunedir=$mastertunedir
24 bookewebdir=$dir/web/$1
22 graphicsdir=$dir/graphics/$1 25 graphicsdir=$dir/graphics/$1
23 output=index.html 26 output=index.html
24 tunelist=tunelist.html 27 tunelist=tunelist.html
25 title=$booke 28 title=$booke
26 instrument=$3 29 instrument=$3
36 fi 39 fi
37 40
38 if [ -n "$instrument" ]; then 41 if [ -n "$instrument" ]; then
39 title="${title} ($instrument)" 42 title="${title} ($instrument)"
40 subtitle="${subtitle} ($instrument)" 43 subtitle="${subtitle} ($instrument)"
44 basetunedir="${basetunedir}-${instrument}"
41 fi 45 fi
42 46
43 mkdir -p $webdir 47 mkdir -p $bookewebdir
44 48
45 sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \ 49 sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \
46 -e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" dottes.html > $webdir/$output 50 -e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" dottes.html > $bookewebdir/$output
47 51
48 for item in intro 52 for item in intro
49 do 53 do
50 rm -f $webdir/$item.html 54 rm -f $bookewebdir/$item.html
51 if [ -r $bookedir/$item.md ]; then 55 if [ -r $bookedir/$item.md ]; then
52 pandoc --from=markdown --to=html --output=$webdir/$item.html $bookedir/$item.md 56 pandoc --from=markdown --to=html --output=$bookewebdir/$item.html $bookedir/$item.md
53 else 57 else
54 touch $webdir/$item.html 58 touch $bookewebdir/$item.html
55 fi 59 fi
56 done 60 done
57 61
58 # Copy in any htaccess. 62 # Copy in any htaccess.
59 if [ -r $masterbookedir/htaccess ]; then 63 if [ -r $masterbookedir/htaccess ]; then
60 cp $masterbookedir/htaccess $webdir/.htaccess 64 cp $masterbookedir/htaccess $bookewebdir/.htaccess
61 fi 65 fi
62 66
63 # Copy in the book PDFs. Like the graphics, Midi etc. these are assumed 67 # Copy in the book PDFs. Like the graphics, Midi etc. these are assumed
64 # to be already generated. 68 # to be already generated.
65 cp $1-*.pdf $webdir 69 cp $1-*.pdf $bookewebdir
66 70
67 # Now, for each tune, make the tune page. 71 # Now, for each tune, make the tune page.
68 rm -f $webdir/$tunelist 72 rm -f $bookewebdir/$tunelist
69 declare -a filenames 73 declare -a filenames
70 filenames=(`find $bookedir -maxdepth 1 -name "*.abc" | sort`) 74 filenames=(`find $bookedir -maxdepth 1 -name "*.abc" | sort`)
71 nofiles=${#filenames[@]} 75 nofiles=${#filenames[@]}
72 for (( i=0; i < ${nofiles}; i++ )) 76 for (( i=0; i < ${nofiles}; i++ ))
73 do 77 do
74 filename=${filenames[$i]} 78 filename=${filenames[$i]}
75 name=`basename $filename .abc` 79 name=`basename $filename .abc`
80 tunedir=$basetunedir/$name
81 tunewebdir=$basewebdir/$tunedir
82 mkdir -p $tunewebdir
76 83
77 # Copy the ABC into the web. 84 # Copy the ABC into the web.
78 cp $filename $webdir 85 cp $filename $tunewebdir
79 86
80 # Generate MusicXML into the web. 87 # Generate MusicXML into the web.
81 python $abc2xml $filename > ${webdir}/${name}.xml 88 python $abc2xml $filename > ${tunewebdir}/${name}.xml
82
83 # If we are not the master booke, link the mp3s in from the
84 # master page in a desperate attempt to make IE8 work.
85 # The Jenkins archive will dereference the soft link, it seems,
86 # but I guess I can live with copies of the MP3 for now.
87 if [ "$booke" != "$masterbooke" ]; then
88 pushd ${webdir} > /dev/null
89 ln -f -s ../${masterbooke}/*${name}.mp3 .
90 popd > /dev/null
91 fi
92 89
93 # Get date and time of last change to tune. 90 # Get date and time of last change to tune.
94 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc` 91 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc`
95 92
96 # Get previous and next tunes, if available. 93 # Get previous and next tunes, if available.
99 nextarg="" 96 nextarg=""
100 nextpage="" 97 nextpage=""
101 98
102 if [ $i -gt 0 ]; then 99 if [ $i -gt 0 ]; then
103 prev=${filenames[$((i - 1))]} 100 prev=${filenames[$((i - 1))]}
104 prevpage=`basename $prev .abc`.html 101 prevpage=`basename $prev .abc`
105 prevarg="--prev $prev" 102 prevarg="--prev $prev"
106 fi 103 fi
107 if [ $i -lt $((nofiles - 1)) ]; then 104 if [ $i -lt $((nofiles - 1)) ]; then
108 next=${filenames[$((i + 1))]} 105 next=${filenames[$((i + 1))]}
109 nextpage=`basename $next .abc`.html 106 nextpage=`basename $next .abc`
110 nextarg="--next $next" 107 nextarg="--next $next"
111 fi 108 fi
112 109
113 # Generate the tune web page. 110 # Generate the tune web page.
114 tunepage=${name}.html
115 learnerpage=learner-${name}.html
116
117 $dir/abctemplate.py \ 111 $dir/abctemplate.py \
118 --value "masterbooke=${masterbooke}" \ 112 --value "booke=${booke}" \
113 --value "mastertunedir=${mastertunedir}" \
119 --value "lastchanged=${lastchanged}" \ 114 --value "lastchanged=${lastchanged}" \
120 --value "prevpage=${prevpage}" \ 115 --value "prevpage=${prevpage}" \
121 --value "nextpage=${nextpage}" \ 116 --value "nextpage=${nextpage}" \
122 ${prevarg} ${nextarg} \ 117 ${prevarg} ${nextarg} \
123 --template dottes.html.tune \ 118 --template dottes.html.tune \
124 $filename > $webdir/$tunepage 119 $filename > $tunewebdir/index.html
125 $dir/abctemplate.py \ 120 $dir/abctemplate.py \
126 --value "masterbooke=${masterbooke}" \ 121 --value "booke=${booke}" \
122 --value "mastertunedir=${mastertunedir}" \
127 --value "lastchanged=${lastchanged}" \ 123 --value "lastchanged=${lastchanged}" \
128 --value "prevpage=${prevpage}" \ 124 --value "prevpage=${prevpage}" \
129 --value "nextpage=${nextpage}" \ 125 --value "nextpage=${nextpage}" \
130 ${prevarg} ${nextarg} \ 126 ${prevarg} ${nextarg} \
131 --template dottes.html.learnertune \ 127 --template dottes.html.learnertune \
132 $filename > $webdir/$learnerpage 128 $filename > $tunewebdir/learner.html
133 $dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist 129 $dir/abctemplate.py \
130 --value "tunedir=${tunedir}" \
131 --template dottes.html.tuneindex $filename >> $bookewebdir/$tunelist
134 done 132 done