rails_admin_settings 0.3.3 → 0.3.4
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.
- data/README.md +2 -1
- data/app/models/rails_admin_settings/setting.rb +1 -0
- data/lib/rails_admin_settings/processing.rb +10 -1
- data/lib/rails_admin_settings/rails_admin_config.rb +8 -0
- data/lib/rails_admin_settings/settings.rb +4 -0
- data/lib/rails_admin_settings/storage/carrierwave.rb +9 -0
- data/lib/rails_admin_settings/types.rb +1 -1
- data/lib/rails_admin_settings/uploads.rb +25 -0
- data/lib/rails_admin_settings/validation.rb +7 -0
- data/lib/rails_admin_settings/version.rb +1 -1
- data/lib/rails_admin_settings.rb +1 -0
- metadata +5 -3
data/README.md
CHANGED
@@ -30,6 +30,7 @@ Add this line to your application's Gemfile:
|
|
30
30
|
- Put it after safe_yaml to get built-in support
|
31
31
|
- Put it after validates_email_format_of to get built-in support
|
32
32
|
- Put it after geocoder to get built-in support
|
33
|
+
- Put it after carrierwave / paperclip to get built-in support
|
33
34
|
|
34
35
|
And then execute:
|
35
36
|
|
@@ -67,7 +68,7 @@ Supported types:
|
|
67
68
|
phone (requires russian_phone)
|
68
69
|
email (requires validates_email_format_of)
|
69
70
|
address (requires geocoder)
|
70
|
-
|
71
|
+
file (requires paperclip or carrierwave)
|
71
72
|
|
72
73
|
Strings and html support following replacement patterns:
|
73
74
|
|
@@ -32,8 +32,14 @@ module RailsAdminSettings
|
|
32
32
|
'sanitized' == type
|
33
33
|
end
|
34
34
|
|
35
|
+
def file_type?
|
36
|
+
'file' == type
|
37
|
+
end
|
38
|
+
|
35
39
|
def value
|
36
|
-
if
|
40
|
+
if file_type?
|
41
|
+
file.url
|
42
|
+
elsif raw.blank? || disabled?
|
37
43
|
default_value
|
38
44
|
else
|
39
45
|
processed_value
|
@@ -112,7 +118,10 @@ module RailsAdminSettings
|
|
112
118
|
load_yaml
|
113
119
|
elsif phone_type?
|
114
120
|
load_phone
|
121
|
+
elsif file_type?
|
122
|
+
file.url
|
115
123
|
else
|
124
|
+
puts "[rails_admin_settings] Unknown field type: #{type}"
|
116
125
|
nil
|
117
126
|
end
|
118
127
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RailsAdminSettings
|
2
|
+
module Uploads
|
3
|
+
autoload :CarrierWave, "rails_admin_settings/storage/carrierwave"
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
# carrierwave
|
7
|
+
if base.respond_to?(:mount_uploader)
|
8
|
+
# puts "[rails_admin_settings] CarrierWave detected"
|
9
|
+
base.field(:file, type: String)
|
10
|
+
base.mount_uploader(:file, RailsAdminSettings::Uploads::CarrierWave)
|
11
|
+
Settings.file_uploads_supported = true
|
12
|
+
Settings.file_uploads_engine = :carrierwave
|
13
|
+
# paperclip
|
14
|
+
elsif base.respond_to?(:has_mongoid_attached_file)
|
15
|
+
# puts "[rails_admin_settings] PaperClip detected"
|
16
|
+
base.field(:file, type: String)
|
17
|
+
base.has_mongoid_attached_file(:file)
|
18
|
+
Settings.file_uploads_supported = true
|
19
|
+
Settings.file_uploads_engine = :paperclip
|
20
|
+
else
|
21
|
+
# puts "[rails_admin_settings] Uploads disabled"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -27,6 +27,13 @@ module RailsAdminSettings
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
base.validate if: :file_type? do
|
31
|
+
unless Settings.file_uploads_supported
|
32
|
+
raise '[rails_admin_settings] File type requires either CarrierWave or Paperclip. Check that rails_admin_settings is below them in Gemfile'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
30
37
|
if Object.const_defined?('Geocoder')
|
31
38
|
base.field(:coordinates, type: Array, default: [])
|
32
39
|
base.send(:include, Geocoder::Model::Mongoid)
|
data/lib/rails_admin_settings.rb
CHANGED
@@ -5,6 +5,7 @@ module RailsAdminSettings
|
|
5
5
|
autoload :Validation, "rails_admin_settings/validation"
|
6
6
|
autoload :RequireHelpers, "rails_admin_settings/require_helpers"
|
7
7
|
autoload :RailsAdminConfig, "rails_admin_settings/rails_admin_config"
|
8
|
+
autoload :Uploads, "rails_admin_settings/uploads"
|
8
9
|
end
|
9
10
|
|
10
11
|
require "rails_admin_settings/types"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -244,7 +244,9 @@ files:
|
|
244
244
|
- lib/rails_admin_settings/rails_admin_config.rb
|
245
245
|
- lib/rails_admin_settings/require_helpers.rb
|
246
246
|
- lib/rails_admin_settings/settings.rb
|
247
|
+
- lib/rails_admin_settings/storage/carrierwave.rb
|
247
248
|
- lib/rails_admin_settings/types.rb
|
249
|
+
- lib/rails_admin_settings/uploads.rb
|
248
250
|
- lib/rails_admin_settings/validation.rb
|
249
251
|
- lib/rails_admin_settings/version.rb
|
250
252
|
- rails_admin_settings.gemspec
|
@@ -271,7 +273,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
271
273
|
version: '0'
|
272
274
|
segments:
|
273
275
|
- 0
|
274
|
-
hash:
|
276
|
+
hash: 126914792518638842
|
275
277
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
276
278
|
none: false
|
277
279
|
requirements:
|
@@ -280,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
282
|
version: '0'
|
281
283
|
segments:
|
282
284
|
- 0
|
283
|
-
hash:
|
285
|
+
hash: 126914792518638842
|
284
286
|
requirements: []
|
285
287
|
rubyforge_project:
|
286
288
|
rubygems_version: 1.8.25
|