-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.rb
More file actions
31 lines (25 loc) · 1.04 KB
/
process.rb
File metadata and controls
31 lines (25 loc) · 1.04 KB
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
require 'slim'
require 'yaml'
require 'fileutils'
Dir.chdir "talks"
BASE_PATH = ".."
def render_partial(name, attributes={})
Slim::Template.new("#{BASE_PATH}/templates/#{name}.slim").render(Object.new, attributes)
end
volumes = (Dir.glob "*.yaml").map do |filename|
volume = YAML.load_file(filename)
volume["id"] = filename.gsub(".yaml", "")
volume
end
volumes.each do |volume|
volume["talks"].each do |talk|
siblings = volume["talks"] - [talk]
content = Slim::Template.new("#{BASE_PATH}/templates/talk.slim", {:pretty => true}).render(Object.new, talk: talk, volume: volume["id"], siblings: siblings, size: volume["video_size"])
File.open("#{BASE_PATH}/output/#{talk["slug"]}.html", "w") { |file| file.write(content) }
end
end
# Generate index file
content = Slim::Template.new("#{BASE_PATH}/templates/index.slim").render(Object.new, volumes: volumes.reverse)
File.open("#{BASE_PATH}/output/index.html", "w") { |file| file.write(content) }
# Copy assets -- TODO: minify stylesheets
FileUtils.cp_r "#{BASE_PATH}/assets", "#{BASE_PATH}/output/"