require'active_admin/router'require'active_admin/helpers/settings'moduleActiveAdminclassApplicationincludeSettings# The default namespace to put controllers and routes inside. Set this# in config/initializers/active_admin.rb using:## config.default_namespace = :super_admin#setting:default_namespace,:admin# The default number of resources to display on index pagessetting:default_per_page,30# A hash of all the registered namespacessetting:namespaces,{}# The title which gets displayed in the main layoutsetting:site_title,""# Set the site title link href (defaults to AA dashboard)setting:site_title_link,""# Load paths for admin configurations. Add folders to this load path# to load up other resources for administration. External gems can# include their paths in this load path to provide active_admin UIssetting:load_paths,[File.expand_path('app/admin',Rails.root)]# The view factory to use to generate all the view classes. Take# a look at ActiveAdmin::ViewFactorysetting:view_factory,ActiveAdmin::ViewFactory.new# The method to call in controllers to get the current usersetting:current_user_method,false# The method to call in the controllers to ensure that there# is a currently authenticated admin usersetting:authentication_method,false# The path to log user's out with. If set to a symbol, we assume# that it's a method to call which returns the pathsetting:logout_link_path,:destroy_admin_user_session_path# The method to use when generating the link for user logoutsetting:logout_link_method,:get# Active Admin makes educated guesses when displaying objects, this is# the list of methods it tries calling in ordersetting:display_name_methods,[:display_name,:full_name,:name,:username,:login,:title,:email,:to_s]# == Deprecated Settings# @deprecated The default sort order for index pagesdeprecated_setting:default_sort_order,'id_desc'# DEPRECATED: This option is deprecated and will be removed. Use# the #allow_comments_in option insteadattr_accessor:admin_notesincludeAssetRegistrationdefinitializeregister_default_assetsenddefprepare!remove_active_admin_load_paths_from_rails_autoload_and_eager_loadattach_reloadergenerate_stylesheetsend# Registers a brand new configuration for the given resource.defregister(resource,options={},&block)namespace_name=options.has_key?(:namespace)?options[:namespace]:default_namespacenamespace=find_or_create_namespace(namespace_name)namespace.register(resource,options,&block)end# Creates a namespace for the given namedeffind_or_create_namespace(name)name||=:rootreturnnamespaces[name]ifnamespaces[name]namespace=Namespace.new(self,name)ActiveAdmin::Event.dispatchActiveAdmin::Namespace::RegisterEvent,namespacenamespaces[name]=namespacenamespaceend# Stores if everything has been loaded or we need to reload@@loaded=false# Returns true if all the configuration files have been loaded.defloaded?@@loadedend# Removes all the controllers that were defined by registering# resources for administration.## We remove them, then load them on each request in development# to allow for changes without having to restart the server.defunload!namespaces.values.each{|namespace|namespace.unload!}self.namespaces={}@@loaded=falseend# Loads all of the ruby files that are within the load path of# ActiveAdmin.load_paths. This should load all of the administration# UIs so that they are available for the router to proceed.## The files are only loaded if we haven't already loaded all the files# and they aren't marked for re-loading. To mark the files for re-loading# you must first call ActiveAdmin.unload!defload!# No work to do if we've already loadedreturnfalseifloaded?# Load filesfiles_in_load_path.each{|file|loadfile}# If no configurations, let's make sure you can still loginload_default_namespaceifnamespaces.values.empty?# Load Menusnamespaces.values.each{|namespace|namespace.load_menu!}@@loaded=trueend# Returns ALL the files to load from all the load pathsdeffiles_in_load_pathload_paths.flatten.compact.uniq.collect{|path|Dir["#{path}/**/*.rb"]}.flattenenddefrouter@router||=Router.new(self)enddefroutes(rails_router)# Ensure that all the configurations (which define the routes)# are all loadedload!router.apply(rails_router)enddefload_default_namespacefind_or_create_namespace(default_namespace)end## Add before, around and after filters to each registered resource.## eg:## ActiveAdmin.before_filter :authenticate_admin!#defbefore_filter(*args,&block)ResourceController.before_filter(*args,&block)enddefskip_before_filter(*args,&block)ResourceController.skip_before_filter(*args,&block)enddefafter_filter(*args,&block)ResourceController.after_filter(*args,&block)enddefaround_filter(*args,&block)ResourceController.around_filter(*args,&block)end# Helper method to add a dashboard sectiondefdashboard_section(name,options={},&block)ActiveAdmin::Dashboards.add_section(name,options,&block)endprivatedefregister_default_assetsregister_stylesheet'active_admin.css'register_javascript'active_admin.js'end# Since we're dealing with all our own file loading, we need# to remove our paths from the ActiveSupport autoload paths.# If not, file naming becomes very important and can cause clashes.defremove_active_admin_load_paths_from_rails_autoload_and_eager_loadActiveSupport::Dependencies.autoload_paths.reject!{|path|load_paths.include?(path)}# Don't eagerload our configs, we'll deal with them ourselvesRails.application.config.eager_load_paths=Rails.application.config.eager_load_paths.rejectdo|path|load_paths.include?(path)endenddefattach_reloaderActiveAdmin::Reloader.new(Rails.version).attach!enddefgenerate_stylesheets# This must be required after initializationrequire'sass/plugin'require'active_admin/sass/helpers'# Create our own asset pipeline in Rails 3.0ifActiveAdmin.use_asset_pipeline?# Add our mixins to the load path for SASS::Sass::Engine::DEFAULT_OPTIONS[:load_paths]<<File.expand_path("../../../app/assets/stylesheets",__FILE__)elserequire'active_admin/sass/css_loader'::Sass::Plugin.add_template_location(File.expand_path("../../../app/assets/stylesheets",__FILE__))::Sass::Plugin.add_template_location(File.expand_path("../sass",__FILE__))endendendend