Autorensystem flexibilisiert

This commit is contained in:
2026-01-11 19:32:47 +01:00
parent f68e2f10ae
commit bbd6d44455
2 changed files with 140 additions and 95 deletions

View File

@@ -2,8 +2,8 @@
poetPrefix = "Worte:" poetPrefix = "Worte:"
composerPrefix = "Weise:" composerPrefix = "Weise:"
compositionPrefix = "Satz:" compositionPrefix = "Satz:"
adaptionTextPrefix = "Bearbeitung Text:" adaptionTextPrefix = "Bearbeitung:"
adaptionMusicPrefix = "Bearbeitung Musik:" adaptionMusicPrefix = "Bearbeitung:"
poetAndComposerEqualPrefix = "Worte und Weise:" poetAndComposerEqualPrefix = "Worte und Weise:"
voicePrefix = "Stimme:" voicePrefix = "Stimme:"
versePrefix = "Strophe:" versePrefix = "Strophe:"
@@ -12,6 +12,7 @@
pronunciationPrefix = "Aussprache:" pronunciationPrefix = "Aussprache:"
interludePrefix = "Zwischenspiel:" interludePrefix = "Zwischenspiel:"
bridgePrefix = "Bridge:" bridgePrefix = "Bridge:"
author-joiner = #(lambda (author-list) (string-join author-list ", "))
authorFormat = authorFormat =
#(lambda (noDetails name trail_name birth_year death_year organization) #(lambda (noDetails name trail_name birth_year death_year organization)
@@ -31,6 +32,105 @@
"" ""
))) )))
authorContributionFormat =
#(lambda* (render-contribution-group render-partial-contribution-group #:key
(poetIds '())
(translatorIds '())
(versePoetData '())
(composerIds '())
(verseComposerData '())
(voiceComposerData '())
(compositionIds '())
(adaptionTextIds '())
(adaptionMusicIds '())
(bridgeIds '())
(interludeIds '())
(year_text #f)
(year_translation #f)
(year_melody #f)
(year_composition #f)
(year_adaption_text #f)
(year_adaption_music #f)
(poetAndComposerEqualPrefix "")
(poetPrefix "")
(composerPrefix "")
(translationPrefix "")
(pronunciationPrefix "")
(compositionPrefix "")
(adaptionTextPrefix "")
(adaptionMusicPrefix "")
(bridgePrefix "")
(interludePrefix ""))
(if (and
(equal? poetIds composerIds)
(null? translatorIds)
(null? versePoetData)
(null? verseComposerData)
(null? voiceComposerData)
(null? compositionIds)
(null? adaptionTextIds)
(null? adaptionMusicIds)
(null? bridgeIds)
(null? interludeIds))
(list
(join-present (list
(render-contribution-group poetAndComposerEqualPrefix poetIds)
(if (equal? year_text year_melody) year_text (join-present (list year_text year_melody) "/"))
) ", ")
#f)
(list
(if (and (null? poetIds) (null? versePoetData) (null? translatorIds)) #f
(string-append
poetPrefix
" "
(join-present (list
(join-present (list
(render-contribution-group "" poetIds)
year_text
) ", ")
(render-partial-contribution-group 'versePrefix versePoetData)
(join-present (list
(render-contribution-group adaptionTextPrefix adaptionTextIds)
year_adaption_text
) ", ")
(join-present (list
(render-contribution-group translationAuthorPrefix translatorIds)
year_translation
) ", ")
) "; ")
))
(if (and
(null? composerIds)
(null? compositionIds)
(null? adaptionMusicIds)
(null? verseComposerData)
(null? voiceComposerData)
(null? bridgeIds)
(null? interludeIds)) #f
(string-append
composerPrefix
" "
(join-present (list
(join-present (list
(render-contribution-group "" composerIds)
year_melody
) ", ")
(render-partial-contribution-group 'versePrefix verseComposerData)
(render-partial-contribution-group 'voicePrefix voiceComposerData)
(join-present (list
(render-contribution-group compositionPrefix compositionIds)
year_composition
) ", ")
(join-present (list
(render-contribution-group adaptionMusicPrefix adaptionMusicIds)
year_adaption_music
) ", ")
(render-contribution-group bridgePrefix bridgeIds)
(render-contribution-group interludePrefix interludeIds)
) "; ")
)))))
songinfoMarkup = songinfoMarkup =
#(make-on-the-fly-markup #(make-on-the-fly-markup
(lambda (layout props m) (lambda (layout props m)
@@ -45,13 +145,15 @@
(year_melody (chain-assoc-get 'songinfo:year_melody props #f)) (year_melody (chain-assoc-get 'songinfo:year_melody props #f))
(poet-with-year (if (and poet-maybe-with-composer year_text) (string-append poet-maybe-with-composer ", " year_text) poet-maybe-with-composer)) (poet-with-year (if (and poet-maybe-with-composer year_text) (string-append poet-maybe-with-composer ", " year_text) poet-maybe-with-composer))
(composer-with-year (if (and composer year_melody) (string-append composer ", " year_melody) composer)) (composer-with-year (if (and composer year_melody) (string-append composer ", " year_melody) composer))
(concat-markupped-strings (lambda (text)
(ly:regex-replace (ly:make-regex "(\\S+)(\\\\\\w+(?:\\s+\\[^\\{\\s]*|\\s*\\{[^\\}]*\\}))(\\S*)") text "\\concat {" 1 "\\line {" 2 "}" 3 "}")))
(string-with-paragraphs->markuplist (lambda (prefix text) (string-with-paragraphs->markuplist (lambda (prefix text)
(if text (if text
(apply append (apply append
(map (map
(lambda (paragraph) (lambda (paragraph)
(make-wordwrap-internal-markup-list #t (make-wordwrap-internal-markup-list #t
#{ \markuplist { $(ly:parser-include-string paragraph) } #})) #{ \markuplist { $(ly:parser-include-string (concat-markupped-strings paragraph)) } #}))
(ly:regex-split (ly:make-regex "\r?\n[ \t\r\n]*\n[ \t\r\n]*") (string-append prefix text)))) (ly:regex-split (ly:make-regex "\r?\n[ \t\r\n]*\n[ \t\r\n]*") (string-append prefix text))))
'()))) '())))
(poet-and-composer-markup-list (poet-and-composer-markup-list

View File

@@ -30,6 +30,9 @@
(lambda (a b) (< (cadr a) (cadr b)))) (lambda (a b) (< (cadr a) (cadr b))))
(list))) (list)))
#(define (join-present items joiner)
(string-join (filter (lambda (item) (and (string? item) (not (string-null? (string-trim-both item))))) items) joiner))
#(define-markup-command (print-songinfo layout props) () #(define-markup-command (print-songinfo layout props) ()
(define (songinfo-from songId key) (define (songinfo-from songId key)
(let ((song (if (defined? 'SONG_DATA) (assoc-ref SONG_DATA songId) #f))) (let ((song (if (defined? 'SONG_DATA) (assoc-ref SONG_DATA songId) #f)))
@@ -74,11 +77,7 @@
(define (render-contribution-group contributionPrefix authorIds) (define (render-contribution-group contributionPrefix authorIds)
(if (null? authorIds) (if (null? authorIds)
"" ""
(string-append contributionPrefix " " (string-join (format-authors authorIds) ", "))) (string-append contributionPrefix " " ((ly:output-def-lookup layout 'author-joiner) (format-authors authorIds))))
)
(define (join-present items joiner)
(string-join (filter (lambda (item) (and (string? item) (not (string-null? (string-trim-both item))))) items) joiner)
) )
(define (render-partial-contribution-group prefixLookup authorData) (define (render-partial-contribution-group prefixLookup authorData)
@@ -94,93 +93,37 @@
(define (poet-and-composer-from-authors authors) (define (poet-and-composer-from-authors authors)
(if authors (if authors
(let ( ((ly:output-def-lookup layout 'authorContributionFormat)
(poetIds (find-author-ids-by 'text authors)) render-contribution-group
(translatorIds (find-author-ids-by 'translation authors)) render-partial-contribution-group
(versePoetData (find-author-id-with-part-numbers 'verse authors)) #:poetIds (find-author-ids-by 'text authors)
(composerIds (find-author-ids-by 'melody authors)) #:translatorIds (find-author-ids-by 'translation authors)
(verseComposerData (find-author-id-with-part-numbers 'meloverse authors)) #:versePoetData (find-author-id-with-part-numbers 'verse authors)
(voiceComposerData (find-author-id-with-part-numbers 'voice authors)) #:composerIds (find-author-ids-by 'melody authors)
(compositionIds (find-author-ids-by 'composition authors)) #:verseComposerData (find-author-id-with-part-numbers 'meloverse authors)
(adaptionTextIds (find-author-ids-by 'adaption_text authors)) #:voiceComposerData (find-author-id-with-part-numbers 'voice authors)
(adaptionMusicIds (find-author-ids-by 'adaption_music authors)) #:compositionIds (find-author-ids-by 'composition authors)
(bridgeIds (find-author-ids-by 'bridge authors)) #:adaptionTextIds (find-author-ids-by 'adaption_text authors)
(interludeIds (find-author-ids-by 'interlude authors)) #:adaptionMusicIds (find-author-ids-by 'adaption_music authors)
(year_text (chain-assoc-get 'header:year_text props #f)) #:bridgeIds (find-author-ids-by 'bridge authors)
(year_translation (chain-assoc-get 'header:year_translation props #f)) #:interludeIds (find-author-ids-by 'interlude authors)
(year_melody (chain-assoc-get 'header:year_melody props #f)) #:year_text (chain-assoc-get 'header:year_text props #f)
(year_composition (chain-assoc-get 'header:year_composition props #f)) #:year_translation (chain-assoc-get 'header:year_translation props #f)
(year_adaption_text (chain-assoc-get 'header:year_adaption_text props #f)) #:year_melody (chain-assoc-get 'header:year_melody props #f)
(year_adaption_music (chain-assoc-get 'header:year_adaption_music props #f)) #:year_composition (chain-assoc-get 'header:year_composition props #f)
#:year_adaption_text (chain-assoc-get 'header:year_adaption_text props #f)
#:year_adaption_music (chain-assoc-get 'header:year_adaption_music props #f)
#:poetAndComposerEqualPrefix (ly:output-def-lookup layout 'poetAndComposerEqualPrefix)
#:poetPrefix (ly:output-def-lookup layout 'poetPrefix)
#:composerPrefix (ly:output-def-lookup layout 'composerPrefix)
#:translationPrefix (ly:output-def-lookup layout 'translationPrefix)
#:pronunciationPrefix (ly:output-def-lookup layout 'pronunciationPrefix)
#:compositionPrefix (ly:output-def-lookup layout 'compositionPrefix)
#:adaptionTextPrefix (ly:output-def-lookup layout 'adaptionTextPrefix)
#:adaptionMusicPrefix (ly:output-def-lookup layout 'adaptionMusicPrefix)
#:bridgePrefix (ly:output-def-lookup layout 'bridgePrefix)
#:interludePrefix (ly:output-def-lookup layout 'interludePrefix)
) )
(if (and
(equal? poetIds composerIds)
(null? translatorIds)
(null? versePoetData)
(null? verseComposerData)
(null? voiceComposerData)
(null? compositionIds)
(null? adaptionTextIds)
(null? adaptionMusicIds)
(null? bridgeIds)
(null? interludeIds))
(list
(join-present (list
(render-contribution-group (ly:output-def-lookup layout 'poetAndComposerEqualPrefix) poetIds)
(if (equal? year_text year_melody) year_text (join-present (list year_text year_melody) "/"))
) ", ")
#f)
(list
(if (and (null? poetIds) (null? versePoetData) (null? translatorIds)) #f
(string-append
(ly:output-def-lookup layout 'poetPrefix)
" "
(join-present (list
(join-present (list
(render-contribution-group "" poetIds)
year_text
) ", ")
(render-partial-contribution-group 'versePrefix versePoetData)
(join-present (list
(render-contribution-group (ly:output-def-lookup layout 'translationAuthorPrefix) translatorIds)
year_translation
) ", ")
(join-present (list
(render-contribution-group (ly:output-def-lookup layout 'adaptionTextPrefix) adaptionTextIds)
year_adaption_text
) ", ")
) "; ")
))
(if (and
(null? composerIds)
(null? compositionIds)
(null? adaptionMusicIds)
(null? verseComposerData)
(null? voiceComposerData)
(null? bridgeIds)
(null? interludeIds)) #f
(string-append
(ly:output-def-lookup layout 'composerPrefix)
" "
(join-present (list
(join-present (list
(render-contribution-group "" composerIds)
year_melody
) ", ")
(render-partial-contribution-group 'versePrefix verseComposerData)
(render-partial-contribution-group 'voicePrefix voiceComposerData)
(join-present (list
(render-contribution-group (ly:output-def-lookup layout 'compositionPrefix) compositionIds)
year_composition
) ", ")
(join-present (list
(render-contribution-group (ly:output-def-lookup layout 'adaptionMusicPrefix) adaptionMusicIds)
year_adaption_music
) ", ")
(render-contribution-group (ly:output-def-lookup layout 'bridgePrefix) bridgeIds)
(render-contribution-group (ly:output-def-lookup layout 'interludePrefix) interludeIds)
) "; ")
)))))
(list #f #f) (list #f #f)
) )
) )