-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.generator.rb
executable file
·45 lines (37 loc) · 1.3 KB
/
.generator.rb
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
#!/usr/bin/env ruby
require 'yaml'
require 'ERB'
class Generator
def initialize(lang)
@lang = lang
@text = YAML.load_file(".text_#{lang}.yml")
@speakers = YAML.load_file(".speakers_#{lang}.yml")
@rfd_speakers = YAML.load_file(".rfd_speakers_#{lang}.yml")
end
def t(key)
@text[key]
end
def html_result
write_html @lang + '/index.html', ERB.new( File.open(".index.html.erb").read ).result(binding)
write_html @lang + '/program.html', ERB.new( File.open(".program.html.erb").read ).result(binding)
write_html @lang + '/rfd.html', ERB.new( File.open(".rfd.html.erb").read ).result(binding)
write_html @lang + '/schedule.html', ERB.new( File.open(".schedule.html.erb").read ).result(binding)
write_html @lang + '/app.html', ERB.new( File.open(".app.html.erb").read ).result(binding)
end
def schedule_talk(id, rfd = false)
if rfd
"<a href=\"rfd.html##{id}\">#{@rfd_speakers[id]['title']}</a><span>#{@rfd_speakers[id]['full_name']}</span>"
else
"<a href=\"program.html##{id}\">#{@speakers[id]['title']}</a><span>#{@speakers[id]['full_name']}</span>"
end
end
private
def write_html(file, html)
File.open(file, 'w'){|f| f.write html}
end
end
if ARGV[0].nil?
printf "usage: %s [en|es]\n", $0
exit
end
puts Generator.new(ARGV[0]).html_result