Add previous and next tune links to website.

This commit is contained in:
Jim Hague 2017-10-10 15:01:22 +01:00
parent 0f1646cb90
commit dab61c6bbd
5 changed files with 219 additions and 27 deletions

View File

@ -176,7 +176,7 @@ def convertMarkdown(t, latex):
# <foo.abc> will expand to ['title of foo'](foo.abc). # <foo.abc> will expand to ['title of foo'](foo.abc).
def expandCustomMarkdown(t, dir, latex): def expandCustomMarkdown(t, dir, latex):
# Given a match to (foo.abc), return a markdown link to the tune with the # Given a match to (foo.abc), return a markdown link to the tune with the
# title of the tune as the text of the link. # title (and subtitle, if present) of the tune as the text of the link.
def getTitle(m): def getTitle(m):
fname = m.group(1) + ".abc" fname = m.group(1) + ".abc"
path = pathlib.Path(dir, fname) path = pathlib.Path(dir, fname)

View File

@ -142,6 +142,21 @@
</div> </div>
</div> </div>
</div> </div>
<div class="dottes-tune-footer-learner">
<div class="dottes-tune-footer-learner-prev-column"></div>
<div class="dottes-tune-footer-learner-booke-column"></div>
<div class="dottes-tune-footer-learner-next-column"></div>
<div class="dottes-tune-footer-learner-row">
<div class="dottes-tune-footer-learner-prev">
<a href="${prevpage}">${prevtitle}</a>
</div>
<div class="dottes-tune-footer-learner-booke">
</div>
<div class="dottes-tune-footer-learner-next">
<a href="${nextpage}">${nexttitle}</a>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -85,6 +85,16 @@
Last changed ${lastchanged} Last changed ${lastchanged}
</div> </div>
</div> </div>
<div class="dottes-tune-footer-row">
<div class="dottes-tune-footer-prev">
<a href="${prevpage}">${prevtitle}</a>
</div>
<div class="dottes-tune-footer-booke">
</div>
<div class="dottes-tune-footer-next">
<a href="${nextpage}">${nexttitle}</a>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -66,35 +66,69 @@ cp $1-*.pdf $webdir
# Now, for each tune, make the tune page. # Now, for each tune, make the tune page.
rm -f $webdir/$tunelist rm -f $webdir/$tunelist
find $bookedir -name "*.abc" | sort | declare -a filenames
while read filename filenames=(`find $bookedir -name "*.abc" | sort`)
do nofiles=${#filenames[@]}
name=`basename $filename .abc` for (( i=0; i < ${nofiles}; i++ ))
do
filename=${filenames[$i]}
name=`basename $filename .abc`
# Copy the ABC into the web. # Copy the ABC into the web.
cp $filename $webdir cp $filename $webdir
# Generate MusicXML into the web. # Generate MusicXML into the web.
python $abc2xml $filename > ${webdir}/${name}.xml python $abc2xml $filename > ${webdir}/${name}.xml
# If we are not the master booke, link the mp3s in from the # If we are not the master booke, link the mp3s in from the
# master page in a desperate attempt to make IE8 work. # master page in a desperate attempt to make IE8 work.
# The Jenkins archive will dereference the soft link, it seems, # The Jenkins archive will dereference the soft link, it seems,
# but I guess I can live with copies of the MP3 for now. # but I guess I can live with copies of the MP3 for now.
if [ "$booke" != "$masterbooke" ]; then if [ "$booke" != "$masterbooke" ]; then
pushd ${webdir} > /dev/null pushd ${webdir} > /dev/null
ln -f -s ../${masterbooke}/*${name}.mp3 . ln -f -s ../${masterbooke}/*${name}.mp3 .
popd > /dev/null popd > /dev/null
fi fi
# Get date and time of last change to tune. # Get date and time of last change to tune.
lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc` lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc`
# Generate the tune web page. # Get previous and next tune page names and titles.
tunepage=${name}.html prevpage=""
learnerpage=learner-${name}.html prevtitle=""
nextpage=""
nexttitle=""
$dir/abctemplate.py --value "masterbooke=${masterbooke}" --value "lastchanged=${lastchanged}" --template dottes.html.tune $filename > $webdir/$tunepage if [ $i -gt 0 ]; then
$dir/abctemplate.py --value "masterbooke=${masterbooke}" --value "lastchanged=${lastchanged}" --template dottes.html.learnertune $filename > $webdir/$learnerpage prev=${filenames[$((i - 1))]}
$dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist prevpage=`basename $prev .abc`.html
done prevtitle=`./abcfield.py --display --field="T" $prev`
fi
if [ $i -lt $((nofiles - 1)) ]; then
next=${filenames[$((i + 1))]}
nextpage=`basename $next .abc`.html
nexttitle=`./abcfield.py --display --field="T" $next`
fi
# Generate the tune web page.
tunepage=${name}.html
learnerpage=learner-${name}.html
$dir/abctemplate.py \
--value "masterbooke=${masterbooke}" \
--value "lastchanged=${lastchanged}" \
--value "prevpage=${prevpage}" \
--value "prevtitle=${prevtitle}" \
--value "nextpage=${nextpage}" \
--value "nexttitle=${nexttitle}" \
--template dottes.html.tune $filename > $webdir/$tunepage
$dir/abctemplate.py \
--value "masterbooke=${masterbooke}" \
--value "lastchanged=${lastchanged}" \
--value "prevpage=learner-${prevpage}" \
--value "prevtitle=${prevtitle}" \
--value "nextpage=learner-${nextpage}" \
--value "nexttitle=${nexttitle}" \
--template dottes.html.learnertune $filename > $webdir/$learnerpage
$dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist
done

View File

@ -244,6 +244,26 @@ div.dottes-tune-footer-last
vertical-align: middle; vertical-align: middle;
} }
div.dottes-tune-footer-prev
{
display: table-cell;
vertical-align: middle;
}
div.dottes-tune-footer-booke
{
display: table-cell;
text-align: center;
vertical-align: middle;
}
div.dottes-tune-footer-next
{
display: table-cell;
text-align: right;
vertical-align: middle;
}
div.dottes-tune-learner div.dottes-tune-learner
{ {
display: table; display: table;
@ -290,6 +310,55 @@ div.dottes-tune-learner-download
text-align: right; text-align: right;
} }
div.dottes-tune-footer-learner
{
display: table;
width: 100%;
}
div.dottes-tune-footer-learner-prev-column
{
display: table-column;
width: 25%;
}
div.dottes-tune-footer-learner-booke-column
{
display: table-column;
width: 50%;
}
div.dottes-tune-footer-learner-next-column
{
display: table-column;
width: 25%;
}
div.dottes-tune-footer-learner-row
{
display: table-row;
}
div.dottes-tune-footer-learner-prev
{
display: table-cell;
vertical-align: middle;
}
div.dottes-tune-footer-learner-booke
{
display: table-cell;
text-align: center;
vertical-align: middle;
}
div.dottes-tune-footer-learner-next
{
display: table-cell;
text-align: right;
vertical-align: middle;
}
a.dottes-tune-icon-link a.dottes-tune-icon-link
{ {
text-decoration: none; text-decoration: none;
@ -476,6 +545,27 @@ div.dottes-history-yes
vertical-align: middle; vertical-align: middle;
} }
div.dottes-tune-footer-prev
{
display: table-row;
text-align: center;
vertical-align: middle;
}
div.dottes-tune-footer-booke
{
display: table-row;
text-align: center;
vertical-align: middle;
}
div.dottes-tune-footer-next
{
display: table-row;
text-align: center;
vertical-align: middle;
}
div.dottes-tune-learner div.dottes-tune-learner
{ {
} }
@ -515,6 +605,49 @@ div.dottes-history-yes
display: table-row; display: table-row;
text-align: center; text-align: center;
} }
div.dottes-tune-footer-learner
{
}
div.dottes-tune-footer-learner-prev-column
{
}
div.dottes-tune-footer-learner-booke-column
{
}
div.dottes-tune-footer-learner-next-column
{
}
div.dottes-tune-footer-learner-row
{
display: table;
width: 100%;
}
div.dottes-tune-footer-learner-prev
{
display: table-row;
text-align: center;
vertical-align: middle;
}
div.dottes-tune-footer-learner-booke
{
display: table-row;
text-align: center;
vertical-align: middle;
}
div.dottes-tune-footer-learner-next
{
display: table-row;
text-align: center;
vertical-align: middle;
}
} }
/* /*