Class: Lookbook::PreviewsController
Class Method Summary
collapse
Instance Method Summary
collapse
#preview_controller
#inspector_data, #lookup_entities, #path_segments, #set_display_options, #set_params, #set_title, #show_404
Class Method Details
.controller_path ⇒ Object
11
12
13
|
# File 'app/controllers/lookbook/previews_controller.rb', line 11
def self.controller_path
"lookbook/previews"
end
|
Instance Method Details
#index ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/lookbook/previews_controller.rb', line 15
def index
respond_to do |format|
format.json do
render(
json: Lookbook.previews.map do |preview|
{
name: preview.name,
examples: preview.examples.map { |example|
case example
when Lookbook::PreviewExample
example_json(example)
when Lookbook::PreviewGroup
{
name: example.name,
examples: example.examples.map { |ex| example_json(ex) }
}
end
}
}
end
)
end
end
end
|
#show ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'app/controllers/lookbook/previews_controller.rb', line 40
def show
if @target
begin
opts = {layout: @preview.layout}
if params[:lookbook_embed] == "true"
opts[:append_html] = "<script src=\"/lookbook-assets/js/embed.js?v=#{Lookbook.version}\"></script>".html_safe
end
preview_html = preview_controller.process(:render_in_layout_to_string, "lookbook/preview", inspector_data, **opts)
render html: preview_html
rescue => exception
render_in_layout "lookbook/error",
layout: "lookbook/standalone",
error: prettify_error(exception)
end
else
show_404 layout: "lookbook/standalone"
end
end
|