Sha256: e29fcdbccb2e5759249cfc5eae8adb750f1a2fa45d5f21560b3e5dc78926a785
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
require 'facet/kernel/constant' require 'facet/time/stamp' require 'nitro/controller' # Provides an automatically generated Administration # interface. class AdminController < Nitro::Controller # Run a simple security check function before each action before :check_security, :except => [ :denied ] # scaffold all the classes scaffold_all # Default to views in part dir def self.template_root File.join(File.dirname(__FILE__), 'template') end # default method for controller def index @classes = self.class.scaffolding_classes.keys end # Delete all instances of the class. # Useful in development mode. def delete_all(klass) constant(klass).delete_all redirect_to_referer end # Drop the schema (typically the DB tables) used to # store the class instances. def destroy(klass) constant(klass).delete_all redirect_to_referer end # fetch the css for this controller # checks for a /system.css file and uses that if available # otherwise uses system.css from the part/admin dir def stylesheet(sheet='system') sheet << ".css" [Nitro::Server.public_root, File.dirname(__FILE__)].each do |path| css_file = File.join(path, sheet) if File.exists? css_file response.content_type = 'text/css' @out << File.read(css_file) raise Nitro::RenderExit end end raise RenderExit end alias_action :stylesheets, :stylesheet private # Overload in your application to suit your # needs. The default implementation does NOT apply security # in debug mode.The default implementation requires the # existense of an :ADMIN key in the session, so you can # easily integrate this in your user/roles management code. def check_security return true if Nitro::Runner.mode == :debug redirect 'denied' unless session[:ADMIN] end end # * George Moschovitis <gm@navel.gr>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.28.0 | src/part/admin/controller.rb |