app/controllers/scrivito/ui_controller.rb in scrivito_sdk-0.66.0 vs app/controllers/scrivito/ui_controller.rb in scrivito_sdk-0.70.0.rc1
- old
+ new
@@ -1,15 +1,45 @@
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?
- @application_src = "/#{params['application_path']}#{query}"
- redirect_to @application_src unless editing_context.editor
+ "/#{params['application_path']}#{query}"
end
- private
+ 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