Sha256: f84617a1821ab23b4bc0ea9ec8a28a4e198d8f758c39b9926caaa275a53ed56a
Contents?: true
Size: 2 KB
Versions: 1
Compression:
Stored size: 2 KB
Contents
module Scrivito # This controller provides some default includes ({CmsAccessible}), # before filters (+load_object+, among others), and actions to simplify # CMS object handling. It should never be used directly, but only as a # super class to {CmsController}. # @api public class DefaultCmsController < ApplicationController include CmsAccessible before_filter :load_object before_filter :authorize_editor, only: [:show_widget, :widget_details, :details_page] # Default Action. Delivers files directly if {BasicObj#binary?}. # Otherwise the view is rendered. # @api public def index deliver_file if @obj.binary? end def show_widget widget = load_widget render layout: false, locals: {widget: widget} end def widget_details widget = load_widget template_path = "#{widget.obj_class_name.underscore}/details" render template_path, layout: false, locals: {widget: widget} end def details_page @scrivito_resource = editing_context.selected_workspace.objs .find_including_deleted(params[:resource_id]) render text: '', layout: true end # This method indicates if this controller should be used automatically when an Obj is # requested via the Scrivito's standard routes. It returns true by default. # # Overwrite it to return false if you do want your controller to be excluded from Obj dispatching. # # You may also implement a method with the name {use_for_obj_dispatch?} in controllers not # descending from {DefaultCmsController} to include them in Obj dispatching. # # @see Obj#controller_name # @api public def self.use_for_obj_dispatch? true end private def authorize_editor head(:forbidden) unless editing_context.authenticated_editor? end def editing_context request.env[EditingContextMiddleware::ENVKEY] || EditingContext.new end def load_widget @obj.widget_from_pool(params[:widget_id]) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scrivito_sdk-0.17.0 | app/controllers/scrivito/default_cms_controller.rb |