golden-setting 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -4
- data/app/controllers/golden/setting/settings_controller.rb +7 -2
- data/lib/generators/golden/setting/USAGE +2 -2
- data/lib/generators/golden/setting/install_generator.rb +34 -10
- data/lib/generators/golden/setting/templates/golden_setting.rb +5 -0
- data/lib/golden/setting.rb +3 -0
- data/lib/golden/setting/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 512bed1909c6513efb9e69ae74b1dc7c2d8a0f95
|
4
|
+
data.tar.gz: 7ccc2a33821007ea7293f445b257c8311be4cc84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa58ff93a5ab01f2baa9a81f82abfb18e3e497592ad2d176013d8f2a7daddd0e60bf404664799e2958912dfb785a88846adbb32683235fe841a8b4ec86ef873c
|
7
|
+
data.tar.gz: a2f19af0367d4b98e0f66ed9deb4010f893987f47a26dd6b79555c14a97f582eba9e112f6f59b634af700ce703d367a4f701306378f929902eb1ba93927fa38b
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ gem 'cancancan'
|
|
14
14
|
gem 'simple_form', '~> 3.0'
|
15
15
|
gem 'bootstrap-sass'
|
16
16
|
gem 'will_paginate'
|
17
|
-
gem '
|
17
|
+
gem 'golden-theme'
|
18
18
|
```
|
19
19
|
|
20
20
|
If you add `gem 'protected_attributes'` in your `Gemfile`, remember to add
|
@@ -33,7 +33,7 @@ gem 'cancancan'
|
|
33
33
|
gem 'simple_form', '>= 2.0', '< 3.0'
|
34
34
|
gem 'bootstrap-sass'
|
35
35
|
gem 'will_paginate'
|
36
|
-
gem '
|
36
|
+
gem 'golden-theme'
|
37
37
|
```
|
38
38
|
|
39
39
|
Please make sure these gems are installed and configured properly.
|
@@ -68,6 +68,7 @@ You will need to add these basic configures of `golden-setting` for your needs.
|
|
68
68
|
* `groups` for grouping settings with a name
|
69
69
|
* `default_group` for saving settings with a group
|
70
70
|
* `default_tab` for a group of settings shown in tab views
|
71
|
+
* `before_actions` for setting up authentication filters
|
71
72
|
|
72
73
|
Edit `config/initializers/golden_setting.rb` for more detail.
|
73
74
|
|
@@ -137,7 +138,7 @@ You can add virtaul settings for your application by setting defaults.
|
|
137
138
|
Add `config/initializers/golden_setting_defaults.rb`.
|
138
139
|
|
139
140
|
```ruby
|
140
|
-
|
141
|
+
Rails.application.config.after_initialize do
|
141
142
|
Setting.defaults[:administrator] = 'tsechingho'
|
142
143
|
end
|
143
144
|
```
|
@@ -152,7 +153,7 @@ Setting.administrator # => 'tsechingho'
|
|
152
153
|
You can also save default settings in database after initializing your application.
|
153
154
|
|
154
155
|
```ruby
|
155
|
-
|
156
|
+
Rails.application.config.after_initialize do
|
156
157
|
Setting.save_default :manager, 'tsechingho'
|
157
158
|
end
|
158
159
|
```
|
@@ -165,6 +166,8 @@ Setting.object('manager').group # => 'site'
|
|
165
166
|
Setting.manager # => 'tsechingho'
|
166
167
|
```
|
167
168
|
|
169
|
+
For Rails 3 project, use `YourApp::Application.config.after_initialize` instead.
|
170
|
+
|
168
171
|
### Resourced settings
|
169
172
|
|
170
173
|
Settings may be bound to any existing ActiveRecord object.
|
@@ -1,5 +1,10 @@
|
|
1
1
|
class Golden::Setting::SettingsController < ApplicationController
|
2
|
-
|
2
|
+
if Golden::Setting.before_actions.blank?
|
3
|
+
raise "Please set config.before_actions like `authenticate_user!` for security."
|
4
|
+
end
|
5
|
+
Golden::Setting.before_actions.each do |action|
|
6
|
+
before_filter action.to_sym
|
7
|
+
end
|
3
8
|
before_filter :load_setting_class, only: [:index, :create, :list, :batch_update]
|
4
9
|
before_filter :new_setting, only: [:create]
|
5
10
|
load_and_authorize_resource :setting, class: Golden::Setting.setting_class, parent: false
|
@@ -47,7 +52,7 @@ class Golden::Setting::SettingsController < ApplicationController
|
|
47
52
|
def batch_update
|
48
53
|
params[:setting].each do |setting, value|
|
49
54
|
@setting_class.send "#{setting}=", value
|
50
|
-
end
|
55
|
+
end if params[:setting]
|
51
56
|
redirect_to action: :index
|
52
57
|
end
|
53
58
|
|
@@ -7,8 +7,8 @@ Example:
|
|
7
7
|
This will create/modify:
|
8
8
|
db/migrate/20130516050309_create_golden_settings.rb
|
9
9
|
app/models/setting.rb
|
10
|
-
app/assets/javascripts/application.js
|
11
|
-
app/assets/stylesheets/application.css
|
10
|
+
app/assets/javascripts/application.js(.coffee)
|
11
|
+
app/assets/stylesheets/application.css(.sass|.scss)
|
12
12
|
config/initializers/golden_setting.rb
|
13
13
|
config/application.rb
|
14
14
|
config/locales/golden/settings.en.yml
|
@@ -24,8 +24,9 @@ class Golden::Setting::InstallGenerator < Rails::Generators::NamedBase
|
|
24
24
|
template file, File.join('app/models', class_path, "#{file_name}.rb"), verbose: false
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def inject_javascript_js
|
28
28
|
file = 'app/assets/javascripts/application.js'
|
29
|
+
return unless File.exists? file
|
29
30
|
log :javascripts, 'application.js'
|
30
31
|
sentinel = "//= require_tree .\n"
|
31
32
|
insert_into_file file, before: sentinel, verbose: false do
|
@@ -33,8 +34,19 @@ class Golden::Setting::InstallGenerator < Rails::Generators::NamedBase
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
def
|
37
|
+
def inject_javascript_coffee
|
38
|
+
file = 'app/assets/javascripts/application.js.coffee'
|
39
|
+
return unless File.exists? file
|
40
|
+
log :javascripts, 'application.js.coffee'
|
41
|
+
sentinel = "#= require_tree .\n"
|
42
|
+
insert_into_file file, before: sentinel, verbose: false do
|
43
|
+
"#= require golden/setting/settings\n"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def inject_stylesheet_css
|
37
48
|
file = 'app/assets/stylesheets/application.css'
|
49
|
+
return unless File.exists? file
|
38
50
|
log :stylesheets, 'application.css'
|
39
51
|
sentinel = " *= require_self\n"
|
40
52
|
insert_into_file file, before: sentinel, verbose: false do
|
@@ -42,6 +54,26 @@ class Golden::Setting::InstallGenerator < Rails::Generators::NamedBase
|
|
42
54
|
end
|
43
55
|
end
|
44
56
|
|
57
|
+
def inject_stylesheet_sass
|
58
|
+
file = 'app/assets/stylesheets/application.css.sass'
|
59
|
+
return unless File.exists? file
|
60
|
+
log :stylesheets, 'application.css.sass'
|
61
|
+
sentinel = "//= require_self\n"
|
62
|
+
insert_into_file file, before: sentinel, verbose: false do
|
63
|
+
"//= require golden/setting/settings\n"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def inject_stylesheet_scss
|
68
|
+
file = 'app/assets/stylesheets/application.css.scss'
|
69
|
+
return unless File.exists? file
|
70
|
+
log :stylesheets, 'application.css.scss'
|
71
|
+
sentinel = "//= require_self\n"
|
72
|
+
insert_into_file file, before: sentinel, verbose: false do
|
73
|
+
"//= require golden/setting/settings\n"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
45
77
|
def generate_initializer
|
46
78
|
file = 'golden_setting.rb'
|
47
79
|
log :initializer, file
|
@@ -68,14 +100,6 @@ class Golden::Setting::InstallGenerator < Rails::Generators::NamedBase
|
|
68
100
|
route "mount Golden::Setting::Engine, at: '/'\n"
|
69
101
|
end
|
70
102
|
|
71
|
-
def inject_controller
|
72
|
-
file = 'app/controllers/application_controller.rb'
|
73
|
-
sentinel = "protect_from_forgery with: :exception\n"
|
74
|
-
insert_into_file file, after: sentinel do
|
75
|
-
" alias_method :authenticate_session!, :authenticate_user!\n"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
103
|
def inject_layout
|
80
104
|
file = 'app/views/layouts/application.html.erb'
|
81
105
|
sentinel = "<%= yield %>\n"
|
data/lib/golden/setting.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: golden-setting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tse-Ching Ho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|