2023-07-22 22:07:57 +02:00
|
|
|
#(define-markup-command (print-songinfo layout props) ()
|
2023-08-20 12:14:30 +02:00
|
|
|
(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)))))
|
|
|
|
|
2023-08-11 16:25:06 +02:00
|
|
|
(define (format-author authorId)
|
2023-08-20 12:14:30 +02:00
|
|
|
(let ((author (if (defined? 'AUTHOR_DATA) (assoc-ref AUTHOR_DATA authorId) #f)))
|
2023-08-11 16:25:06 +02:00
|
|
|
(if author
|
|
|
|
(markup
|
2023-08-20 12:14:30 +02:00
|
|
|
#: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"))
|
2023-08-11 16:25:06 +02:00
|
|
|
(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)
|
2023-08-20 12:14:30 +02:00
|
|
|
(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)))
|
2023-11-01 09:48:52 +01:00
|
|
|
(let ((infotext (chain-assoc-get 'header:infotext props (chain-assoc-get 'header:songinfo props #f)))
|
2023-10-31 13:31:50 +01:00
|
|
|
(poet-maybe-with-composer (chain-assoc-get 'header:poet props (if poetId (if poet-and-composer-same (format-poet-and-composer poetId) (format-poet poetId)) #f)))
|
2023-08-11 16:25:06 +02:00
|
|
|
(composer (chain-assoc-get 'header:composer props (if (and composerId (not poet-and-composer-same)) (format-composer composerId) #f)))
|
2023-10-31 13:31:50 +01:00
|
|
|
(copyright (chain-assoc-get 'header:copyright props #f))
|
|
|
|
(translation (chain-assoc-get 'header:translation props #f))
|
|
|
|
(spelling (chain-assoc-get 'header:spelling props #f))
|
|
|
|
(year_text (chain-assoc-get 'header:year_text props #f))
|
|
|
|
(year_melody (chain-assoc-get 'header:year_melody props #f)))
|
|
|
|
(markup
|
|
|
|
#:override (cons 'songinfo:poet-maybe-with-composer
|
|
|
|
(if (and poet-maybe-with-composer (not (and (string? poet-maybe-with-composer) (string-null? poet-maybe-with-composer)))) poet-maybe-with-composer #f))
|
|
|
|
#:override (cons 'songinfo:composer
|
|
|
|
(if (and composer (not (and (string? composer) (string-null? composer)))) composer #f))
|
|
|
|
#:override (cons 'songinfo:copyright
|
|
|
|
(if (and copyright (not (and (string? copyright) (string-null? copyright)))) copyright #f))
|
|
|
|
#:override (cons 'songinfo:infotext
|
|
|
|
(if (and infotext (not (and (string? infotext) (string-null? infotext)))) infotext #f))
|
|
|
|
#:override (cons 'songinfo:translation
|
|
|
|
(if (and translation (not (and (string? translation) (string-null? translation)))) translation #f))
|
|
|
|
#:override (cons 'songinfo:spelling
|
|
|
|
(if (and spelling (not (and (string? spelling) (string-null? spelling)))) spelling #f))
|
|
|
|
#:override (cons 'songinfo:year_text
|
|
|
|
(if (and year_text (not (and (string? year_text) (string-null? year_text)))) year_text #f))
|
|
|
|
#:override (cons 'songinfo:year_melody
|
|
|
|
(if (and year_melody (not (and (string? year_melody) (string-null? year_melody)))) year_melody #f))
|
2023-10-31 18:47:47 +01:00
|
|
|
#:override '(baseline-skip . 3.0)
|
|
|
|
#:fontsize songInfoFontSize
|
|
|
|
#:sans
|
2023-10-31 13:31:50 +01:00
|
|
|
(ly:output-def-lookup layout 'songinfoMarkup)
|
|
|
|
)))
|
2023-08-11 16:25:06 +02:00
|
|
|
(make-null-markup)))
|
2023-07-22 22:07:57 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
#(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)
|
|
|
|
)
|
|
|
|
))))
|
|
|
|
|
2023-11-01 09:48:52 +01:00
|
|
|
#(define-markup-command (fractional-line-width layout props arg)(markup?)
|
|
|
|
(interpret-markup layout props
|
|
|
|
(make-override-markup
|
|
|
|
`(line-width . ,(* (chain-assoc-get 'header:songinfo-size-factor props 0.9) (ly:output-def-lookup layout 'line-width)))
|
|
|
|
arg)))
|
|
|
|
|
2023-07-22 22:07:57 +02:00
|
|
|
\paper {
|
|
|
|
print-first-page-number = ##t
|
|
|
|
first-page-number = #0
|
|
|
|
|
|
|
|
oddFooterMarkup = \markup {
|
|
|
|
\fill-line {
|
|
|
|
\line { \null }
|
2023-11-01 09:48:52 +01:00
|
|
|
\line { \general-align #Y #DOWN \fractional-line-width \print-songinfo }
|
2023-07-22 22:07:57 +02:00
|
|
|
\line { \if \should-print-page-number \print-pagenumber }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
evenFooterMarkup = \markup {
|
|
|
|
\fill-line {
|
|
|
|
\line { \if \should-print-page-number \print-pagenumber }
|
2023-11-01 09:48:52 +01:00
|
|
|
\line { \general-align #Y #DOWN \fractional-line-width \print-songinfo }
|
2023-07-22 22:07:57 +02:00
|
|
|
\line { \null }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|