From 6427153e8ee2cdb4c7581453593bc3e8436f7ae7 Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Sun, 4 Aug 2013 22:09:25 +0100 Subject: [PATCH] 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. --- Session/AllInAGardenGreen.abc | 1 + Session/ButteredPeas.abc | 1 + Session/OrangeInBloom.abc | 1 + abcfield.py | 7 +++++++ dottes.html.tune | 3 +++ dottes.tex | 9 ++++++--- makeBookeTunePages.sh | 6 ++++-- makeWeb.sh | 9 ++++++++- web/css/dottes.css | 9 +++++++++ 9 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Session/AllInAGardenGreen.abc b/Session/AllInAGardenGreen.abc index 8b1d656..efa1659 100644 --- a/Session/AllInAGardenGreen.abc +++ b/Session/AllInAGardenGreen.abc @@ -5,6 +5,7 @@ R:March 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 --git a/Session/ButteredPeas.abc b/Session/ButteredPeas.abc index 0e316b5..9e4dca3 100644 --- a/Session/ButteredPeas.abc +++ b/Session/ButteredPeas.abc @@ -3,6 +3,7 @@ T:Buttered Peas 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 --git a/Session/OrangeInBloom.abc b/Session/OrangeInBloom.abc index c6333b5..6d30ff4 100644 --- a/Session/OrangeInBloom.abc +++ b/Session/OrangeInBloom.abc @@ -3,6 +3,7 @@ T:Orange in Bloom 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 --git a/abcfield.py b/abcfield.py index 14fc64f..3a89a31 100755 --- a/abcfield.py +++ b/abcfield.py @@ -109,6 +109,9 @@ def process(inf, options): 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 @@ parser.add_option("-n", "--index", dest="index", 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 --git a/dottes.html.tune b/dottes.html.tune index adbefdc..48138ff 100644 --- a/dottes.html.tune +++ b/dottes.html.tune @@ -34,6 +34,9 @@ @TITLE@ dots +
+ From @CREDIT@. +
Change: @CHANGETITLE@ diff --git a/dottes.tex b/dottes.tex index ce8cb7b..19e063b 100644 --- a/dottes.tex +++ b/dottes.tex @@ -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 --git a/makeBookeTunePages.sh b/makeBookeTunePages.sh index e7694de..61ca69e 100755 --- a/makeBookeTunePages.sh +++ b/makeBookeTunePages.sh @@ -44,7 +44,7 @@ find $booke -name "*.abc" | sort | 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 @@ find $booke -name "*.abc" | sort | 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 --git a/makeWeb.sh b/makeWeb.sh index cb8b9b7..7b1a072 100755 --- a/makeWeb.sh +++ b/makeWeb.sh @@ -67,7 +67,7 @@ find $bookedir -name "*.abc" | sort | 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 @@ find $bookedir -name "*.abc" | sort | 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 @@ find $bookedir -name "*.abc" | sort | -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 --git a/web/css/dottes.css b/web/css/dottes.css index 8e3183d..aa1045e 100644 --- a/web/css/dottes.css +++ b/web/css/dottes.css @@ -244,3 +244,12 @@ div.dottes-change-yes div.dottes-change-link { } + +div.dottes-credit-no +{ + display: none; +} + +div.dottes-credit-yes +{ +}