diff --git a/Makefile b/Makefile index 5e168c7..501ff9b 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,15 @@ -docker = podman build_dir = build -template_dir = templates config_dir = config +docker = podman +library_dir = library +propers_dir = propers +template_dir = templates +tex_deps = $(template_dir)/*.tt $(library_dir)/*/*/*.tt $(propers_dir)/*.tt $(config_dir)/song_choices.csv $(config_dir)/qr_codes.csv $(config_dir)/variables.tt .PHONY: all all: leadsheet_collection.pdf choir_scores.pdf print_a3.pdf clean_intermediate #print_a4.pdf %.pdf: build $(MAKE) -C $(build_dir) $@ +songsheet.tex: $(template_dir)/songsheet.tt $(tex_deps) $(template_dir)/header.tt $(template_dir)/head.tt $(template_dir)/footer.tt %.tex: build $(MAKE) -C $(template_dir) $@ clean_intermediate: diff --git a/templates/Makefile b/templates/Makefile index fb205fa..3534c9a 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -2,7 +2,7 @@ build_dir = ../build library_dir = ../library propers_dir = ../propers config_dir = ../config -tex_deps = *.tt $(library_dir)/*/*/*.tt $(config_dir)/song_choices.csv $(propers_dir)/*.tt +tex_deps = *.tt $(library_dir)/*/*/*.tt $(propers_dir)/*.tt $(config_dir)/song_choices.csv $(config_dir)/variables.tt songsheet.tex: songsheet.tt $(tex_deps) header.tt head.tt footer.tt tpage $< > $(build_dir)/$@ musician_scores.tex: musician_scores.tt $(tex_deps) diff --git a/templates/musician_scores.tt b/templates/musician_scores.tt index 9d9d10f..6248b55 100644 --- a/templates/musician_scores.tt +++ b/templates/musician_scores.tt @@ -77,17 +77,17 @@ RawFeature = {+ss06} [% USE song_choices = datafile("${config_dir}/song_choices.csv", delim= '|') %] [% IF parts == 0 -%] - parts = ensemble +parts = ensemble [% END -%] [% FOREACH song = song_choices %] \newpage - [% template = song.template == '' ? "song_template.tt" : song.template -%] - [% INCLUDE "$template" - purpose = song.purpose - title = song.title - content = song.content - variables = song.variables ? "${song.variables}/assignments.tt" : '' - %] +[% template = song.template == '' ? "song_template.tt" : song.template -%] +[% INCLUDE "$template" + purpose = song.purpose + title = song.title + content = song.content + variables = song.variables ? "${library_dir}/${song.variables}/assignments.tt" : '' +%] [% END %] \end{document} diff --git a/templates/song_template.tt b/templates/song_template.tt index e6dfedc..b548227 100644 --- a/templates/song_template.tt +++ b/templates/song_template.tt @@ -4,51 +4,55 @@ END; -%] \song{[% purpose_print ? purpose_print : purpose %]}{[% song_title -%]}{ - [% before_song -%] - \begin{samepage} - [% IF scores -%] - [% IF scores.gregorian AND (gregorian OR NOT scores.congregation) -%] - [% IF NOT gregorian -%] - \textbf{\LARGE{Activate gregorian}} - [% ELSE -%] - \gregorioscore{gregorio_scores/[% scores.gregorian %]} - [% END -%] - [% ELSE -%] -\lilypondfile{[% IF parts; - IF parts == 'band'; - IF scores.leadsheet; - GET "${library_dir}/${scores.leadsheet}"; +[% before_song -%] +\begin{samepage} +[% IF scores; + IF scores.gregorian AND (gregorian OR NOT scores.congregation); + IF NOT gregorian; + GET "\\textbf{\\LARGE{Activate gregorian}}\n"; ELSE; - GET "${library_dir}/${scores.SATB}"; + GET "\\gregorioscore{gregorio_scores/${scores.gregorian}}\n"; END; - ELSIF parts == 'SATB'; - IF scores.SATB; - GET "${library_dir}/${scores.SATB}"; - ELSE; - GET "${library_dir}/${scores.leadsheet}"; + ELSE; + GET '\lilypondfile{'; + IF parts; + IF parts == 'band'; + IF scores.leadsheet; + GET "${library_dir}/${scores.leadsheet}"; + ELSE; + GET "${library_dir}/${scores.SATB}"; + END; + ELSIF parts == 'SATB'; + IF scores.SATB; + GET "${library_dir}/${scores.SATB}"; + ELSE; + GET "${library_dir}/${scores.leadsheet}"; + END; END; + ELSE; + GET "${library_dir}/${scores.congregation}"; END; -ELSE; - GET "${library_dir}/${scores.congregation}"; -END; %]} - [% END -%] - [% ELSIF lyrics -%] - [% lyrics %] - [% END -%] - [% IF credits -%] - \leavevmode\\* - [% FOREACH key = credits.keys -%] - \[% key %]{[% credits.$key %]} - [% END -%] - [% END -%] - \end{samepage} - [% content -%] - [% IF (meditation && meditations) || (parts && meditation) -%] - \leavevmode\par\smallskip - [% meditation %] - [% END -%] - [% IF after_song -%] - \leavevmode\par\smallskip - [% after_song %] - [% END -%] + GET "}\n"; +END; +ELSIF lyrics; + GET lyrics; +END; %] +[% IF credits -%] +\leavevmode\\* +[% FOREACH key = credits.keys; +# Workaround because PERL keeps resolving \\$ to $ + s = "\\ ${key}{${credits.$key}}\n"; + GET s.replace('(\W) ', '$1'); +END; -%] +[% END -%] +\end{samepage} +[% content -%] +[% IF (meditation && meditations) || (parts && meditation) -%] + \leavevmode\par\smallskip + [% meditation %] +[% END -%] +[% IF after_song -%] + \leavevmode\par\smallskip + [% after_song %] +[% END -%] } diff --git a/templates/songsheet.tt b/templates/songsheet.tt index fd49da5..ad239a2 100644 --- a/templates/songsheet.tt +++ b/templates/songsheet.tt @@ -7,12 +7,12 @@ [% USE song_choices = datafile("${config_dir}/song_choices.csv", delim= '|') %] [% FOREACH song = song_choices %] - [% template = song.template == '' ? "song_template.tt" : song.template -%] - [% INCLUDE "$template" - purpose = song.purpose - content = song.content - variables = song.variables ? "${song.variables}/assignments.tt" : '' - %] +[% template = song.template == '' ? "song_template.tt" : song.template -%] +[% INCLUDE "$template" + purpose = song.purpose + content = song.content + variables = song.variables ? "${library_dir}/${song.variables}/assignments.tt" : '' +%] [% END %] [% INCLUDE footer.tt %] diff --git a/templates/variables.tt b/templates/variables.tt index d750fe9..691112c 100644 --- a/templates/variables.tt +++ b/templates/variables.tt @@ -10,9 +10,10 @@ meditations = 0 config_dir = '../config' library_dir = '../library' + propers_dir = '../propers/' -%] [% PROCESS "${config_dir}/variables.tt"; IF proper != ''; - PROCESS "propers/${proper}.tt"; + PROCESS "${propers_dir}/${proper}.tt"; END; -%]