# HG changeset patch # User Jim Hague # Date 1375650565 -3600 # Node ID 27f29e8aafea2fb2504600815f7a93e362b01f07 # Parent 21615733c3f3ec93d6c1e5374eae7e8af82d92f2 Add --contains flag to abcfield.py. Currently we rely on any N: field with a Change: subnotice being the first N: field. Add --contains field to abcfield.py to remove this restriction. Also use it to extract new subfield Credit: and add that if present to the tune information in print and on web. diff -r 21615733c3f3 -r 27f29e8aafea Session/AllInAGardenGreen.abc --- a/Session/AllInAGardenGreen.abc Sun Aug 04 21:28:05 2013 +0100 +++ b/Session/AllInAGardenGreen.abc Sun Aug 04 22:09:25 2013 +0100 @@ -5,6 +5,7 @@ O:England Z:Paul Hardy's Session Tunebook 2013 (see www.paulhardy.net). Creative Commons cc by-nc-sa licenced. N: Change: GatheringPeascods.abc +N: Credit: Paul Hardy's Session Tunebook M:2/2 L:1/8 Q:1/2=90 diff -r 21615733c3f3 -r 27f29e8aafea Session/ButteredPeas.abc --- a/Session/ButteredPeas.abc Sun Aug 04 21:28:05 2013 +0100 +++ b/Session/ButteredPeas.abc Sun Aug 04 22:09:25 2013 +0100 @@ -3,6 +3,7 @@ R:Polka O:England Z:Paul Hardy's Session Tunebook 2013 (see www.paulhardy.net). Creative Commons cc by-nc-sa licenced. +N: Credit: Paul Hardy's Session Tunebook M:2/2 L:1/8 Q:1/4=180 diff -r 21615733c3f3 -r 27f29e8aafea Session/OrangeInBloom.abc --- a/Session/OrangeInBloom.abc Sun Aug 04 21:28:05 2013 +0100 +++ b/Session/OrangeInBloom.abc Sun Aug 04 22:09:25 2013 +0100 @@ -3,6 +3,7 @@ T:Sherborne Waltz R:Waltz O:England +N: Credit: Paul Hardy's Session Tunebook Z:Paul Hardy's Session Tunebook 2013 (see www.paulhardy.net). Creative Commons cc by-nc-sa licenced. M:3/4 L:1/8 diff -r 21615733c3f3 -r 27f29e8aafea abcfield.py --- a/abcfield.py Sun Aug 04 21:28:05 2013 +0100 +++ b/abcfield.py Sun Aug 04 22:09:25 2013 +0100 @@ -109,6 +109,9 @@ for line in inf: line = line.strip() if len(line) > 2 and line[0] == options.field and line[1] == ':': + if len(options.contains) > 0: + if line.find(options.contains) < 0: + continue if n > 1: n = n - 1 else: @@ -129,6 +132,10 @@ action="store", type="int", default=1, help="report INDEXth value [default: %default]", metavar="INDEX") +parser.add_option("-c", "--contains", dest="contains", + action="store", type="string", default="", + help="report only if line contains CONTENT", + metavar="CONTENT") (options, args) = parser.parse_args() if options.html and options.latex: diff -r 21615733c3f3 -r 27f29e8aafea dottes.html.tune --- a/dottes.html.tune Sun Aug 04 21:28:05 2013 +0100 +++ b/dottes.html.tune Sun Aug 04 22:09:25 2013 +0100 @@ -34,6 +34,9 @@ @TITLE@ dots +
+ From @CREDIT@. +
Change: @CHANGETITLE@ diff -r 21615733c3f3 -r 27f29e8aafea dottes.tex --- a/dottes.tex Sun Aug 04 21:28:05 2013 +0100 +++ b/dottes.tex Sun Aug 04 22:09:25 2013 +0100 @@ -47,8 +47,8 @@ % Show the main tune graphic and optional change. % Args are tune name, tune title, tune subtitle, composer, tune graphic -% filename, change name, change title. -\newcommand{\showtune}[7]{% +% filename, change name, change title, credit. +\newcommand{\showtune}[8]{% \vfill \begin{center} \phantomsection @@ -63,8 +63,11 @@ } \addcontentsline{toc}{section}{#2} \end{center} + \ifemptyarg{#8}{}{% + From {#8}. + }% \ifemptyarg{#6}{}{% - Change: \hyperlink{#6}{#7} + Change: \hyperlink{#6}{#7}. }% } diff -r 21615733c3f3 -r 27f29e8aafea makeBookeTunePages.sh --- a/makeBookeTunePages.sh Sun Aug 04 21:28:05 2013 +0100 +++ b/makeBookeTunePages.sh Sun Aug 04 22:09:25 2013 +0100 @@ -44,7 +44,7 @@ subtitle=`$dir/abcfield.py --index 2 --field T --latex $filename` composer=`$dir/abcfield.py --field C --latex $filename` - changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"` + changefile=`$dir/abcfield.py --field N --contains "Change:" $filename | sed -e "s/Change: *//"` changename="" changetitle="" if [ -n "$changefile" ]; then @@ -53,7 +53,9 @@ fixtitle "$changetitle" changetitle=$retval fi - echo -E "\showtune{$name}{$title}{$subtitle}{$composer}{$graphicsdir/$name}{$changename}{$changetitle}" >> $tunesoutput + + credit=`$dir/abcfield.py --field N --contains "Credit:" $filename | sed -e "s/Credit: *//"` + echo -E "\showtune{$name}{$title}{$subtitle}{$composer}{$graphicsdir/$name}{$changename}{$changetitle}{$credit}" >> $tunesoutput echo -E "\showfirstline{$name}{$title}{$graphicsdir/firstline-$name}" >> $indexoutput done diff -r 21615733c3f3 -r 27f29e8aafea makeWeb.sh --- a/makeWeb.sh Sun Aug 04 21:28:05 2013 +0100 +++ b/makeWeb.sh Sun Aug 04 22:09:25 2013 +0100 @@ -67,7 +67,7 @@ title=$retval subtitle=`$dir/abcfield.py --index 2 --field T --latex $filename` composer=`$dir/abcfield.py --field C --latex $filename` - changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"` + changefile=`$dir/abcfield.py --field N --contains "Change:" $filename | sed -e "s/Change: *//"` changetitle="" changevisibility="no" if [ -n "$changefile" ]; then @@ -77,6 +77,11 @@ fixtitle "$changetitle" changetitle=$retval fi + credit=`$dir/abcfield.py --field N --contains "Credit:" $filename | sed -e "s/Credit: *//"` + creditvisibility="no" + if [ -n "$credit" ]; then + creditvisibility="yes" + fi # Copy the ABC into the web. cp $filename $webdir @@ -93,6 +98,8 @@ -e "s/@CHANGETITLE@/${changetitle//&/\&}/" \ -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \ -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \ + -e "s/@CREDIT@/${credit}/" \ + -e "s/@CREDITVISIBILITY@/${creditvisibility}/" \ -e "s/@TUNE@/${name}/" dottes.html.tune > $webdir/$tunepage sed -e "s/@TITLE@/${title//&/\&}/" \ diff -r 21615733c3f3 -r 27f29e8aafea web/css/dottes.css --- a/web/css/dottes.css Sun Aug 04 21:28:05 2013 +0100 +++ b/web/css/dottes.css Sun Aug 04 22:09:25 2013 +0100 @@ -244,3 +244,12 @@ div.dottes-change-link { } + +div.dottes-credit-no +{ + display: none; +} + +div.dottes-credit-yes +{ +}