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
|
# File 'lib/jekyll/attendease_plugin/event_layout_generator.rb', line 16
def generate(site)
Jekyll.logger.debug "[Attendease] Generating theme layouts..."
attendease_precompiled_theme_layouts_path = File.join(site.source, 'attendease_layouts') attendease_precompiled_theme_email_layouts_path = File.join(site.source, 'attendease_layouts', 'emails') layouts_path = File.join(site.source, '_layouts')
FileUtils.mkdir_p(attendease_precompiled_theme_layouts_path)
base_layout = site.config['attendease']['base_layout'] || 'layout'
base_layout_file = File.join(layouts_path, "#{base_layout}.html")
unless File.exists?(base_layout_file)
File.open(base_layout_file, 'w+') { |f| f.write("{{ content }}") }
end
cms_layouts = []
begin
Dir.glob(File.join(layouts_path, '*.html')).each do |l|
html = File.read(l)
if html =~ %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m
data = YAML.load(Regexp.last_match(1))
if data['cms_layout']
cms_layouts << File.basename(l).split('.').first
end
end
end
rescue
end
layouts_to_precompile = %w{ layout register surveys } layouts_to_precompile.each do |layout|
unless File.exists?(File.join(attendease_precompiled_theme_layouts_path, "#{layout}.html"))
site.pages << EventLayoutPage.new(site, site.source, 'attendease_layouts', "#{layout}.html", base_layout, layout.capitalize)
end
end
cms_layouts.each do |layout|
site.pages << EventLayoutPage.new(site, site.source, 'attendease_layouts', "cms-#{layout}.html", layout, layout.capitalize)
end
base_email_layout = site.config['attendease']['base_email_layout'] || 'email'
base_email_layout_file = File.join(layouts_path, "#{base_email_layout}.html")
unless File.exists?(base_email_layout_file)
File.open(base_email_layout_file, 'w+') { |f| f.write("{{ content }}") }
end
layouts_to_precompile = %w{ layout } layouts_to_precompile.each do |layout|
unless File.exists?(File.join(attendease_precompiled_theme_email_layouts_path, "#{layout}.html"))
site.pages << EventLayoutPage.new(site, site.source, 'attendease_layouts/emails', "#{layout}.html", base_email_layout, layout.capitalize)
end
end
end
|