pakyow-presenter 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -2
- data/lib/pakyow/presenter/composers/view.rb +6 -3
- data/lib/pakyow/presenter/renderer/behavior/cleanup_prototype_nodes.rb +1 -0
- data/lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb +1 -0
- data/lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb +1 -0
- data/lib/pakyow/presenter/renderer/behavior/insert_prototype_bar.rb +1 -0
- data/lib/pakyow/presenter/renderer/behavior/install_authenticity.rb +1 -0
- data/lib/pakyow/presenter/renderer/behavior/place_in_mode.rb +1 -0
- data/lib/pakyow/presenter/renderer/behavior/render_components.rb +1 -0
- data/lib/pakyow/presenter/renderer/behavior/set_page_title.rb +1 -0
- data/lib/pakyow/presenter/renderer/behavior/setup_endpoints.rb +1 -0
- data/lib/pakyow/presenter/renderer/behavior/setup_forms.rb +1 -0
- data/lib/pakyow/presenter/templates.rb +84 -72
- data/lib/string_doc.rb +7 -3
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53d31a769ac231000d460220c8b77efe9a6db7614e3da9b527f05953085de9da
|
4
|
+
data.tar.gz: c226279147bcff73dc38ee709be02b79914c26ac715d6d7706dded0b8f0858ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df02a40224c6f9aba3b711b796d0df40fb6b9a6d9957e4db69f2799b5cfac0763f26e3f0467e78b81210fe5d1db0e1cd9d7394ededb218c63e91d879321fdb57
|
7
|
+
data.tar.gz: fe85ef375749eee75124a62babf72242e9724f6625bc15fbed28083d7d3211d820ab1dba32740dddfd947d15843a94fa3826e1f21c27d20604b869277d7a8454
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
-
#
|
1
|
+
# v1.0.2 (unreleased)
|
2
2
|
|
3
|
-
|
3
|
+
* `fix` **Template store is more efficient for faster loading.**
|
4
|
+
|
5
|
+
*Related links:*
|
6
|
+
- [Pull Request #324][pr-324]
|
7
|
+
|
8
|
+
* `fix` **Now renders correctly when a collapsed string doc is transformed.**
|
9
|
+
|
10
|
+
*Related links:*
|
11
|
+
- [Commit 87b7a6c][87b7a6c]
|
12
|
+
|
13
|
+
[pr-324]: https://github.com/pakyow/pakyow/pull/324/commits
|
14
|
+
[87b7a6c]: https://github.com/pakyow/pakyow/commit/87b7a6c06a9524703dc1667b6a010930b682f6d7
|
15
|
+
|
16
|
+
# v1.0.0
|
4
17
|
|
5
18
|
* Hello, Web
|
@@ -51,9 +51,12 @@ module Pakyow
|
|
51
51
|
# mostly an optimization, since it lets us collapse some nodes into single strings and
|
52
52
|
# reduce the number of operations needed for a render.
|
53
53
|
#
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
# FIXME: This breaks when a collapsed string doc is transformed. Once that's fixed, we
|
55
|
+
# can enable this code again. It's pretty low-priority and not worth fixing right now.
|
56
|
+
#
|
57
|
+
# view.object.collapse(
|
58
|
+
# *(StringDoc.significant_types.keys - UNRETAINED_SIGNIFICANCE)
|
59
|
+
# )
|
57
60
|
|
58
61
|
# Empty nodes are removed as another render-time optimization leading to fewer operations.
|
59
62
|
#
|
@@ -17,6 +17,7 @@ module Pakyow
|
|
17
17
|
|
18
18
|
def initialize(name, path, processor: nil, config: {})
|
19
19
|
@name, @path, @processor = name, Pathname(path), processor
|
20
|
+
@layouts, @includes, @info = {}, {}, {}
|
20
21
|
build_config(config)
|
21
22
|
load_templates
|
22
23
|
end
|
@@ -99,6 +100,10 @@ module Pakyow
|
|
99
100
|
}
|
100
101
|
end
|
101
102
|
|
103
|
+
def layout_with_name(name)
|
104
|
+
@layouts[name.to_sym]
|
105
|
+
end
|
106
|
+
|
102
107
|
def load_templates
|
103
108
|
load_layouts
|
104
109
|
load_partials
|
@@ -106,62 +111,63 @@ module Pakyow
|
|
106
111
|
end
|
107
112
|
|
108
113
|
def load_layouts
|
109
|
-
|
110
|
-
layouts_path.children.each_with_object({}) { |file, layouts|
|
111
|
-
next unless template?(file)
|
112
|
-
if layout = load_view_of_type_at_path(Views::Layout, file)
|
113
|
-
layouts[layout.name] = layout
|
114
|
-
end
|
115
|
-
}
|
116
|
-
else
|
117
|
-
{}
|
118
|
-
end
|
119
|
-
end
|
114
|
+
return unless layouts_path.exist?
|
120
115
|
|
121
|
-
|
122
|
-
|
123
|
-
partials_path.children.each_with_object({}) { |file, partials|
|
124
|
-
next unless template?(file)
|
125
|
-
if partial = load_view_of_type_at_path(Views::Partial, file, normalize_path(file))
|
126
|
-
partials[partial.name] = partial
|
127
|
-
end
|
128
|
-
}
|
129
|
-
else
|
130
|
-
{}
|
131
|
-
end
|
132
|
-
end
|
116
|
+
layouts_path.children.each_with_object(@layouts) { |file, layouts|
|
117
|
+
next unless template?(file)
|
133
118
|
|
134
|
-
|
135
|
-
|
119
|
+
if layout = load_view_of_type_at_path(Views::Layout, file)
|
120
|
+
layouts[layout.name] = layout
|
121
|
+
end
|
122
|
+
}
|
123
|
+
end
|
136
124
|
|
137
|
-
|
138
|
-
|
139
|
-
next if path.basename.to_s.start_with?("_")
|
125
|
+
def load_partials
|
126
|
+
return unless partials_path.exist?
|
140
127
|
|
141
|
-
|
128
|
+
partials_path.children.each_with_object(@includes) { |file, partials|
|
129
|
+
next unless template?(file)
|
142
130
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
partials: @includes.merge(partials_at_path(path))
|
149
|
-
}
|
150
|
-
end
|
151
|
-
rescue FrontMatterParsingError => e
|
152
|
-
message = "Could not parse front matter for #{path}:\n\n#{e.context}"
|
131
|
+
if partial = load_view_of_type_at_path(Views::Partial, file, normalize_path(file))
|
132
|
+
partials[partial.name] = partial
|
133
|
+
end
|
134
|
+
}
|
135
|
+
end
|
153
136
|
|
154
|
-
|
155
|
-
|
156
|
-
|
137
|
+
def load_path_info
|
138
|
+
pages_path.glob("**/*").select { |path|
|
139
|
+
template?(path)
|
140
|
+
}.reject { |path|
|
141
|
+
path.basename.to_s.start_with?("_")
|
142
|
+
}.each do |path|
|
143
|
+
if page = page_at_path(path)
|
144
|
+
path_to_page = String.normalize_path(
|
145
|
+
File.join(
|
146
|
+
@config[:prefix], normalize_path(path, pages_path)
|
147
|
+
)
|
148
|
+
)
|
149
|
+
|
150
|
+
@info[path_to_page] = {
|
151
|
+
page: page,
|
152
|
+
|
153
|
+
layout: layout_with_name(
|
154
|
+
page.info(:layout)
|
155
|
+
),
|
156
|
+
|
157
|
+
partials: @includes.merge(
|
158
|
+
partials_at_path(path)
|
159
|
+
)
|
160
|
+
}
|
161
|
+
end
|
162
|
+
rescue FrontMatterParsingError => e
|
163
|
+
message = "Could not parse front matter for #{path}:\n\n#{e.context}"
|
157
164
|
|
158
|
-
|
165
|
+
if e.wrapped_exception
|
166
|
+
message << "\n#{e.wrapped_exception.problem} at line #{e.wrapped_exception.line} column #{e.wrapped_exception.column}"
|
159
167
|
end
|
160
|
-
end
|
161
|
-
end
|
162
168
|
|
163
|
-
|
164
|
-
|
169
|
+
raise FrontMatterParsingError.new(message)
|
170
|
+
end
|
165
171
|
end
|
166
172
|
|
167
173
|
def page_at_path(path)
|
@@ -175,38 +181,15 @@ module Pakyow
|
|
175
181
|
end
|
176
182
|
|
177
183
|
def index_page_at_path(path)
|
178
|
-
|
179
|
-
path.ascend do |parent_path|
|
184
|
+
ascend(path) do |parent_path|
|
180
185
|
next unless info = info(normalize_path(parent_path))
|
181
186
|
next unless page = info[:page]
|
182
187
|
return page
|
183
188
|
end
|
184
189
|
end
|
185
190
|
|
186
|
-
# TODO: do we always need to make it relative, etc here?
|
187
|
-
# maybe break up these responsibilities to the bare minimum required
|
188
|
-
def normalize_path(path, relative_from = @path)
|
189
|
-
path = path.expand_path
|
190
|
-
relative_from = relative_from.expand_path
|
191
|
-
|
192
|
-
# make it relative
|
193
|
-
path = path.relative_path_from(relative_from)
|
194
|
-
# we can short-circuit here
|
195
|
-
return "/" if path.to_s == "."
|
196
|
-
|
197
|
-
# remove the extension
|
198
|
-
path = path.sub_ext("")
|
199
|
-
|
200
|
-
# remove index from the end
|
201
|
-
path = path.sub("index", "")
|
202
|
-
|
203
|
-
# actually normalize it
|
204
|
-
String.normalize_path(path.to_s)
|
205
|
-
end
|
206
|
-
|
207
191
|
def partials_at_path(path)
|
208
|
-
|
209
|
-
path.ascend.select(&:directory?).each_with_object({}) { |parent_path, partials|
|
192
|
+
ascend(path).select(&:directory?).each_with_object({}) { |parent_path, partials|
|
210
193
|
parent_path.children.select { |child|
|
211
194
|
child.basename.to_s.start_with?("_")
|
212
195
|
}.each_with_object(partials) { |child, child_partials|
|
@@ -233,6 +216,35 @@ module Pakyow
|
|
233
216
|
nil
|
234
217
|
end
|
235
218
|
end
|
219
|
+
|
220
|
+
def ascend(path)
|
221
|
+
return enum_for(:ascend, path) unless block_given?
|
222
|
+
|
223
|
+
path.ascend.each do |path|
|
224
|
+
yield path
|
225
|
+
|
226
|
+
if path == @path
|
227
|
+
break
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def normalize_path(path, relative_from = @path)
|
233
|
+
# make it relative
|
234
|
+
path = path.expand_path.relative_path_from(relative_from.expand_path)
|
235
|
+
|
236
|
+
# we can short-circuit here
|
237
|
+
return "/" if path.to_s == "."
|
238
|
+
|
239
|
+
# remove the extension
|
240
|
+
path = path.sub_ext("")
|
241
|
+
|
242
|
+
# remove index from the end
|
243
|
+
path = path.sub("index", "")
|
244
|
+
|
245
|
+
# actually normalize it
|
246
|
+
String.normalize_path(path.to_s)
|
247
|
+
end
|
236
248
|
end
|
237
249
|
end
|
238
250
|
end
|
data/lib/string_doc.rb
CHANGED
@@ -444,8 +444,12 @@ class StringDoc
|
|
444
444
|
# Returns the node as an xml string, without transforming.
|
445
445
|
#
|
446
446
|
def to_s
|
447
|
-
|
448
|
-
|
447
|
+
if collapsed && empty?
|
448
|
+
collapsed
|
449
|
+
else
|
450
|
+
@nodes.each_with_object(String.new) do |node, string|
|
451
|
+
string << node.to_s
|
452
|
+
end
|
449
453
|
end
|
450
454
|
end
|
451
455
|
|
@@ -459,7 +463,7 @@ class StringDoc
|
|
459
463
|
node.children.collapse(*significance)
|
460
464
|
end
|
461
465
|
else
|
462
|
-
@collapsed =
|
466
|
+
@collapsed = render
|
463
467
|
@nodes = []
|
464
468
|
end
|
465
469
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pakyow-presenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pakyow-core
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.
|
19
|
+
version: 1.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.
|
26
|
+
version: 1.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pakyow-routing
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.
|
33
|
+
version: 1.0.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.
|
40
|
+
version: 1.0.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pakyow-support
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.0.
|
47
|
+
version: 1.0.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0.
|
54
|
+
version: 1.0.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: oga
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.5'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.5'
|
83
83
|
description: Views and presentation for Pakyow
|
84
84
|
email: bryan@bryanp.org
|
85
85
|
executables: []
|