lb-project 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lb/project/roda.rb +14 -9
- data/lib/lb/project/version.rb +1 -1
- data/lib/lb/project/view.rb +26 -1
- data/spec/shared/setup.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '06996fcfa5635e9e17d9a7e9468caaba7202076f3830b5f7b8b410e2b383fc3f'
|
4
|
+
data.tar.gz: 6fb9a7e95fa4add0ee698c483b3411b805fda49be01884f5f12374b7b0f0a9ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 469efbc9289a0daf4da1faf2f599a9e834b270586b7563709d7d0bad085f8ea38575c2434e38d5ee0c53d1ec58c9542a3b79dc884f9eb5c2c9ae56c7df685696
|
7
|
+
data.tar.gz: b061f346767b0eafd36ded6583aee10e446744ec549f317fc9d1ade3ad1af070b611d063c905b1ef95a2b0ece774bb98b70fb6c805e0067aca54b6fd80c45a49
|
data/lib/lb/project/roda.rb
CHANGED
@@ -8,8 +8,20 @@ class Roda
|
|
8
8
|
# Plugin instance methods
|
9
9
|
module InstanceMethods
|
10
10
|
def page(name, overrides = {})
|
11
|
-
|
12
|
-
|
11
|
+
view_for(LB::Project::Page.page_registry, name, overrides)
|
12
|
+
end
|
13
|
+
|
14
|
+
def view(name, overrides = {})
|
15
|
+
view_for(LB::Project::View.view_registry, name, overrides)
|
16
|
+
end
|
17
|
+
|
18
|
+
def view_for(registry, name, overrides)
|
19
|
+
registry[name].new.with(overrides.merge(site: current_site)).render
|
20
|
+
end
|
21
|
+
|
22
|
+
def flush_flash
|
23
|
+
flash.keep
|
24
|
+
flash.sweep
|
13
25
|
end
|
14
26
|
|
15
27
|
private
|
@@ -18,13 +30,6 @@ class Roda
|
|
18
30
|
site.with_flash(flash)
|
19
31
|
end
|
20
32
|
|
21
|
-
def current_context(page)
|
22
|
-
{
|
23
|
-
context: ::Struct.new(:site, :page).new(current_site, page),
|
24
|
-
locals: {}
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
33
|
def site
|
29
34
|
LB::Project.settings.site.new.with(csrf_config.merge(session_config))
|
30
35
|
end
|
data/lib/lb/project/version.rb
CHANGED
data/lib/lb/project/view.rb
CHANGED
@@ -11,9 +11,34 @@ module LB
|
|
11
11
|
view.setting :layout, layout
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
attr_reader :site
|
15
|
+
|
16
|
+
def with(options)
|
17
|
+
@site = options.fetch(:site, LB::Project.settings.site.new)
|
15
18
|
self
|
16
19
|
end
|
20
|
+
|
21
|
+
def view(name, overrides = {})
|
22
|
+
LB::Project::View.view_registry[name]
|
23
|
+
.new
|
24
|
+
.with(overrides.merge(site: site))
|
25
|
+
.render
|
26
|
+
end
|
27
|
+
|
28
|
+
def render(locals = {})
|
29
|
+
render_with(site, self, locals)
|
30
|
+
end
|
31
|
+
|
32
|
+
def render_with(site, page, locals = {})
|
33
|
+
call(with_context(site, page, locals))
|
34
|
+
end
|
35
|
+
|
36
|
+
def with_context(site, page, locals = {})
|
37
|
+
{
|
38
|
+
context: ::Struct.new(:site, :page).new(site, page),
|
39
|
+
locals: locals
|
40
|
+
}
|
41
|
+
end
|
17
42
|
end
|
18
43
|
end
|
19
44
|
end
|
data/spec/shared/setup.rb
CHANGED