thecore_settings 3.0.10 → 3.1.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/app/models/thecore_settings/setting.rb +30 -0
- data/app/views/rails_admin/main/_setting_value.html.erb +6 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/it.yml +1 -0
- data/lib/thecore_settings/rails_admin_config.rb +26 -19
- data/lib/thecore_settings/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cb2029264f95f1b0aafbfbd3f98fc5b23748b2a2747313fe777166eef253e255
|
|
4
|
+
data.tar.gz: 26f3fea85b47b4c1a587da9d92025282067814bd25af1350a45c249aa8f2e928
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1b3bbeda73101c4952f6c99fa642e175cd0e4a6579cf4840862f61b3f64e9571e0121c69d06214d7e615e4bc7c3296f89af076642f276f47fd6776a2be1f9576
|
|
7
|
+
data.tar.gz: dee6112ab34c18645aff70b90ab805232c80c3a2c2cea15053fa54ed28757fee8ccaaec24ce41844e7cc70a72d0f583b93e29a742cc6a03aa0a141b88f78a15f
|
|
@@ -23,6 +23,32 @@ module ThecoreSettings
|
|
|
23
23
|
include ThecoreSettings::Uploads
|
|
24
24
|
include ThecoreSettings::Validation
|
|
25
25
|
|
|
26
|
+
# A key that names a secret (smtp.password, sql.password, the SMB shares' password,
|
|
27
|
+
# vapid.private_key, ...): the whole key or its last underscore-separated part.
|
|
28
|
+
SECRET_KEY = /(\A|_)(password|passwd|secret|private_key|api_key|token)\z/i
|
|
29
|
+
|
|
30
|
+
def self.secret_key?(key)
|
|
31
|
+
SECRET_KEY.match?(key.to_s)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# A Secret setting is write-only (host ADR 0046 point 10): the code reads raw, nothing
|
|
35
|
+
# serializes it, and a blank save (the masked RailsAdmin field left empty) keeps the stored
|
|
36
|
+
# value. To clear one, destroy the row (the seeds recreate it empty).
|
|
37
|
+
def secret?
|
|
38
|
+
self.class.secret_key?(key)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
before_save :keep_secret_when_blank, if: :secret?
|
|
42
|
+
|
|
43
|
+
# No `methods:` for a secret, whose value could come back through any of them (value,
|
|
44
|
+
# attributes, raw_was...), and raw always nil.
|
|
45
|
+
def serializable_hash(options = nil)
|
|
46
|
+
return super unless secret?
|
|
47
|
+
|
|
48
|
+
options = (options || {}).to_h.symbolize_keys.except(:methods)
|
|
49
|
+
super(options).tap { |hash| hash["raw"] = nil if hash.key?("raw") }
|
|
50
|
+
end
|
|
51
|
+
|
|
26
52
|
def disabled?
|
|
27
53
|
!enabled
|
|
28
54
|
end
|
|
@@ -39,6 +65,10 @@ module ThecoreSettings
|
|
|
39
65
|
kind
|
|
40
66
|
end
|
|
41
67
|
|
|
68
|
+
private def keep_secret_when_blank
|
|
69
|
+
self.raw = raw_in_database if raw.blank? && raw_in_database.present?
|
|
70
|
+
end
|
|
71
|
+
|
|
42
72
|
def to_path
|
|
43
73
|
if value.nil?
|
|
44
74
|
nil
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
<%# A Secret setting is write-only (host ADR 0046 point 10): an empty password field, left empty to keep the stored value. %>
|
|
2
|
+
<% if @object.secret? %>
|
|
3
|
+
<%= form.password_field :raw, value: nil, autocomplete: "new-password",
|
|
4
|
+
placeholder: (@object.raw_in_database.present? ? t("admin.settings.secret_set", default: "Set: leave empty to keep it") : nil) %>
|
|
5
|
+
<% else %>
|
|
1
6
|
<% if ['string', 'integer', 'float', 'phone', 'email', 'address', 'url', 'domain'].include?(@object.type) %>
|
|
2
7
|
<%= form.text_field :raw, :value => field.value %>
|
|
3
8
|
<% end %>
|
|
@@ -49,3 +54,4 @@
|
|
|
49
54
|
<%= form.text_area :raw, :value => field.value, :rows => 10, :cols => 80 %>
|
|
50
55
|
<% end %>
|
|
51
56
|
<% end %>
|
|
57
|
+
<% end %>
|
data/config/locales/en.yml
CHANGED
data/config/locales/it.yml
CHANGED
|
@@ -7,6 +7,7 @@ it:
|
|
|
7
7
|
admin:
|
|
8
8
|
settings:
|
|
9
9
|
label: 'Impostazioni'
|
|
10
|
+
secret_set: "Impostata: lascia vuoto per mantenerla"
|
|
10
11
|
no_ckeditor_detected: CKEditor non trovato — mostro il campo come semplice testo
|
|
11
12
|
phone_invalid: Telefono non valido
|
|
12
13
|
phones_invalid: "Telefono non valido: %{phones}"
|
|
@@ -4,6 +4,31 @@ module ThecoreSettings
|
|
|
4
4
|
if base.respond_to?(:rails_admin)
|
|
5
5
|
base.rails_admin do
|
|
6
6
|
navigation_label Proc.new {I18n.t("admin.settings.label")}
|
|
7
|
+
# One pretty_value for list, show and export (export_value is pretty_value): a Secret
|
|
8
|
+
# setting shows only whether it is set (host ADR 0046 point 10).
|
|
9
|
+
configure :raw do
|
|
10
|
+
pretty_value do
|
|
11
|
+
object = bindings[:object]
|
|
12
|
+
if object.secret?
|
|
13
|
+
object.raw.present? ? "••••••••" : "-"
|
|
14
|
+
elsif object.file_kind? and !defined?(Shrine) and object.to_path.present?
|
|
15
|
+
if object.file.url.blank?
|
|
16
|
+
"-"
|
|
17
|
+
else
|
|
18
|
+
"<a href='#{CGI::escapeHTML(object.file.url)}'>#{CGI::escapeHTML(object.to_path)}</a>".html_safe
|
|
19
|
+
end
|
|
20
|
+
elsif object.image_kind? and !defined?(Shrine) and !object.file.nil?
|
|
21
|
+
if object.file.url.blank?
|
|
22
|
+
"-"
|
|
23
|
+
else
|
|
24
|
+
"<a href='#{CGI::escapeHTML(object.file.url)}'><img src='#{CGI::escapeHTML(object.file.url)}' /></a>".html_safe
|
|
25
|
+
end
|
|
26
|
+
else
|
|
27
|
+
value
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
7
32
|
list do
|
|
8
33
|
if Object.const_defined?('RailsAdminToggleable')
|
|
9
34
|
field :enabled, :toggle
|
|
@@ -13,25 +38,7 @@ module ThecoreSettings
|
|
|
13
38
|
field :kind
|
|
14
39
|
field :ns
|
|
15
40
|
field :name
|
|
16
|
-
field :raw
|
|
17
|
-
pretty_value do
|
|
18
|
-
if bindings[:object].file_kind? and !defined?(Shrine) and bindings[:object].to_path.present?
|
|
19
|
-
if bindings[:object].file.url.blank?
|
|
20
|
-
"-"
|
|
21
|
-
else
|
|
22
|
-
"<a href='#{CGI::escapeHTML(bindings[:object].file.url)}'>#{CGI::escapeHTML(bindings[:object].to_path)}</a>".html_safe
|
|
23
|
-
end
|
|
24
|
-
elsif bindings[:object].image_kind? and !defined?(Shrine) and !bindings[:object].file.nil?
|
|
25
|
-
if bindings[:object].file.url.blank?
|
|
26
|
-
"-"
|
|
27
|
-
else
|
|
28
|
-
"<a href='#{CGI::escapeHTML(bindings[:object].file.url)}'><img src='#{CGI::escapeHTML(bindings[:object].file.url)}' /></a>".html_safe
|
|
29
|
-
end
|
|
30
|
-
else
|
|
31
|
-
value
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
41
|
+
field :raw
|
|
35
42
|
if ::Settings.table_exists?
|
|
36
43
|
nss = ::ThecoreSettings::Setting.pluck(:ns).uniq.map { |c| "ns_#{c.gsub('-', '_')}".to_sym }
|
|
37
44
|
scopes([nil] + nss)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: thecore_settings
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gabriele Tassoni
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-11-
|
|
12
|
+
date: 2026-11-25 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: safe_yaml
|