fullstack-cms 0.3.39 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/helpers/settings_helper.rb +8 -14
- data/app/models/setting.rb +18 -30
- data/fullstack-cms.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.1
|
@@ -1,19 +1,13 @@
|
|
1
1
|
module SettingsHelper
|
2
|
-
|
3
|
-
#
|
4
|
-
# setting(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
value = args.first
|
10
|
-
namespaced_key = namespaced_key.to_s
|
11
|
-
group, key = namespaced_key.include?(namespace_separator) ? namespaced_key.split(namespace_separator) : [nil, namespaced_key]
|
12
|
-
|
13
|
-
s = Setting.global("#{key}", :autocreate => false, :default => value, :group => group, :options => opts[:options], :locale => ((Fullstack::Cms.localized == false || opts[:locale] == false) ? nil : I18n.locale.to_s))
|
14
|
-
|
2
|
+
|
3
|
+
#
|
4
|
+
# setting( 'footer/heading', Settings.app.title )
|
5
|
+
#
|
6
|
+
|
7
|
+
def setting(*args)
|
8
|
+
Setting.get(*args)
|
15
9
|
end
|
16
|
-
|
10
|
+
|
17
11
|
alias :get_setting :setting
|
18
12
|
|
19
13
|
end
|
data/app/models/setting.rb
CHANGED
@@ -47,34 +47,22 @@ class Setting < ActiveRecord::Base
|
|
47
47
|
self.send("#{setting_kind}_value")
|
48
48
|
end
|
49
49
|
|
50
|
-
# examples
|
51
|
-
#
|
52
|
-
# Setting.get("contacts/registrant", :default => "[ none ]")
|
53
|
-
# Setting.get( :registrant, :group => :contacts )
|
54
|
-
# Setting.get( "address", :of => @user )
|
55
|
-
|
56
|
-
def self.get(key, opts = {})
|
57
|
-
key = key.to_s
|
58
|
-
gk = key.split("/")
|
59
50
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
51
|
+
def self.get(*args)
|
52
|
+
cached_settings = Rails.cache.read('fullstack-settings-cache')
|
53
|
+
|
54
|
+
unless cached_settings
|
55
|
+
cached_settings = {}
|
56
|
+
Setting.where("locale = ? OR locale IS NULL", I18n.locale.to_s).all.each do |setting|
|
57
|
+
g = setting.group == "global" ? nil : setting.group
|
58
|
+
k = [g, setting.key].compact.join('/')
|
59
|
+
cached_settings[k] = setting.value if setting.value
|
66
60
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
query = opts.dup
|
73
|
-
query.merge!({:key => key})
|
74
|
-
query.merge!({:group => group}) if group
|
75
|
-
query.merge!({:settable_id => settable_id})
|
76
|
-
|
77
|
-
self.where(query).first.try(:value) || default
|
61
|
+
|
62
|
+
Rails.cache.write('fullstack-settings-cache', cached_settings)
|
63
|
+
end
|
64
|
+
|
65
|
+
cached_settings.fetch(*(args[0..1]))
|
78
66
|
end
|
79
67
|
|
80
68
|
# using Setting.get is simpler, expecially if you don't want 'autocreate' feature
|
@@ -119,9 +107,9 @@ class Setting < ActiveRecord::Base
|
|
119
107
|
field :options, :text
|
120
108
|
serialize :options, Hash
|
121
109
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
110
|
+
after_save do
|
111
|
+
Rails.cache.delete('fullstack-settings-cache')
|
112
|
+
end
|
113
|
+
|
126
114
|
end
|
127
115
|
|
data/fullstack-cms.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "fullstack-cms"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["mcasimir"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-02-18"
|
13
13
|
s.description = "CMS system built on fullstack"
|
14
14
|
s.email = "maurizio.cas@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fullstack-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fullstack-admin
|
@@ -294,7 +294,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
294
294
|
version: '0'
|
295
295
|
segments:
|
296
296
|
- 0
|
297
|
-
hash:
|
297
|
+
hash: 2565561884556814372
|
298
298
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
299
299
|
none: false
|
300
300
|
requirements:
|