comparison 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
comparison
equal deleted inserted replaced
721:f053b23af061 722:f8ab14cc9d8d
64 # to be already generated. 64 # to be already generated.
65 cp $1-*.pdf $webdir 65 cp $1-*.pdf $webdir
66 66
67 # Now, for each tune, make the tune page. 67 # Now, for each tune, make the tune page.
68 rm -f $webdir/$tunelist 68 rm -f $webdir/$tunelist
69 find $bookedir -name "*.abc" | sort | 69 declare -a filenames
70 while read filename 70 filenames=(`find $bookedir -name "*.abc" | sort`)
71 do 71 nofiles=${#filenames[@]}
72 name=`basename $filename .abc` 72 for (( i=0; i < ${nofiles}; i++ ))
73 do
74 filename=${filenames[$i]}
75 name=`basename $filename .abc`
73 76
74 # Copy the ABC into the web. 77 # Copy the ABC into the web.
75 cp $filename $webdir 78 cp $filename $webdir
76 79
77 # Generate MusicXML into the web. 80 # Generate MusicXML into the web.
78 python $abc2xml $filename > ${webdir}/${name}.xml 81 python $abc2xml $filename > ${webdir}/${name}.xml
79 82
80 # If we are not the master booke, link the mp3s in from the 83 # If we are not the master booke, link the mp3s in from the
81 # master page in a desperate attempt to make IE8 work. 84 # master page in a desperate attempt to make IE8 work.
82 # The Jenkins archive will dereference the soft link, it seems, 85 # The Jenkins archive will dereference the soft link, it seems,
83 # but I guess I can live with copies of the MP3 for now. 86 # but I guess I can live with copies of the MP3 for now.
84 if [ "$booke" != "$masterbooke" ]; then 87 if [ "$booke" != "$masterbooke" ]; then
85 pushd ${webdir} > /dev/null 88 pushd ${webdir} > /dev/null
86 ln -f -s ../${masterbooke}/*${name}.mp3 . 89 ln -f -s ../${masterbooke}/*${name}.mp3 .
87 popd > /dev/null 90 popd > /dev/null
88 fi 91 fi
89 92
90 # Get date and time of last change to tune. 93 # Get date and time of last change to tune.
91 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc` 94 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc`
92 95
93 # Generate the tune web page. 96 # Get previous and next tune page names and titles.
94 tunepage=${name}.html 97 prevpage=""
95 learnerpage=learner-${name}.html 98 prevtitle=""
99 nextpage=""
100 nexttitle=""
96 101
97 $dir/abctemplate.py --value "masterbooke=${masterbooke}" --value "lastchanged=${lastchanged}" --template dottes.html.tune $filename > $webdir/$tunepage 102 if [ $i -gt 0 ]; then
98 $dir/abctemplate.py --value "masterbooke=${masterbooke}" --value "lastchanged=${lastchanged}" --template dottes.html.learnertune $filename > $webdir/$learnerpage 103 prev=${filenames[$((i - 1))]}
99 $dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist 104 prevpage=`basename $prev .abc`.html
100 done 105 prevtitle=`./abcfield.py --display --field="T" $prev`
106 fi
107 if [ $i -lt $((nofiles - 1)) ]; then
108 next=${filenames[$((i + 1))]}
109 nextpage=`basename $next .abc`.html
110 nexttitle=`./abcfield.py --display --field="T" $next`
111 fi
112
113 # Generate the tune web page.
114 tunepage=${name}.html
115 learnerpage=learner-${name}.html
116
117 $dir/abctemplate.py \
118 --value "masterbooke=${masterbooke}" \
119 --value "lastchanged=${lastchanged}" \
120 --value "prevpage=${prevpage}" \
121 --value "prevtitle=${prevtitle}" \
122 --value "nextpage=${nextpage}" \
123 --value "nexttitle=${nexttitle}" \
124 --template dottes.html.tune $filename > $webdir/$tunepage
125 $dir/abctemplate.py \
126 --value "masterbooke=${masterbooke}" \
127 --value "lastchanged=${lastchanged}" \
128 --value "prevpage=learner-${prevpage}" \
129 --value "prevtitle=${prevtitle}" \
130 --value "nextpage=learner-${nextpage}" \
131 --value "nexttitle=${nexttitle}" \
132 --template dottes.html.learnertune $filename > $webdir/$learnerpage
133 $dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist
134 done