app/controllers/lookbook/previews_controller.rb in lookbook-1.5.1 vs app/controllers/lookbook/previews_controller.rb in lookbook-1.5.2
- old
+ new
@@ -1,10 +1,12 @@
module Lookbook
class PreviewsController < ApplicationController
include TargetableConcern
include WithPreviewControllerConcern
+ before_action { response.headers.delete("X-Frame-Options") }
+
layout "lookbook/inspector"
helper Lookbook::PreviewHelper
def self.controller_path
"lookbook/previews"
@@ -16,14 +18,19 @@
render(
json: Lookbook.previews.map do |preview|
{
name: preview.name,
examples: preview.examples.map { |example|
- {
- inspect_path: example.url_path,
- name: example.name
- }
+ 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
@@ -45,8 +52,19 @@
error: prettify_error(exception)
end
else
show_404 layout: "lookbook/standalone"
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