1
1
require 'active_admin/router'
2
2
require 'active_admin/reloader'
3
- require 'active_admin/settings_node'
3
+ require 'active_admin/application_settings'
4
+ require 'active_admin/namespace_settings'
4
5
5
6
module ActiveAdmin
6
7
class Application
7
8
8
9
class << self
9
- def default_settings
10
- @settings ||= SettingsNode . build
11
- end
12
-
13
- def namespace_default_settings
14
- @namespace_settings ||= SettingsNode . build
15
- end
16
-
17
10
def setting ( name , default )
18
- default_settings . register name , default
11
+ ApplicationSettings . register name , default
19
12
end
20
13
21
14
def inheritable_setting ( name , default )
22
- namespace_default_settings . register name , default
15
+ NamespaceSettings . register name , default
23
16
end
24
17
end
25
18
26
19
def settings
27
- @settings ||= SettingsNode . build ( self . class . default_settings )
20
+ @settings ||= SettingsNode . build ( ApplicationSettings )
28
21
end
29
22
30
23
def namespace_settings
31
- @namespace_settings ||= SettingsNode . build ( self . class . namespace_default_settings )
24
+ @namespace_settings ||= SettingsNode . build ( NamespaceSettings )
32
25
end
33
26
34
27
def respond_to_missing? ( method , include_private = false )
@@ -45,146 +38,11 @@ def method_missing(method, *args)
45
38
end
46
39
end
47
40
48
- # The default namespace to put controllers and routes inside. Set this
49
- # in config/initializers/active_admin.rb using:
50
- #
51
- # config.default_namespace = :super_admin
52
- #
53
- setting :default_namespace , :admin
54
-
55
41
attr_reader :namespaces
56
42
def initialize
57
43
@namespaces = Namespace ::Store . new
58
44
end
59
45
60
- setting :app_path , Rails . root
61
-
62
- # Load paths for admin configurations. Add folders to this load path
63
- # to load up other resources for administration. External gems can
64
- # include their paths in this load path to provide active_admin UIs
65
- setting :load_paths , [ File . expand_path ( 'app/admin' , Rails . root ) ]
66
-
67
- # The default number of resources to display on index pages
68
- inheritable_setting :default_per_page , 30
69
-
70
- # The max number of resources to display on index pages and batch exports
71
- inheritable_setting :max_per_page , 10_000
72
-
73
- # The title which gets displayed in the main layout
74
- inheritable_setting :site_title , ""
75
-
76
- # Set the site title link href (defaults to AA dashboard)
77
- inheritable_setting :site_title_link , ""
78
-
79
- # Set the site title image displayed in the main layout (has precendence over :site_title)
80
- inheritable_setting :site_title_image , ""
81
-
82
- # Set the site footer text (defaults to Powered by ActiveAdmin text with version)
83
- inheritable_setting :footer , ""
84
-
85
- # Set a favicon
86
- inheritable_setting :favicon , false
87
-
88
- # Additional meta tags to place in head of logged in pages.
89
- inheritable_setting :meta_tags , { }
90
-
91
- # Additional meta tags to place in head of logged out pages.
92
- inheritable_setting :meta_tags_for_logged_out_pages , { robots : "noindex, nofollow" }
93
-
94
- # The view factory to use to generate all the view classes. Take
95
- # a look at ActiveAdmin::ViewFactory
96
- inheritable_setting :view_factory , ActiveAdmin ::ViewFactory . new
97
-
98
- # The method to call in controllers to get the current user
99
- inheritable_setting :current_user_method , false
100
-
101
- # The method to call in the controllers to ensure that there
102
- # is a currently authenticated admin user
103
- inheritable_setting :authentication_method , false
104
-
105
- # The path to log user's out with. If set to a symbol, we assume
106
- # that it's a method to call which returns the path
107
- inheritable_setting :logout_link_path , :destroy_admin_user_session_path
108
-
109
- # The method to use when generating the link for user logout
110
- inheritable_setting :logout_link_method , :get
111
-
112
- # Whether the batch actions are enabled or not
113
- inheritable_setting :batch_actions , false
114
-
115
- # Whether filters are enabled
116
- inheritable_setting :filters , true
117
-
118
- # The namespace root.
119
- inheritable_setting :root_to , 'dashboard#index'
120
-
121
- # Options that a passed to root_to.
122
- inheritable_setting :root_to_options , { }
123
-
124
- # Options passed to the routes, i.e. { path: '/custom' }
125
- inheritable_setting :route_options , { }
126
-
127
- # Display breadcrumbs
128
- inheritable_setting :breadcrumb , true
129
-
130
- # Display create another checkbox on a new page
131
- # @return [Boolean] (true)
132
- inheritable_setting :create_another , false
133
-
134
- # Default CSV options
135
- inheritable_setting :csv_options , { col_sep : ',' , byte_order_mark : "\xEF \xBB \xBF " }
136
-
137
- # Default Download Links options
138
- inheritable_setting :download_links , true
139
-
140
- # The authorization adapter to use
141
- inheritable_setting :authorization_adapter , ActiveAdmin ::AuthorizationAdapter
142
-
143
- # A proc to be used when a user is not authorized to view the current resource
144
- inheritable_setting :on_unauthorized_access , :rescue_active_admin_access_denied
145
-
146
- # A regex to detect unsupported browser, set to false to disable
147
- inheritable_setting :unsupported_browser_matcher , /MSIE [1-8]\. 0/
148
-
149
- # Whether to display 'Current Filters' on search screen
150
- inheritable_setting :current_filters , true
151
-
152
- # class to handle ordering
153
- inheritable_setting :order_clause , ActiveAdmin ::OrderClause
154
-
155
- # default show_count for scopes
156
- inheritable_setting :scopes_show_count , true
157
-
158
- # Request parameters that are permitted by default
159
- inheritable_setting :permitted_params , [
160
- :utf8 , :_method , :authenticity_token , :commit , :id
161
- ]
162
-
163
- # Set flash message keys that shouldn't show in ActiveAdmin
164
- inheritable_setting :flash_keys_to_except , [ 'timedout' ]
165
-
166
- # Set default localize format for Date/Time values
167
- setting :localize_format , :long
168
-
169
- # Include association filters by default
170
- inheritable_setting :include_default_association_filters , true
171
-
172
- # Active Admin makes educated guesses when displaying objects, this is
173
- # the list of methods it tries calling in order
174
- # Note that Formtastic also has 'collection_label_methods' similar to this
175
- # used by auto generated dropdowns in filter or belongs_to field of Active Admin
176
- setting :display_name_methods , [ :display_name ,
177
- :full_name ,
178
- :name ,
179
- :username ,
180
- :login ,
181
- :title ,
182
- :email ,
183
- :to_s ]
184
-
185
- # To make debugging easier, by default don't stream in development
186
- setting :disable_streaming_in , [ 'development' ]
187
-
188
46
# Event that gets triggered on load of Active Admin
189
47
BeforeLoadEvent = 'active_admin.application.before_load' . freeze
190
48
AfterLoadEvent = 'active_admin.application.after_load' . freeze
0 commit comments