Sha256: 6ca320d470f89541b19c910fd6a5bc24063e7a68f8e76af578d1b715b54f052f
Contents?: true
Size: 1.8 KB
Versions: 3
Compression:
Stored size: 1.8 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] # 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 # 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
3 entries across 3 versions & 1 rubygems