archival 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/archival.gemspec +1 -1
- data/lib/archival/builder.rb +41 -10
- data/lib/archival/version.rb +1 -1
- data/package.json +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7403410bc5164f3be23c22494a716fe7af6d6e805fc38ddb12c920bed918dba7
|
4
|
+
data.tar.gz: ebb064928f3295b914609a9751c11cf663ae54af6671b655def56f5d03dab93e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 866d33fea5f99757f5a5a01254769ba4a1527341f0f68df03c0daeda38fc642a5177c011d18a902937b72027c2061f92efb0eddea765eae295b520c562188f74
|
7
|
+
data.tar.gz: 802638fe184d75b2596bfbb378e02fe8de985bfdda46463dcba009937493faef442c65280307a7d3d25fd3ecbc762584846d305f3e7ceb2cf4bf4949cfe5d057
|
data/archival.gemspec
CHANGED
data/lib/archival/builder.rb
CHANGED
@@ -35,6 +35,8 @@ module Archival
|
|
35
35
|
@variables = {}
|
36
36
|
@object_types = {}
|
37
37
|
@page_templates = {}
|
38
|
+
@dynamic_pages = Set.new
|
39
|
+
@dynamic_templates = {}
|
38
40
|
|
39
41
|
Liquid::Template.file_system = Liquid::LocalFileSystem.new(
|
40
42
|
File.join(@config.root, @config.pages_dir), '_%s.liquid'
|
@@ -46,8 +48,8 @@ module Archival
|
|
46
48
|
@object_types = Tomlrb.load_file(objects_definition_file)
|
47
49
|
end
|
48
50
|
|
49
|
-
update_pages
|
50
51
|
update_objects
|
52
|
+
update_pages
|
51
53
|
end
|
52
54
|
|
53
55
|
def full_rebuild
|
@@ -59,6 +61,16 @@ module Archival
|
|
59
61
|
do_update_pages(File.join(@config.root, @config.pages_dir))
|
60
62
|
end
|
61
63
|
|
64
|
+
def dynamic?(file)
|
65
|
+
@dynamic_pages.include? File.basename(file, '.liquid')
|
66
|
+
end
|
67
|
+
|
68
|
+
def template_for_page(template_file)
|
69
|
+
content = @file_system.read_template_file(template_file)
|
70
|
+
content += dev_mode_content if @config.dev_mode
|
71
|
+
Liquid::Template.parse(content)
|
72
|
+
end
|
73
|
+
|
62
74
|
def do_update_pages(dir, prefix = nil)
|
63
75
|
add_prefix = lambda { |entry|
|
64
76
|
prefix ? File.join(prefix, entry) : entry
|
@@ -72,14 +84,13 @@ module Archival
|
|
72
84
|
add_prefix(entry))
|
73
85
|
end
|
74
86
|
elsif File.file? File.join(dir, entry)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
template_file =
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
Liquid::Template.parse(content)
|
87
|
+
page_name = File.basename(entry, '.liquid')
|
88
|
+
template_file = add_prefix.call(page_name)
|
89
|
+
if dynamic? entry
|
90
|
+
@dynamic_templates[template_file] = template_for_page(template_file)
|
91
|
+
elsif entry.end_with?('.liquid') && !(entry.start_with? '_')
|
92
|
+
@page_templates[template_file] =
|
93
|
+
template_for_page(template_file)
|
83
94
|
end
|
84
95
|
end
|
85
96
|
end
|
@@ -104,6 +115,9 @@ module Archival
|
|
104
115
|
object[:name] =
|
105
116
|
File.basename(file, '.toml')
|
106
117
|
objects[name][object[:name]] = parse_object(object, definition)
|
118
|
+
if definition.key? 'template'
|
119
|
+
@dynamic_pages << definition['template']
|
120
|
+
end
|
107
121
|
end
|
108
122
|
end
|
109
123
|
end
|
@@ -147,18 +161,35 @@ module Archival
|
|
147
161
|
template.render(@variables)
|
148
162
|
end
|
149
163
|
|
164
|
+
def render_dynamic(page, obj)
|
165
|
+
template = @dynamic_templates[page]
|
166
|
+
template.render(@variables.merge({ page => obj }))
|
167
|
+
end
|
168
|
+
|
150
169
|
def write_all
|
151
170
|
Dir.mkdir(@config.build_dir) unless File.exist? @config.build_dir
|
152
171
|
@page_templates.each_key do |template|
|
153
172
|
out_dir = File.join(@config.build_dir,
|
154
173
|
File.dirname(template))
|
155
174
|
Dir.mkdir(out_dir) unless File.exist? out_dir
|
156
|
-
out_path = File.join(
|
175
|
+
out_path = File.join(out_dir,
|
157
176
|
"#{template}.html")
|
158
177
|
File.open(out_path, 'w+') do |file|
|
159
178
|
file.write(render(template))
|
160
179
|
end
|
161
180
|
end
|
181
|
+
@dynamic_pages.each do |page|
|
182
|
+
out_dir = File.join(@config.build_dir, page)
|
183
|
+
Dir.mkdir(out_dir) unless File.exist? out_dir
|
184
|
+
objects = @variables['objects'][page]
|
185
|
+
objects.each do |obj|
|
186
|
+
out_path = File.join(out_dir, "#{obj[:name]}.html")
|
187
|
+
obj['path'] = out_path
|
188
|
+
File.open(out_path, 'w+') do |file|
|
189
|
+
file.write(render_dynamic(page, obj))
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
162
193
|
return if @config.dev_mode
|
163
194
|
|
164
195
|
# in production, also copy all assets to the dist folder.
|
data/lib/archival/version.rb
CHANGED
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: archival
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Ditson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|