m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/lib/util.rb
blob: 873b6f9b501f8b8e27e191af386a9e21d4ef6a11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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_partial_tex song_id
  song "#{song_id}-partial.tex"
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