-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathimpress.rb
78 lines (60 loc) · 1.68 KB
/
impress.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
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
#!/usr/bin/env ruby
require "rubygems"
require "haml"
require "yaml"
require 'choice'
Choice.options do
header 'Application options:'
separator 'Required:'
option :slide_settings, :required => true do
short '-s'
long '--slide-settings=SETTINGS_YAML'
desc 'The YAML file containing the slide settings.'
end
option :slides_folder, :required => true do
short '-f'
long '--slides-folder=FOLDER'
desc 'The path to folder containing individual slides.'
end
separator 'Optional:'
option :layout_template do
short '-l'
long '--layout-template=LAYOUT_FILE'
desc 'The file to use as the layout template'
default 'templates/layout.html.haml'
end
option :slide_template do
short '-t'
long '--slide-template=SLIDE_FILE'
desc 'The file to use as the slide template'
default 'templates/slide.html.haml'
end
separator 'Common:'
option :help do
short '-h'
long '--help'
desc 'Show this message.'
end
option :version do
short '-v'
long '--version'
desc 'Show version.'
action do
puts 'impress.js renderer version 1.0'
exit
end
end
end
slides = YAML::load( File.read(Choice.choices.slide_settings) )
haml = Haml::Engine.new(File.read(Choice.choices.layout_template)).render do
slides_html = slides.each_with_index.map do |slide, index|
slide = {:name => "", :cls => [], :data => {}, :slide_partial => "#{ index + 1 }.html.haml"}.merge(slide)
slide_partial = File.join(Choice.choices.slides_folder, slide.delete(:slide_partial))
slide = Haml::Engine.new(File.read(Choice.choices.slide_template)).render(Object.new, slide) do
Haml::Engine.new(File.read(slide_partial)).render
end
slide
end
slides_html.join("")
end
puts haml