thecore_settings 1.1.15 → 2.0.5
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/.devcontainer/Dockerfile +20 -0
- data/.devcontainer/devcontainer.json +33 -0
- data/.github/workflows/gempush.yml +34 -0
- data/.gitignore +542 -0
- data/.rakeTasks +7 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +31 -0
- data/CHANGELOG.md +81 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +275 -0
- data/LICENSE.txt +22 -0
- data/README.md +169 -0
- data/README.rdoc +68 -0
- data/Rakefile +6 -34
- data/app/{assets/config/thecore_settings_manifest.js → models/.keep} +0 -0
- data/app/models/thecore_settings/setting.rb +77 -0
- data/app/views/.keep +0 -0
- data/app/views/rails_admin/main/_setting_value.html.haml +41 -0
- data/bin/rails +13 -0
- data/config/locales/en.yml +29 -0
- data/config/locales/{thecore_settings.it.yml → it.yml} +2 -2
- data/config/locales/pt-BR.yml +28 -0
- data/config/locales/ru.yml +29 -0
- data/db/migrate/20161227101954_create_rails_admin_settings.rb +4 -4
- data/gemfiles/mongoid-6.0.gemfile +5 -0
- data/gemfiles/mongoid-6.3.gemfile +5 -0
- data/lib/generators/thecore_settings/migration_generator.rb +15 -0
- data/lib/generators/thecore_settings/templates/db/migrate/20161227101954_create_thecore_settings.rb +29 -0
- data/lib/generators/thecore_settings/templates/migration.rb +29 -0
- data/lib/thecore_settings/determine_mime_type.rb +193 -0
- data/lib/thecore_settings/dumper.rb +12 -0
- data/lib/thecore_settings/engine.rb +17 -3
- data/lib/thecore_settings/fallback.rb +21 -0
- data/lib/thecore_settings/hex_color_validator.rb +11 -0
- data/lib/thecore_settings/kinds.rb +34 -0
- data/lib/thecore_settings/mongoid.rb +19 -0
- data/lib/thecore_settings/namespaced.rb +210 -0
- data/lib/thecore_settings/processing.rb +217 -0
- data/lib/thecore_settings/rails_admin_config.rb +71 -0
- data/lib/thecore_settings/require_helpers.rb +86 -0
- data/lib/thecore_settings/settings.rb +95 -0
- data/lib/thecore_settings/storage/carrier_wave_uploader.rb +9 -0
- data/lib/thecore_settings/storage/shrine_uploader.rb +14 -0
- data/lib/thecore_settings/tasks.rb +35 -0
- data/lib/thecore_settings/uploads.rb +57 -0
- data/lib/thecore_settings/validation.rb +126 -0
- data/lib/thecore_settings/version.rb +1 -1
- data/lib/thecore_settings.rb +115 -123
- data/spec/advanced_usage_spec.rb +11 -0
- data/spec/carrierwave_spec.rb +41 -0
- data/spec/database_trickery_spec.rb +48 -0
- data/spec/defaults_spec.rb +87 -0
- data/spec/enabling_spec.rb +29 -0
- data/spec/factories/setting.rb +8 -0
- data/spec/label_spec.rb +16 -0
- data/spec/migration_spec.rb +20 -0
- data/spec/model_spec.rb +105 -0
- data/spec/namespaced_spec.rb +67 -0
- data/spec/paperclip_spec.rb +38 -0
- data/spec/settings_spec.rb +75 -0
- data/spec/shrine_spec.rb +34 -0
- data/spec/spec_helper.rb +85 -0
- data/spec/support/1024x768.gif +0 -0
- data/spec/support/database_cleaner.rb +10 -0
- data/spec/support/defaults.yml +23 -0
- data/spec/support/defaults_w_file.yml +19 -0
- data/spec/support/mongoid.rb +6 -0
- data/spec/support/mongoid.yml +6 -0
- data/spec/types_spec.rb +101 -0
- data/thecore_settings.gemspec +44 -0
- metadata +326 -63
- data/app/assets/stylesheets/rich/editor.css +0 -20
- data/config/initializers/rails_admin_requirements.rb +0 -22
- data/config/initializers/thecore_settings_abilities.rb +0 -22
- data/config/initializers/thecore_settings_post_init.rb +0 -9
- data/config/routes.rb +0 -3
- data/db/migrate/20161227101956_add_app_name.rb +0 -5
- data/lib/tasks/thecore_settings_tasks.rake +0 -4
data/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.2
|
data/.travis.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
language: ruby
|
2
|
+
services: mongodb
|
3
|
+
|
4
|
+
notifications:
|
5
|
+
email: false
|
6
|
+
|
7
|
+
rvm:
|
8
|
+
- 2.3.3
|
9
|
+
- 2.5.0
|
10
|
+
|
11
|
+
env:
|
12
|
+
global:
|
13
|
+
- CC_TEST_REPORTER_ID=f23ba257d0a12c588551991b4377e3eb218c1ff80050bc48c6b18c49ca16cb62
|
14
|
+
matrix:
|
15
|
+
- "UPLOADS=paperclip"
|
16
|
+
- "UPLOADS=carrierwave"
|
17
|
+
- "UPLOADS=shrine"
|
18
|
+
- "RAILS=1 UPLOADS=paperclip"
|
19
|
+
- "RAILS=1 UPLOADS=carrierwave"
|
20
|
+
- "RAILS=1 UPLOADS=shrine"
|
21
|
+
|
22
|
+
gemfile:
|
23
|
+
- gemfiles/mongoid-6.0.gemfile
|
24
|
+
- gemfiles/mongoid-6.3.gemfile
|
25
|
+
|
26
|
+
before_script:
|
27
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
28
|
+
- chmod +x ./cc-test-reporter
|
29
|
+
- ./cc-test-reporter before-build
|
30
|
+
after_script:
|
31
|
+
- ./cc-test-reporter after-build --debug --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
## 1.6.0 (2020-06-11)
|
2
|
+
|
3
|
+
Add shrine file uploads
|
4
|
+
|
5
|
+
## 1.5.0 (2018-06-09)
|
6
|
+
|
7
|
+
Add float type
|
8
|
+
|
9
|
+
## 1.4.1 (2018-03-07)
|
10
|
+
|
11
|
+
Fix activerecord + paperclip uploads
|
12
|
+
Minor code cleanup
|
13
|
+
|
14
|
+
## 1.4.0
|
15
|
+
|
16
|
+
Add new kinds
|
17
|
+
|
18
|
+
strip_tags (uses strip_tags rails helper)
|
19
|
+
simple_format (uses simple_format rails helper)
|
20
|
+
simple_format_raw (does NOT sanitize (allows ANY javascript) - uses simple_format rails helper with sanitize: false)
|
21
|
+
json
|
22
|
+
|
23
|
+
Use Psych.safe_load for yaml if available
|
24
|
+
|
25
|
+
## 1.3.1
|
26
|
+
|
27
|
+
add pt-BR locale (thanks @prem-prakash)
|
28
|
+
|
29
|
+
## 1.1.3
|
30
|
+
|
31
|
+
- Fix for namespace tabs when database table does not exist yet.
|
32
|
+
|
33
|
+
## 1.1.2
|
34
|
+
|
35
|
+
- Add namespace tabs in rails_admin
|
36
|
+
- Add code type with codemirror (requires glebtv-ckeditor)
|
37
|
+
- Fixed Paperclip installation checking #6. Thx @tanelj
|
38
|
+
- Add boolean data type #2. Thx @teonimesic
|
39
|
+
|
40
|
+
## 1.1.0
|
41
|
+
|
42
|
+
- Fix file type
|
43
|
+
|
44
|
+
## 1.0.0
|
45
|
+
|
46
|
+
- Support ActiveRecord
|
47
|
+
|
48
|
+
## 1.0.0.pre.1
|
49
|
+
|
50
|
+
Disable auto migrate. To migrate from 0.8 run:
|
51
|
+
|
52
|
+
```
|
53
|
+
ThecoreSettings.migrate!
|
54
|
+
```
|
55
|
+
|
56
|
+
## 0.9.1
|
57
|
+
|
58
|
+
Settings.ns(ns) now defaults to fallback to Settings.ns_fallback
|
59
|
+
If you want an NS without fallback, specify nil:
|
60
|
+
Settings.ns(ns, fallback: nil)
|
61
|
+
|
62
|
+
## 0.9.0
|
63
|
+
|
64
|
+
- Added ActiveRecord support
|
65
|
+
- [!!!] Type renamed to Kind to avoid messing with AR STI column
|
66
|
+
|
67
|
+
Rename it in all invocations, then run migrate DB with:
|
68
|
+
|
69
|
+
ThecoreSettings.migrate!
|
70
|
+
|
71
|
+
## 0.6.0
|
72
|
+
|
73
|
+
- Added namespaced settings
|
74
|
+
- Added loading of default settings from config/settings.yml
|
75
|
+
- Settings.label(key) is removed
|
76
|
+
- Added Settings.apply_defaults! to load settings from yml file without
|
77
|
+
overwriting current settings.
|
78
|
+
*note*: If setting type is changed and old value does not pass validation for
|
79
|
+
new type, value will be reset to nil.
|
80
|
+
- Added rake settings:save_defaults to dump current settings to
|
81
|
+
config/defaults.yml
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,275 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
thecore_settings (2.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actioncable (5.2.6)
|
10
|
+
actionpack (= 5.2.6)
|
11
|
+
nio4r (~> 2.0)
|
12
|
+
websocket-driver (>= 0.6.1)
|
13
|
+
actionmailer (5.2.6)
|
14
|
+
actionpack (= 5.2.6)
|
15
|
+
actionview (= 5.2.6)
|
16
|
+
activejob (= 5.2.6)
|
17
|
+
mail (~> 2.5, >= 2.5.4)
|
18
|
+
rails-dom-testing (~> 2.0)
|
19
|
+
actionpack (5.2.6)
|
20
|
+
actionview (= 5.2.6)
|
21
|
+
activesupport (= 5.2.6)
|
22
|
+
rack (~> 2.0, >= 2.0.8)
|
23
|
+
rack-test (>= 0.6.3)
|
24
|
+
rails-dom-testing (~> 2.0)
|
25
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
26
|
+
actionview (5.2.6)
|
27
|
+
activesupport (= 5.2.6)
|
28
|
+
builder (~> 3.1)
|
29
|
+
erubi (~> 1.4)
|
30
|
+
rails-dom-testing (~> 2.0)
|
31
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
32
|
+
activejob (5.2.6)
|
33
|
+
activesupport (= 5.2.6)
|
34
|
+
globalid (>= 0.3.6)
|
35
|
+
activemodel (5.2.6)
|
36
|
+
activesupport (= 5.2.6)
|
37
|
+
activerecord (5.2.6)
|
38
|
+
activemodel (= 5.2.6)
|
39
|
+
activesupport (= 5.2.6)
|
40
|
+
arel (>= 9.0)
|
41
|
+
activestorage (5.2.6)
|
42
|
+
actionpack (= 5.2.6)
|
43
|
+
activerecord (= 5.2.6)
|
44
|
+
marcel (~> 1.0.0)
|
45
|
+
activesupport (5.2.6)
|
46
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
47
|
+
i18n (>= 0.7, < 2)
|
48
|
+
minitest (~> 5.1)
|
49
|
+
tzinfo (~> 1.1)
|
50
|
+
addressable (2.8.0)
|
51
|
+
public_suffix (>= 2.0.2, < 5.0)
|
52
|
+
arel (9.0.0)
|
53
|
+
ast (2.4.2)
|
54
|
+
bson (4.12.1)
|
55
|
+
builder (3.2.4)
|
56
|
+
carrierwave (2.2.2)
|
57
|
+
activemodel (>= 5.0.0)
|
58
|
+
activesupport (>= 5.0.0)
|
59
|
+
addressable (~> 2.6)
|
60
|
+
image_processing (~> 1.1)
|
61
|
+
marcel (~> 1.0.0)
|
62
|
+
mini_mime (>= 0.1.3)
|
63
|
+
ssrf_filter (~> 1.0)
|
64
|
+
carrierwave-mongoid (1.3.0)
|
65
|
+
carrierwave (>= 0.8, < 3)
|
66
|
+
mongoid (>= 3.0, < 8.0)
|
67
|
+
mongoid-grid_fs (>= 1.3, < 3.0)
|
68
|
+
climate_control (0.2.0)
|
69
|
+
concurrent-ruby (1.1.9)
|
70
|
+
content_disposition (1.0.0)
|
71
|
+
crass (1.0.6)
|
72
|
+
database_cleaner (2.0.1)
|
73
|
+
database_cleaner-active_record (~> 2.0.0)
|
74
|
+
database_cleaner-active_record (2.0.1)
|
75
|
+
activerecord (>= 5.a)
|
76
|
+
database_cleaner-core (~> 2.0.0)
|
77
|
+
database_cleaner-core (2.0.1)
|
78
|
+
diff-lcs (1.4.4)
|
79
|
+
docile (1.4.0)
|
80
|
+
down (5.2.3)
|
81
|
+
addressable (~> 2.8)
|
82
|
+
erubi (1.10.0)
|
83
|
+
factory_bot (6.2.0)
|
84
|
+
activesupport (>= 5.0.0)
|
85
|
+
ffi (1.15.3)
|
86
|
+
geocoder (1.6.7)
|
87
|
+
globalid (0.5.2)
|
88
|
+
activesupport (>= 5.0)
|
89
|
+
i18n (1.8.10)
|
90
|
+
concurrent-ruby (~> 1.0)
|
91
|
+
image_processing (1.12.1)
|
92
|
+
mini_magick (>= 4.9.5, < 5)
|
93
|
+
ruby-vips (>= 2.0.17, < 3)
|
94
|
+
loofah (2.12.0)
|
95
|
+
crass (~> 1.0.2)
|
96
|
+
nokogiri (>= 1.5.9)
|
97
|
+
mail (2.7.1)
|
98
|
+
mini_mime (>= 0.1.1)
|
99
|
+
marcel (1.0.1)
|
100
|
+
method_source (1.0.0)
|
101
|
+
mime-types (3.3.1)
|
102
|
+
mime-types-data (~> 3.2015)
|
103
|
+
mime-types-data (3.2021.0704)
|
104
|
+
mimemagic (0.3.10)
|
105
|
+
nokogiri (~> 1)
|
106
|
+
rake
|
107
|
+
mini_magick (4.11.0)
|
108
|
+
mini_mime (1.1.1)
|
109
|
+
mini_portile2 (2.6.1)
|
110
|
+
minitest (5.14.4)
|
111
|
+
mongo (2.15.0)
|
112
|
+
bson (>= 4.8.2, < 5.0.0)
|
113
|
+
mongoid (6.4.8)
|
114
|
+
activemodel (>= 5.1, < 6.0.0)
|
115
|
+
mongo (>= 2.5.1, < 3.0.0)
|
116
|
+
mongoid-compatibility (0.5.1)
|
117
|
+
activesupport
|
118
|
+
mongoid (>= 2.0)
|
119
|
+
mongoid-grid_fs (2.4.0)
|
120
|
+
mime-types (>= 1.0, < 4.0)
|
121
|
+
mongoid (>= 3.0, < 8.0)
|
122
|
+
mongoid-paperclip (0.0.11)
|
123
|
+
mongoid
|
124
|
+
paperclip (>= 2.3.6, != 4.3.0)
|
125
|
+
mongoid-rspec (4.1.0)
|
126
|
+
activesupport (>= 3.0.0)
|
127
|
+
mongoid (>= 3.1)
|
128
|
+
mongoid-compatibility (>= 0.5.1)
|
129
|
+
rspec-core (~> 3.3)
|
130
|
+
rspec-expectations (~> 3.3)
|
131
|
+
rspec-mocks (~> 3.3)
|
132
|
+
nio4r (2.5.8)
|
133
|
+
nokogiri (1.12.3)
|
134
|
+
mini_portile2 (~> 2.6.1)
|
135
|
+
racc (~> 1.4)
|
136
|
+
paperclip (6.1.0)
|
137
|
+
activemodel (>= 4.2.0)
|
138
|
+
activesupport (>= 4.2.0)
|
139
|
+
mime-types
|
140
|
+
mimemagic (~> 0.3.0)
|
141
|
+
terrapin (~> 0.6.0)
|
142
|
+
parallel (1.20.1)
|
143
|
+
parser (3.0.2.0)
|
144
|
+
ast (~> 2.4.1)
|
145
|
+
public_suffix (4.0.6)
|
146
|
+
racc (1.5.2)
|
147
|
+
rack (2.2.3)
|
148
|
+
rack-test (1.1.0)
|
149
|
+
rack (>= 1.0, < 3)
|
150
|
+
rails (5.2.6)
|
151
|
+
actioncable (= 5.2.6)
|
152
|
+
actionmailer (= 5.2.6)
|
153
|
+
actionpack (= 5.2.6)
|
154
|
+
actionview (= 5.2.6)
|
155
|
+
activejob (= 5.2.6)
|
156
|
+
activemodel (= 5.2.6)
|
157
|
+
activerecord (= 5.2.6)
|
158
|
+
activestorage (= 5.2.6)
|
159
|
+
activesupport (= 5.2.6)
|
160
|
+
bundler (>= 1.3.0)
|
161
|
+
railties (= 5.2.6)
|
162
|
+
sprockets-rails (>= 2.0.0)
|
163
|
+
rails-dom-testing (2.0.3)
|
164
|
+
activesupport (>= 4.2.0)
|
165
|
+
nokogiri (>= 1.6)
|
166
|
+
rails-html-sanitizer (1.4.2)
|
167
|
+
loofah (~> 2.3)
|
168
|
+
railties (5.2.6)
|
169
|
+
actionpack (= 5.2.6)
|
170
|
+
activesupport (= 5.2.6)
|
171
|
+
method_source
|
172
|
+
rake (>= 0.8.7)
|
173
|
+
thor (>= 0.19.0, < 2.0)
|
174
|
+
rainbow (3.0.0)
|
175
|
+
rake (13.0.6)
|
176
|
+
regexp_parser (2.1.1)
|
177
|
+
rexml (3.2.5)
|
178
|
+
rspec (3.10.0)
|
179
|
+
rspec-core (~> 3.10.0)
|
180
|
+
rspec-expectations (~> 3.10.0)
|
181
|
+
rspec-mocks (~> 3.10.0)
|
182
|
+
rspec-core (3.10.1)
|
183
|
+
rspec-support (~> 3.10.0)
|
184
|
+
rspec-expectations (3.10.1)
|
185
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
186
|
+
rspec-support (~> 3.10.0)
|
187
|
+
rspec-mocks (3.10.2)
|
188
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
189
|
+
rspec-support (~> 3.10.0)
|
190
|
+
rspec-support (3.10.2)
|
191
|
+
rubocop (1.19.1)
|
192
|
+
parallel (~> 1.10)
|
193
|
+
parser (>= 3.0.0.0)
|
194
|
+
rainbow (>= 2.2.2, < 4.0)
|
195
|
+
regexp_parser (>= 1.8, < 3.0)
|
196
|
+
rexml
|
197
|
+
rubocop-ast (>= 1.9.1, < 2.0)
|
198
|
+
ruby-progressbar (~> 1.7)
|
199
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
200
|
+
rubocop-ast (1.11.0)
|
201
|
+
parser (>= 3.0.1.1)
|
202
|
+
rubocop-rspec (2.4.0)
|
203
|
+
rubocop (~> 1.0)
|
204
|
+
rubocop-ast (>= 1.1.0)
|
205
|
+
ruby-progressbar (1.11.0)
|
206
|
+
ruby-vips (2.1.3)
|
207
|
+
ffi (~> 1.12)
|
208
|
+
russian_phone (0.7.0)
|
209
|
+
safe_yaml (1.0.5)
|
210
|
+
sanitize (6.0.0)
|
211
|
+
crass (~> 1.0.2)
|
212
|
+
nokogiri (>= 1.12.0)
|
213
|
+
shrine (3.4.0)
|
214
|
+
content_disposition (~> 1.0)
|
215
|
+
down (~> 5.1)
|
216
|
+
shrine-mongoid (1.0.0)
|
217
|
+
mongoid (>= 5.0)
|
218
|
+
shrine (>= 3.0.0.beta3, < 4)
|
219
|
+
simplecov (0.21.2)
|
220
|
+
docile (~> 1.1)
|
221
|
+
simplecov-html (~> 0.11)
|
222
|
+
simplecov_json_formatter (~> 0.1)
|
223
|
+
simplecov-html (0.12.3)
|
224
|
+
simplecov_json_formatter (0.1.3)
|
225
|
+
sprockets (4.0.2)
|
226
|
+
concurrent-ruby (~> 1.0)
|
227
|
+
rack (> 1, < 3)
|
228
|
+
sprockets-rails (3.2.2)
|
229
|
+
actionpack (>= 4.0)
|
230
|
+
activesupport (>= 4.0)
|
231
|
+
sprockets (>= 3.0.0)
|
232
|
+
ssrf_filter (1.0.7)
|
233
|
+
terrapin (0.6.0)
|
234
|
+
climate_control (>= 0.0.3, < 1.0)
|
235
|
+
thor (1.1.0)
|
236
|
+
thread_safe (0.3.6)
|
237
|
+
tzinfo (1.2.9)
|
238
|
+
thread_safe (~> 0.1)
|
239
|
+
unicode-display_width (2.0.0)
|
240
|
+
validates_email_format_of (1.6.3)
|
241
|
+
i18n
|
242
|
+
websocket-driver (0.7.5)
|
243
|
+
websocket-extensions (>= 0.1.0)
|
244
|
+
websocket-extensions (0.1.5)
|
245
|
+
|
246
|
+
PLATFORMS
|
247
|
+
ruby
|
248
|
+
|
249
|
+
DEPENDENCIES
|
250
|
+
addressable
|
251
|
+
bundler
|
252
|
+
carrierwave-mongoid
|
253
|
+
database_cleaner
|
254
|
+
factory_bot
|
255
|
+
geocoder
|
256
|
+
image_processing
|
257
|
+
mini_magick
|
258
|
+
mongoid (~> 6.3)
|
259
|
+
mongoid-paperclip
|
260
|
+
mongoid-rspec
|
261
|
+
rails
|
262
|
+
rake
|
263
|
+
rspec
|
264
|
+
rubocop-rspec
|
265
|
+
russian_phone
|
266
|
+
safe_yaml
|
267
|
+
sanitize
|
268
|
+
shrine (~> 3.0)
|
269
|
+
shrine-mongoid (~> 1.0)
|
270
|
+
simplecov
|
271
|
+
thecore_settings!
|
272
|
+
validates_email_format_of
|
273
|
+
|
274
|
+
BUNDLED WITH
|
275
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Gleb Tv
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
# ThecoreSettings
|
2
|
+
|
3
|
+
Project forked from:
|
4
|
+
|
5
|
+
https://gitlab.com/rocket-science/rails_admin_settings
|
6
|
+
|
7
|
+
Since it looks in hyatus.
|
8
|
+
|
9
|
+
|
10
|
+
[](http://travis-ci.org/rs-pro/thecore_settings)
|
11
|
+
[](https://badge.fury.io/rb/thecore_settings)
|
12
|
+
[](https://hakiri.io/github/rs-pro/thecore_settings/master)
|
13
|
+
[](https://codeclimate.com/github/rs-pro/thecore_settings/maintainability)
|
14
|
+
[](https://codeclimate.com/github/rs-pro/thecore_settings/test_coverage)
|
15
|
+
|
16
|
+
App settings editable via RailsAdmin with support for ActiveRecord and Mongoid.
|
17
|
+
|
18
|
+
Supports images, files, html with or without sanitization, code with codemirror, etc.
|
19
|
+
|
20
|
+
## Features
|
21
|
+
|
22
|
+
- Lazy loading - loads settings only if they are needed during request
|
23
|
+
- Loads all settings at once and caches them for the duration of request
|
24
|
+
- Supports lots of setting kinds - yaml, html with ckeditor, phone numbers etc
|
25
|
+
- Each setting can be enabled and disabled within rails_admin, if it's disabled it returns default value for kind
|
26
|
+
|
27
|
+
## Installation
|
28
|
+
|
29
|
+
1. Add this line to your application's Gemfile:
|
30
|
+
|
31
|
+
```shell
|
32
|
+
gem 'thecore_settings'
|
33
|
+
```
|
34
|
+
|
35
|
+
2. Then migrate:
|
36
|
+
|
37
|
+
```shell
|
38
|
+
rails db:migrate
|
39
|
+
```
|
40
|
+
|
41
|
+
|
42
|
+
### OPTIONAL Generage migration
|
43
|
+
|
44
|
+
Not needed anymore since migrations from this gem are automatically loaded by main app when needed:
|
45
|
+
|
46
|
+
```shell
|
47
|
+
rails g thecore_settings:migration
|
48
|
+
```
|
49
|
+
|
50
|
+
## Gemfile order matters
|
51
|
+
|
52
|
+
- Put it after rails_admin to get built-in support
|
53
|
+
- Put it after rails_admin_toggleable to get built-in support
|
54
|
+
- Put it after ckeditor/glebtv-ckeditor/rich to get built-in support
|
55
|
+
- Put it after russian_phone to get built-in support
|
56
|
+
- Put it after sanitized to get built-in support
|
57
|
+
- Put it after safe_yaml to get built-in support
|
58
|
+
- Put it after validates_email_format_of to get built-in support
|
59
|
+
- Put it after geocoder to get built-in support
|
60
|
+
- Put it after carrierwave / paperclip to get built-in support
|
61
|
+
- Put it after addressable to get built-in support
|
62
|
+
|
63
|
+
And then execute:
|
64
|
+
|
65
|
+
$ bundle
|
66
|
+
|
67
|
+
Or install it yourself as:
|
68
|
+
|
69
|
+
$ gem install thecore_settings
|
70
|
+
|
71
|
+
## Basic Usage (like RailsSettings)
|
72
|
+
|
73
|
+
Settings.admin_email = 'test@example.com'
|
74
|
+
Settings.admin_email
|
75
|
+
|
76
|
+
|
77
|
+
## Advanced Usage
|
78
|
+
|
79
|
+
Settings.content_block_1(kind: 'html', default: 'test', label: "Test Value")
|
80
|
+
Settings.data(kind: 'yaml')
|
81
|
+
Settings.data = [1, 2, 3]
|
82
|
+
|
83
|
+
Settings.enabled?(:phone, kind: 'phone', default: '906 111-11-11') # also creates setting if it doesn't exist
|
84
|
+
Settings.phone.area
|
85
|
+
Settings.phone.subscriber
|
86
|
+
|
87
|
+
See more here: https://github.com/rs-pro/thecore_settings/blob/master/spec/advanced_usage_spec.rb
|
88
|
+
|
89
|
+
## Namespacing
|
90
|
+
|
91
|
+
Settings can have namespaces (useful for locale, etc)
|
92
|
+
|
93
|
+
Settings.ns('test').s1 = 123
|
94
|
+
Settings.ns('test').s1
|
95
|
+
> "123"
|
96
|
+
Settings.ns('main').s1
|
97
|
+
> ""
|
98
|
+
Settings.s1
|
99
|
+
> ""
|
100
|
+
Settings.ns_default = 'test'
|
101
|
+
Settings.s1
|
102
|
+
> "123"
|
103
|
+
Settings.ns_default = 'main'
|
104
|
+
Settings.ns_fallback = 'test'
|
105
|
+
Settings.s1
|
106
|
+
> "123"
|
107
|
+
|
108
|
+
|
109
|
+
## Value types
|
110
|
+
|
111
|
+
Supported types:
|
112
|
+
|
113
|
+
string (input)
|
114
|
+
text (textarea)
|
115
|
+
boolean (checkbox)
|
116
|
+
color (uses built-in RailsAdmin color picker)
|
117
|
+
html (does NOT sanitize (allows ANY javascript) - for trusted admin, supports Rich, glebtv-ckeditor, ckeditor, but does not require any of them)
|
118
|
+
code (does NOT sanitize (allows ANY javascript) - shows as codemirror, requires glebtv-ckeditor for codemirror)
|
119
|
+
sanitized (requires sanitize gem -- sanitizes HTML before saving to DB [Warning: uses RELAXED config!])
|
120
|
+
integer (stored as string)
|
121
|
+
yaml (requires safe_yaml)
|
122
|
+
phone (requires russian_phone)
|
123
|
+
phones (requires russian_phone - multiple phones)
|
124
|
+
email (requires validates_email_format_of)
|
125
|
+
address (requires geocoder)
|
126
|
+
file (requires paperclip or carrierwave)
|
127
|
+
url (requires addressable)
|
128
|
+
domain (requires addressable)
|
129
|
+
sanitize (uses rails sanitize helper with default settings, shows as html)
|
130
|
+
sanitize_code (uses rails sanitize helper with default settings, shows as codemirror textarea, can provide custom scrubber, defaults to Rails::Html::WhiteListSanitizer)
|
131
|
+
strip_tags (uses strip_tags rails helper)
|
132
|
+
simple_format (uses simple_format rails helper)
|
133
|
+
simple_format_raw (does NOT sanitize (allows ANY javascript) - uses simple_format rails helper with sanitize: false)
|
134
|
+
json
|
135
|
+
|
136
|
+
#### Sanitize settings
|
137
|
+
|
138
|
+
Sanitizer can be changed like this:
|
139
|
+
```
|
140
|
+
RalsAdminSettings.scrubber = Rails::Html::WhiteListSanitizer.new
|
141
|
+
```
|
142
|
+
defaults to Rails::Html::WhiteListSanitizer
|
143
|
+
|
144
|
+
Strings and html support following replacement patterns:
|
145
|
+
|
146
|
+
{{year}} -> current year
|
147
|
+
{{year|2013}} -> 2013 in 2013, 2013-2014 in 2014, etc
|
148
|
+
|
149
|
+
Sanitized types sanitize before storing to DB and not on display for performance.
|
150
|
+
Simple format types are stored in db as-is.
|
151
|
+
|
152
|
+
## Usage with Rails Admin
|
153
|
+
|
154
|
+
Rails admin management for settings is supported out of the box
|
155
|
+
|
156
|
+
It is recommended to disable new/create page (it is not supported by design, settings are defined in ruby code).
|
157
|
+
Disable via cancan:
|
158
|
+
|
159
|
+
```
|
160
|
+
cannot :create, ThecoreSettings::Setting
|
161
|
+
```
|
162
|
+
|
163
|
+
## Contributing
|
164
|
+
|
165
|
+
1. Fork it
|
166
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
167
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
168
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
169
|
+
5. Create new Pull Request
|