Sha256: 81880778808a50716cd228c908535338417d449f430e0149fb5b8975c77e1949

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require_dependency 'radiant'

class ApplicationController < ActionController::Base
  include LoginSystem
  include Radiant::LegacyRoutes
  
  filter_parameter_logging :password, :password_confirmation
  
  protect_from_forgery
  
  before_filter :set_current_user
  before_filter :set_javascripts_and_stylesheets
  
  attr_accessor :config, :cache
  
  def initialize
    super
    @config = Radiant::Config
  end
  
  # helpers to include additional assets from actions or views
  helper_method :include_stylesheet, :include_javascript
  
  def include_stylesheet(sheet)
    @stylesheets << sheet
  end
  
  def include_javascript(script)
    @javascripts << script
  end

  def template_name
    case self.action_name
    when 'index'
      'index'
    when 'new','create'
      'new'
    when 'edit', 'update'
      'edit'
    when 'remove', 'destroy'
      'remove'
    end
  end
  
  def rescue_action_in_public(exception)
    case exception
      when ActiveRecord::RecordNotFound, ActionController::UnknownController, ActionController::UnknownAction, ActionController::RoutingError
        render :template => "site/not_found", :status => 404
      else
        super
    end
  end
  
  private
  
    def set_current_user
      UserActionObserver.current_user = current_user
    end
  
    def set_javascripts_and_stylesheets
      @stylesheets ||= []
      @stylesheets.concat %w(admin/main)
      @javascripts ||= []
      @javascripts.concat %w(prototype string effects admin/tabcontrol admin/ruledtable admin/admin)
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radiant-0.8.0 app/controllers/application_controller.rb