Class: Lookbook::PreviewsController

Inherits:
ApplicationController show all
Includes:
TargetableConcern, WithPreviewControllerConcern
Defined in:
app/controllers/lookbook/previews_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from WithPreviewControllerConcern

#preview_controller

Methods included from TargetableConcern

#inspector_data, #lookup_entities, #path_segments, #set_display_options, #set_params, #set_title, #show_404

Methods inherited from ApplicationController

#index

Class Method Details

.controller_pathObject



9
10
11
# File 'app/controllers/lookbook/previews_controller.rb', line 9

def self.controller_path
  "lookbook/previews"
end

Instance Method Details

#showObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/lookbook/previews_controller.rb', line 13

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