lookbook 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/lookbook/page_controller.rb +1 -1
- data/config/app.yml +1 -0
- data/lib/lookbook/preview_controller_actions.rb +17 -15
- data/lib/lookbook/services/templates/action_view_config_handler.rb +50 -0
- data/lib/lookbook/version.rb +1 -1
- data/public/lookbook-assets/css/lookbook.css +419 -232
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/js/index.js +202 -168
- data/public/lookbook-assets/js/index.js.map +1 -1
- metadata +3 -3
- data/lib/lookbook/services/templates/action_view_annotations_handler.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0277029efee9bfc07832f5bc2ea7d1a57063a81e2e2986978c93abca8750fbe2'
|
4
|
+
data.tar.gz: c03b8c178645b7dba6572d37711cb4664ea4175fa56430acd595a369069d54c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c34fbd701d1f7818dea444b9ad899b7dce012968a0cc0038dd197bf0e70ea2af105c2d299e3ac21302f9276d0dde162b56cfebb8f45ba4e7eb9c1ab1455c4555
|
7
|
+
data.tar.gz: 50613e6f04c758f5c93fa4ff659a0a0a4c1a903e80d167a3c1aead2f6e5af7278549b260255405c077fe1f35ba920fc050fdfdb0dab4d37ce7df18658f6ace47
|
@@ -15,7 +15,7 @@ module Lookbook
|
|
15
15
|
@next_page = @pages.next(@page)
|
16
16
|
@previous_page = @pages.previous(@page)
|
17
17
|
|
18
|
-
content =
|
18
|
+
content = ActionViewConfigHandler.call do
|
19
19
|
render_to_string inline: @page.content, locals: {
|
20
20
|
page: @page,
|
21
21
|
next_page: @next_page,
|
data/config/app.yml
CHANGED
@@ -21,6 +21,7 @@ shared:
|
|
21
21
|
display_option_controls: true
|
22
22
|
preview_layout: ~
|
23
23
|
preview_disable_action_view_annotations: true
|
24
|
+
preview_disable_action_view_partial_prefixes: true
|
24
25
|
preview_type_default: view_component
|
25
26
|
preview_sort_scenarios: false
|
26
27
|
preview_disable_error_handling: false
|
@@ -21,24 +21,23 @@ module Lookbook
|
|
21
21
|
opts[:assigns] = @render_args[:assigns] || {}
|
22
22
|
opts[:locals] = locals if locals.present?
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
if scenario.after_render_method.present?
|
27
|
-
render_context = Store.new({
|
28
|
-
preview: preview,
|
29
|
-
scenario: scenario,
|
30
|
-
params: user_request_parameters
|
31
|
-
})
|
32
|
-
rendered = @preview.after_render(method: scenario.after_render_method, html: rendered, context: render_context)
|
33
|
-
end
|
24
|
+
with_action_view_settings do
|
25
|
+
rendered = render_to_string(template, **opts)
|
34
26
|
|
35
|
-
|
27
|
+
if scenario.after_render_method.present?
|
28
|
+
render_context = Store.new({
|
29
|
+
preview: preview,
|
30
|
+
scenario: scenario,
|
31
|
+
params: user_request_parameters
|
32
|
+
})
|
33
|
+
rendered = @preview.after_render(method: scenario.after_render_method, html: rendered, context: render_context)
|
34
|
+
end
|
36
35
|
render html: rendered
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
39
|
def render_in_layout_to_string(template, locals, opts = {})
|
41
|
-
|
40
|
+
with_action_view_settings do
|
42
41
|
html = render_to_string(template, locals: locals, **determine_layout(opts[:layout]))
|
43
42
|
if opts[:append_html].present?
|
44
43
|
html += opts[:append_html]
|
@@ -49,9 +48,12 @@ module Lookbook
|
|
49
48
|
|
50
49
|
protected
|
51
50
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
51
|
+
def with_action_view_settings(&block)
|
52
|
+
ActionViewConfigHandler.call(
|
53
|
+
disable_annotations: Lookbook.config.preview_disable_action_view_annotations,
|
54
|
+
disable_partial_prefixes: Lookbook.config.preview_disable_action_view_partial_prefixes,
|
55
|
+
&block
|
56
|
+
)
|
55
57
|
end
|
56
58
|
|
57
59
|
def user_request_parameters
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class ActionViewConfigHandler < Service
|
3
|
+
attr_reader :disable_annotations, :disable_partial_prefixes
|
4
|
+
|
5
|
+
def initialize(disable_annotations: true, disable_partial_prefixes: true)
|
6
|
+
@disable_annotations = disable_annotations
|
7
|
+
@disable_partial_prefixes = disable_partial_prefixes
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
handle_annotations
|
12
|
+
handle_partial_prefixes
|
13
|
+
|
14
|
+
yield
|
15
|
+
ensure
|
16
|
+
restore_annotations
|
17
|
+
restore_partial_prefixes
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def handle_annotations
|
23
|
+
return unless disable_annotations && ActionView::Base.respond_to?(:annotate_rendered_view_with_filenames)
|
24
|
+
|
25
|
+
@original_annotations_value = ActionView::Base.annotate_rendered_view_with_filenames
|
26
|
+
ActionView::Base.annotate_rendered_view_with_filenames = false
|
27
|
+
end
|
28
|
+
|
29
|
+
def restore_annotations
|
30
|
+
return if @original_annotations_value.nil?
|
31
|
+
|
32
|
+
ActionView::Base.annotate_rendered_view_with_filenames = @original_annotations_value
|
33
|
+
@original_annotations_value = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def handle_partial_prefixes
|
37
|
+
return unless disable_partial_prefixes && ActionView::Base.respond_to?(:prefix_partial_path_with_controller_namespace)
|
38
|
+
|
39
|
+
@original_partial_prefix_value = ActionView::Base.prefix_partial_path_with_controller_namespace
|
40
|
+
ActionView::Base.prefix_partial_path_with_controller_namespace = false
|
41
|
+
end
|
42
|
+
|
43
|
+
def restore_partial_prefixes
|
44
|
+
return if @original_partial_prefix_value.nil?
|
45
|
+
|
46
|
+
ActionView::Base.prefix_partial_path_with_controller_namespace = @original_partial_prefix_value
|
47
|
+
@original_partial_prefix_value = nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/lookbook/version.rb
CHANGED