app/controllers/lookbook/previews_controller.rb in lookbook-1.5.5 vs app/controllers/lookbook/previews_controller.rb in lookbook-2.0.0.beta.0

- old
+ new

@@ -1,15 +1,12 @@ module Lookbook class PreviewsController < ApplicationController include TargetableConcern include WithPreviewControllerConcern - before_action { response.headers.delete("X-Frame-Options") } + layout false - layout "lookbook/inspector" - helper Lookbook::PreviewHelper - def self.controller_path "lookbook/previews" end def index @@ -17,20 +14,15 @@ 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 + scenarios: preview.scenarios.map { |scenario| + { + inspect_path: scenario.url_path, + name: scenario.name + } } } end ) end @@ -40,31 +32,19 @@ 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 + opts[:append_html] = render_to_string("lookbook/partials/_iframe_content_scripts", layout: nil) end - preview_html = preview_controller.process(:render_in_layout_to_string, "lookbook/preview", inspector_data, **opts) - render html: preview_html + @preview_html = preview_controller.process(:render_in_layout_to_string, "lookbook/previews/group", inspector_data, **opts) rescue => exception render_in_layout "lookbook/error", - layout: "lookbook/standalone", + layout: "lookbook/skeleton", error: prettify_error(exception) end else - show_404 layout: "lookbook/standalone" + show_404 end - end - - private - - def example_json(example) - { - inspect_path: example.url_path, - name: example.name, - preview_path: example.preview_path, - lookup_path: example.lookup_path - } end end end