Sha256: 2d8b5d1567ab377d53a53070d82fd7b4377be0c5e8a29fe3e0cf3cc253b0160d

Contents?: true

Size: 1.07 KB

Versions: 25

Compression:

Stored size: 1.07 KB

Contents

module Scrivito

class UiController < ActionController::Base
  def index
    @application_src = application_src
    if editing_context.editor
      @ui_config = UiConfig.new(
        editing_context: editing_context,
        resource: resource,
        return_to: params[:return_to],
        app_extension_tags: app_extension_tags,
      ).to_json
    else
      redirect_to @application_src
    end
  end

  private

  def application_src
    return "/" if resource_details?

    given_query = request.env['QUERY_STRING']
    query = "?#{given_query}" if given_query.present?
    "/#{params['application_path']}#{query}"
  end

  def resource_details?
    params[:resource_id].present?
  end

  def resource
    if resource_details?
      editing_context.selected_workspace.objs.find_including_deleted(params[:resource_id])
    end
  end

  def app_extension_tags
    view_context.javascript_include_tag('scrivito_app_extensions') +
      view_context.stylesheet_link_tag('scrivito_app_extensions')
  end

  def editing_context
    EditingContextMiddleware.from_request(request)
  end
end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
scrivito_sdk-1.1.1 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-1.1.0 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-1.1.0.rc3 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-1.1.0.rc2 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-1.1.0.rc1 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-1.0.0 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-1.0.0.rc4 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-1.0.0.rc3 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-1.0.0.rc2 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-1.0.0.rc1 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-0.90.0 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-0.90.0.rc3 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-0.90.0.rc2 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-0.90.0.rc1 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-0.70.2 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-0.71.2 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-0.71.1 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-0.70.1 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-0.71.0 app/controllers/scrivito/ui_controller.rb
scrivito_sdk-0.71.0.rc2 app/controllers/scrivito/ui_controller.rb