m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarcin Chrzanowski <m@m-chrzan.xyz>2021-09-12 21:19:42 +0200
committerMarcin Chrzanowski <m@m-chrzan.xyz>2021-09-12 21:19:42 +0200
commit236cbc380efbf1e36f8b31511b59298747acc0b1 (patch)
treebab73bb05120dca5a3351e02753b3f04b0853cba /lib
parent04768d5433f3fdade45b18dacf1159177f2f8fa8 (diff)
Add songbook generation
Diffstat (limited to 'lib')
-rw-r--r--lib/latex.rb23
-rw-r--r--lib/util.rb4
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/latex.rb b/lib/latex.rb
index e17a6ef..fa1094c 100644
--- a/lib/latex.rb
+++ b/lib/latex.rb
@@ -1,3 +1,9 @@
+def render_partial_latex song
+ template = tex_template 'song-partial'
+ templated = template.result binding
+ File.write(tmp(song_partial_tex song.id), templated)
+end
+
def render_latex song
template = tex_template 'song'
templated = template.result binding
@@ -10,8 +16,25 @@ def render_pdf song
system "mv #{tmp (song_pdf song.id)} #{build (song_pdf song.id)}"
end
+def render_songbook_latex songs
+ template = tex_template 'songbook'
+ templated = template.result binding
+ File.write(tmp('songbook.tex'), templated)
+end
+
+def render_songbook songs
+ render_songbook_latex songs
+ system "lualatex --shell-escape -output-directory=#{TmpDir}/ #{tmp 'songbook.tex'}"
+ # compile twice for table of contents to generate properly
+ system "lualatex --shell-escape -output-directory=#{TmpDir}/ #{tmp 'songbook.tex'}"
+ system "mv #{tmp 'songbook.pdf'} #{build 'songbook.pdf'}"
+end
+
def make_pdfs songs
songs.each_value do |song|
+ render_partial_latex song
render_pdf song
end
+
+ render_songbook songs
end
diff --git a/lib/util.rb b/lib/util.rb
index 48698ff..873b6f9 100644
--- a/lib/util.rb
+++ b/lib/util.rb
@@ -32,6 +32,10 @@ def song_meta song_id
song "#{song_id}.yaml"
end
+def song_partial_tex song_id
+ song "#{song_id}-partial.tex"
+end
+
def song_tex song_id
song "#{song_id}.tex"
end