Sha256: ae536b06fb9f8556c6008bb583a8318152847c129e9c3ec0111e6d1e76776081

Contents?: true

Size: 893 Bytes

Versions: 14

Compression:

Stored size: 893 Bytes

Contents

module ScrivitoContentBrowser
  class ContentBrowserController < ApplicationController
    # Return JSON responses without layout information.
    layout false

    # Render a JSON response that holds the content browser inspector markup. The inspector either
    # renders the details view for the selected object, or a fallback view that is located under
    # 'app/views/obj/details'.
    def inspector
      @obj = Obj.find(params[:id])

      options = {
        layout: 'scrivito_content_browser/inspector',
      }

      content = begin
        render_to_string(details_view_template(@obj), options)
      rescue ActionView::MissingTemplate
        render_to_string('scrivito_content_browser/obj/details', options)
      end

      render json: { content: content }
    end

    private

    def details_view_template(obj)
      "#{obj.obj_class.underscore}/details"
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
scrivito_content_browser-1.0.0 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-1.0.0.rc4 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-1.0.0.rc3 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-1.0.0.rc2 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-1.0.0.rc1 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-0.90.0 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-0.90.0.rc3 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-0.90.0.rc2 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-0.90.0.rc1 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-0.71.2 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-0.71.1 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-0.71.0 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-0.71.0.rc2 app/controllers/scrivito_content_browser/content_browser_controller.rb
scrivito_content_browser-0.71.0.rc1 app/controllers/scrivito_content_browser/content_browser_controller.rb