93 lines
4.5 KiB
Plaintext
93 lines
4.5 KiB
Plaintext
#(define-markup-command (print-songinfo layout props) ()
|
|
(define (songinfo-from songId key)
|
|
(let ((song (if (defined? 'SONG_DATA) (assoc-ref SONG_DATA songId) #f)))
|
|
(if song
|
|
(assoc-ref song key)
|
|
(ly:warning (ly:format "song with id ~a not found" songId)))))
|
|
|
|
(define (format-author authorId)
|
|
(let ((author (if (defined? 'AUTHOR_DATA) (assoc-ref AUTHOR_DATA authorId) #f)))
|
|
(if author
|
|
(markup
|
|
#:override (cons 'author:name (assoc-ref author "name"))
|
|
#:override (cons 'author:trail_name (assoc-ref author "trail_name"))
|
|
#:override (cons 'author:birth_year (assoc-ref author "birth_year"))
|
|
#:override (cons 'author:death_year (assoc-ref author "death_year"))
|
|
#:override (cons 'author:organization (assoc-ref author "organization"))
|
|
(ly:output-def-lookup layout 'authorMarkup))
|
|
(ly:warning (ly:format "author with id ~a not found" authorId)))))
|
|
|
|
(define (format-poet poetId)
|
|
(markup #:override (cons 'author (format-author poetId)) (ly:output-def-lookup layout 'poetMarkup)))
|
|
|
|
(define (format-composer composerId)
|
|
(markup #:override (cons 'author (format-author composerId)) (ly:output-def-lookup layout 'composerMarkup)))
|
|
|
|
(define (format-poet-and-composer authorId)
|
|
(markup #:override (cons 'author (format-author authorId)) (ly:output-def-lookup layout 'poetAndComposerEqualMarkup)))
|
|
|
|
(interpret-markup layout props
|
|
(if (chain-assoc-get 'page:is-bookpart-last-page props #f)
|
|
(let* ((songId (chain-assoc-get 'header:songId props #f))
|
|
(poetId (chain-assoc-get 'header:poetId props (if songId (songinfo-from songId "poet") #f)))
|
|
(composerId (chain-assoc-get 'header:composerId props (if songId (songinfo-from songId "composer") #f)))
|
|
(poet-and-composer-same (equal? poetId composerId)))
|
|
(let (
|
|
(blockwidth (* (chain-assoc-get 'header:songinfo-size-factor props 0.9) (ly:output-def-lookup layout 'line-width)))
|
|
(infotext (chain-assoc-get 'header:songinfo props #f))
|
|
(poet (chain-assoc-get 'header:poet props (if poetId (if poet-and-composer-same (format-poet-and-composer poetId) (format-poet poetId)) #f)))
|
|
(composer (chain-assoc-get 'header:composer props (if (and composerId (not poet-and-composer-same)) (format-composer composerId) #f)))
|
|
(poet-and-composer-stacked (chain-assoc-get 'header:poet-and-composer-stacked props songInfoPoetAndComposerStacked))
|
|
(between-poet-and-composer-markup (chain-assoc-get 'header:between-poet-and-composer-markup props (make-hspace-markup 3)))
|
|
(copyright (chain-assoc-get 'header:copyright props #f)))
|
|
(markup #:override '(baseline-skip . 3.0) (
|
|
make-fontsize-markup songInfoFontSize
|
|
(make-sans-markup
|
|
;%\override #'(line-width . 92) \wordwrap-field #symbol
|
|
(make-column-markup (list
|
|
(make-line-markup
|
|
(list
|
|
(if (and poet (not (and (string? poet) (string-null? poet)))) (markup poet between-poet-and-composer-markup) "")
|
|
(if (and composer (not poet-and-composer-stacked)) composer ""))
|
|
)
|
|
(if (and composer poet-and-composer-stacked) (make-line-markup (list composer)) "")
|
|
(make-override-markup `(line-width . ,blockwidth) (make-justify-string-markup (string-append
|
|
(if (and copyright (not (and (string? copyright) (string-null? copyright)))) (ly:format "© ~a\n\n" copyright) "")
|
|
(if infotext infotext "")
|
|
)))
|
|
)))
|
|
)
|
|
)
|
|
))
|
|
(make-null-markup)))
|
|
)
|
|
|
|
#(define-markup-command (print-pagenumber layout props)()
|
|
(let ((label (chain-assoc-get 'header:myindexlabel props #f)))
|
|
(interpret-markup layout props
|
|
(markup #:large #:bold
|
|
(if label
|
|
(make-custom-page-number-markup label (chain-assoc-get 'page:page-number props 0))
|
|
(make-fromproperty-markup 'page:page-number-string)
|
|
)
|
|
))))
|
|
|
|
\paper {
|
|
print-first-page-number = ##t
|
|
first-page-number = #0
|
|
|
|
oddFooterMarkup = \markup {
|
|
\fill-line {
|
|
\line { \null }
|
|
\line { \general-align #Y #DOWN \print-songinfo }
|
|
\line { \if \should-print-page-number \print-pagenumber }
|
|
}
|
|
}
|
|
evenFooterMarkup = \markup {
|
|
\fill-line {
|
|
\line { \if \should-print-page-number \print-pagenumber }
|
|
\line { \general-align #Y #DOWN \print-songinfo }
|
|
\line { \null }
|
|
}
|
|
}
|
|
} |