m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/lib/util.rb
diff options
context:
space:
mode:
authorMarcin Chrzanowski <m@m-chrzan.xyz>2021-09-12 14:17:19 +0200
committerMarcin Chrzanowski <m@m-chrzan.xyz>2021-09-12 14:17:19 +0200
commitf3039744d72454e7e3b8cb1032266bcc172ce488 (patch)
tree5a92a698056e2cbec6f0b121a9ce31596e4a4581 /lib/util.rb
Initial commit
Diffstat (limited to 'lib/util.rb')
-rw-r--r--lib/util.rb85
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/util.rb b/lib/util.rb
new file mode 100644
index 0000000..48698ff
--- /dev/null
+++ b/lib/util.rb
@@ -0,0 +1,85 @@
+SongsDir = 'songs'
+SrcDir = 'src'
+BuildDir = 'public'
+TmpDir = 'tmp'
+TemplatesDir = 'templates'
+
+def song filename
+ File.join SongsDir, filename
+end
+
+def build filename
+ File.join BuildDir, filename
+end
+
+def tmp filename
+ File.join TmpDir, filename
+end
+
+def src filename
+ File.join SrcDir, filename
+end
+
+def song_lyrics song_id
+ song "#{song_id}.txt"
+end
+
+def song_ly song_id
+ song "#{song_id}.ly"
+end
+
+def song_meta song_id
+ song "#{song_id}.yaml"
+end
+
+def song_tex song_id
+ song "#{song_id}.tex"
+end
+
+def song_sheet_pdf song_id
+ song "#{song_id}.cropped.pdf"
+end
+
+def song_tmp_svg song_id
+ song "#{song_id}.cropped.svg"
+end
+
+def song_pdf song_id
+ song "#{song_id}.pdf"
+end
+
+def song_sheet_svg song_id
+ song "#{song_id}.svg"
+end
+
+def song_svg song_id
+ song "#{song_id}.svg"
+end
+
+def song_html song_id
+ song "#{song_id}.html"
+end
+
+def template filename
+ ERB.new(File.read(filename), trim_mode: '-')
+end
+
+def template_file filename
+ File.join TemplatesDir, filename
+end
+
+def tex_template name
+ template(template_file "#{name}.tex.erb")
+end
+
+def html_template name
+ template(template_file "#{name}.html.erb")
+end
+
+def page_template
+ html_template 'template'
+end
+
+def path_to asset_id
+ P.path_to asset_id
+end