forked from saturnflyer/radiant-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings_extension.rb
47 lines (38 loc) · 1.36 KB
/
settings_extension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application_controller'
class SettingsExtension < Radiant::Extension
version "1.2"
description "Web based administration for Radiant default configuration settings."
url "http://github.com/squaretalent/radiant-settings-extension"
define_routes do |map|
map.namespace 'admin' do |admin|
admin.resources :configs, :as => :settings
end
end
def activate
Radiant::Config.extend ConfigFindAllAsTree
Radiant::Config.send :include, ConfigProtection
if Radiant::Config['roles.settings']
config_roles = Radiant::Config['roles.settings']
roles = []
roles << :developer if config_roles.include?('developer')
roles << :admin if config_roles.include?('admin')
if config_roles.include?('all')
roles = [:all]
end
end
tab 'Settings' do
add_item 'Settings', '/admin/settings', :after => 'Personal'
end
Page.class_eval { include ConfigTags }
Radiant::AdminUI.class_eval { attr_accessor :settings }
admin.settings = load_default_settings_regions
end
def load_default_settings_regions
returning OpenStruct.new do |settings|
settings.index = Radiant::AdminUI::RegionSet.new do |index|
index.main.concat %w{top list bottom}
end
end
end
end