Sha256: cbff16ecdd0c926300522d986a40f951cc0ec3e0307bf16b72f0842514f39ac7

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

module Lookbook
  class PreviewsController < ApplicationController
    include TargetableConcern
    include WithPreviewControllerConcern

    layout false

    def self.controller_path
      "lookbook/previews"
    end

    def index
      respond_to do |format|
        format.json do
          render(
            json: Lookbook.previews.map do |preview|
              {
                name: preview.name,
                scenarios: preview.scenarios.map { |scenario|
                  {
                    inspect_path: scenario.url_path,
                    name: scenario.name
                  }
                }
              }
            end
          )
        end
      end
    end

    def show
      if @target
        begin
          opts = {layout: @preview.layout}
          if params[:lookbook_embed] == "true"
            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/previews/group", inspector_data, **opts)
        rescue => exception
          render_in_layout "lookbook/error",
            layout: "lookbook/skeleton",
            error: prettify_error(exception)
        end
      else
        show_404
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lookbook-2.0.0.beta.0 app/controllers/lookbook/previews_controller.rb