trusty-cms 4.1.1 → 4.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +107 -107
  4. data/README.md +1 -1
  5. data/Rakefile +7 -7
  6. data/app/assets/javascripts/admin/assets.js +1 -1
  7. data/app/assets/javascripts/rad_social/rad_ajax_form.js +3 -0
  8. data/app/assets/javascripts/rad_social/rad_email.js +0 -1
  9. data/app/assets/javascripts/rad_social/rad_email_form.js +2 -7
  10. data/app/assets/stylesheets/admin/partials/_forms.scss +1 -1
  11. data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
  12. data/app/controllers/admin/assets_controller.rb +21 -31
  13. data/app/controllers/admin/configuration_controller.rb +9 -11
  14. data/app/controllers/admin/extensions_controller.rb +3 -3
  15. data/app/controllers/admin/layouts_controller.rb +3 -4
  16. data/app/controllers/admin/page_attachments_controller.rb +5 -5
  17. data/app/controllers/admin/page_fields_controller.rb +3 -4
  18. data/app/controllers/admin/page_parts_controller.rb +4 -5
  19. data/app/controllers/admin/pages_controller.rb +55 -56
  20. data/app/controllers/admin/references_controller.rb +1 -1
  21. data/app/controllers/admin/resource_controller.rb +132 -130
  22. data/app/controllers/admin/sites_controller.rb +4 -4
  23. data/app/controllers/admin/snippets_controller.rb +3 -4
  24. data/app/controllers/admin/users_controller.rb +16 -16
  25. data/app/controllers/application_controller.rb +47 -48
  26. data/app/controllers/site_controller.rb +51 -48
  27. data/app/controllers/social_mailer_controller.rb +12 -22
  28. data/app/helpers/admin/configuration_helper.rb +19 -20
  29. data/app/helpers/admin/layouts_helper.rb +0 -1
  30. data/app/helpers/admin/node_helper.rb +27 -24
  31. data/app/helpers/admin/pages_helper.rb +2 -2
  32. data/app/helpers/admin/preferences_helper.rb +0 -1
  33. data/app/helpers/admin/references_helper.rb +9 -10
  34. data/app/helpers/admin/regions_helper.rb +3 -3
  35. data/app/helpers/application_helper.rb +32 -33
  36. data/app/helpers/rad_social_helper.rb +8 -11
  37. data/app/helpers/scoped_helper.rb +1 -3
  38. data/app/helpers/sites_helper.rb +4 -4
  39. data/app/mailers/devise_mailer.rb +3 -4
  40. data/app/mailers/rad_social_mailer.rb +8 -8
  41. data/app/models/asset.rb +62 -63
  42. data/app/models/asset_type.rb +38 -39
  43. data/app/models/deprecated_tags.rb +3 -4
  44. data/app/models/file_not_found_page.rb +1 -3
  45. data/app/models/haml_filter.rb +1 -1
  46. data/app/models/layout.rb +4 -5
  47. data/app/models/legacy_user.rb +2 -2
  48. data/app/models/menu_renderer.rb +16 -18
  49. data/app/models/page.rb +96 -93
  50. data/app/models/page_attachment.rb +1 -2
  51. data/app/models/page_context.rb +11 -12
  52. data/app/models/page_part.rb +3 -4
  53. data/app/models/rails_page.rb +10 -12
  54. data/app/models/site.rb +22 -21
  55. data/app/models/snippet.rb +6 -8
  56. data/app/models/snippet_finder.rb +3 -3
  57. data/app/models/snippet_tags.rb +4 -4
  58. data/app/models/standard_tags.rb +258 -252
  59. data/app/models/status.rb +8 -8
  60. data/app/models/trusty_cms/config.rb +25 -25
  61. data/app/models/trusty_cms/page_response_cache_director.rb +2 -3
  62. data/app/models/user.rb +15 -14
  63. data/app/models/user_action_observer.rb +3 -3
  64. data/app/views/admin/assets/edit.html.haml +3 -9
  65. data/app/views/admin/assets/new.html.haml +0 -3
  66. data/app/views/admin/assets/remove.html.haml +1 -1
  67. data/app/views/admin/layouts/remove.html.haml +3 -2
  68. data/app/views/admin/page_parts/_page_part.html.haml +1 -1
  69. data/app/views/admin/snippets/remove.html.haml +3 -2
  70. data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
  71. data/app/views/widget/_email_form.html.haml +0 -5
  72. data/bin/rails +4 -4
  73. data/bin/trusty_cms +3 -5
  74. data/config.ru +1 -1
  75. data/config/application.rb +14 -15
  76. data/config/boot.rb +1 -2
  77. data/config/environment.rb +1 -1
  78. data/config/environments/production.rb +0 -1
  79. data/config/environments/test.rb +1 -2
  80. data/config/initializers/devise.rb +1 -1
  81. data/config/initializers/kraken.rb +2 -2
  82. data/config/initializers/tmp.rb +1 -1
  83. data/config/initializers/trusty_cms_config.rb +48 -48
  84. data/config/locales/en.yml +5 -4
  85. data/config/routes.rb +6 -7
  86. data/lib/active_record_extensions/active_record_extensions.rb +1 -2
  87. data/lib/annotatable.rb +3 -5
  88. data/lib/configuration_extensions/configuration_extensions.rb +1 -1
  89. data/lib/inheritable_class_attributes.rb +13 -9
  90. data/lib/login_system.rb +73 -73
  91. data/lib/method_observer.rb +13 -12
  92. data/lib/ostruct.rb +7 -10
  93. data/lib/simpleton.rb +0 -4
  94. data/lib/string_extensions/string_extensions.rb +3 -3
  95. data/lib/symbol_extensions/symbol_extensions.rb +1 -1
  96. data/lib/tasks/database.rake +28 -28
  97. data/lib/tasks/extensions.rake +18 -18
  98. data/lib/tasks/framework.rake +68 -68
  99. data/lib/tasks/radiant_config.rake +4 -4
  100. data/lib/tasks/snippets_extension_tasks.rake +11 -11
  101. data/lib/tasks/translate.rake +14 -14
  102. data/lib/tasks/upgrade_to_devise.rake +1 -1
  103. data/lib/translation_support.rb +22 -22
  104. data/lib/trusty_cms.rb +2 -2
  105. data/lib/trusty_cms/admin_ui.rb +19 -16
  106. data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
  107. data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
  108. data/lib/trusty_cms/available_locales.rb +2 -4
  109. data/lib/trusty_cms/config/definition.rb +11 -8
  110. data/lib/trusty_cms/engine.rb +13 -14
  111. data/lib/trusty_cms/extension.rb +14 -16
  112. data/lib/trusty_cms/extension_loader.rb +6 -6
  113. data/lib/trusty_cms/extension_migrator.rb +42 -41
  114. data/lib/trusty_cms/extension_path.rb +20 -19
  115. data/lib/trusty_cms/initializer.rb +5 -8
  116. data/lib/trusty_cms/pagination/controller.rb +7 -10
  117. data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
  118. data/lib/trusty_cms/resource_responses.rb +3 -3
  119. data/lib/trusty_cms/setup.rb +130 -132
  120. data/lib/trusty_cms/taggable.rb +19 -22
  121. data/lib/trusty_cms/task_support.rb +9 -6
  122. data/package.json +1 -1
  123. data/public/dispatch.fcgi +1 -1
  124. data/public/dispatch.rb +2 -2
  125. data/script/extension +1 -1
  126. data/script/rails +2 -2
  127. data/spec/dummy/package.json +1 -1
  128. data/spec/dummy/yarn.lock +3 -3
  129. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
  130. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
  131. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
  132. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
  133. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
  134. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
  135. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
  136. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
  137. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
  138. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
  139. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
  140. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
  141. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
  142. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
  143. data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
  144. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
  145. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
  146. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
  147. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
  148. data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
  149. data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
  150. data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
  151. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
  152. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
  153. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
  154. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
  155. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
  156. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
  157. data/trusty_cms.gemspec +25 -25
  158. data/vendor/extensions/clipped-extension/lib/clipped_admin_ui.rb +1 -1
  159. data/yarn.lock +7 -7
  160. metadata +7609 -105
  161. data/app/assets/javascripts/rad_social/captcha.js +0 -42
  162. data/app/views/admin/assets/refresh.html.haml +0 -14
@@ -17,7 +17,7 @@ namespace :import do
17
17
  admin: legacy.admin,
18
18
  designer: legacy.designer,
19
19
  content_editor: legacy.content_editor,
20
- notes: legacy.notes
20
+ notes: legacy.notes,
21
21
  )
22
22
  u.save!
23
23
  end
@@ -1,54 +1,54 @@
1
1
  class TranslationSupport
2
2
  class << self
3
-
4
- #Retrieve US word set
5
- def get_translation_keys(language_root, suffix=nil)
3
+ # Retrieve US word set
4
+ def get_translation_keys(language_root, suffix = nil)
6
5
  (dummy_comments, words) = read_file("#{language_root}/en#{suffix}.yml", 'en')
7
6
  words
8
7
  end
9
8
 
10
- #Retrieve comments, translation data in hash form
9
+ # Retrieve comments, translation data in hash form
11
10
  def read_file(filename, basename)
12
- (comments, data) = IO.read(filename).split(/\n#{basename}:\s*\n/) #Add error checking for failed file read?
13
- return comments, create_hash(data, basename)
11
+ (comments, data) = IO.read(filename).split(/\n#{basename}:\s*\n/) # Add error checking for failed file read?
12
+ [comments, create_hash(data, basename)]
14
13
  end
15
14
 
16
- #Creates hash of translation data
17
- def create_hash(data, basename)
15
+ # Creates hash of translation data
16
+ def create_hash(data, _basename)
18
17
  words = Hash.new
19
18
  return words if !data
19
+
20
20
  parent = Array.new
21
21
  previous_key = 'base'
22
22
  data.split("\n").each do |w|
23
23
  next if w.strip.blank?
24
+
24
25
  (key, value) = w.split(':', 2)
25
26
  value ||= ''
26
- shift = (key =~ /\w/)/2 - parent.size #Determine level of current key in comparison to parent array
27
- key = key.sub(/^\s+/,'')
28
- parent << previous_key if shift > 0 #If key is child of previous key, add previous key as parent
29
- (shift * -1).times { parent.pop } if shift < 0 #If key is not related to previous key, remove parent keys
30
- previous_key = key #Track key in case next key is child of this key
27
+ shift = (key =~ /\w/) / 2 - parent.size # Determine level of current key in comparison to parent array
28
+ key = key.sub(/^\s+/, '')
29
+ parent << previous_key if shift > 0 # If key is child of previous key, add previous key as parent
30
+ (shift * -1).times { parent.pop } if shift < 0 # If key is not related to previous key, remove parent keys
31
+ previous_key = key # Track key in case next key is child of this key
31
32
  words[parent.join(':') + ':' + key] = value unless key.blank?
32
33
  end
33
34
  words
34
35
  end
35
36
 
36
37
  def open_available_tags(filename)
37
- data = YAML::load(File.open("#{filename}"))
38
+ data = YAML::load(File.open(filename.to_s))
38
39
  data.to_s
39
40
  end
40
41
 
41
- #Writes to file from translation data hash structure
42
- def write_file(filename,basename,comments,words)
43
- File.open(filename, "w") do |log|
44
- log.puts(comments+"\n"+basename+": \n")
45
- words.sort.each do |k,v|
42
+ # Writes to file from translation data hash structure
43
+ def write_file(filename, basename, comments, words)
44
+ File.open(filename, 'w') do |log|
45
+ log.puts(comments + "\n" + basename + ": \n")
46
+ words.sort.each do |k, v|
46
47
  keys = k.split(':')
47
- (keys.size-1).times { keys[keys.size-1] = ' ' + keys[keys.size-1] } #Add indentation for children keys
48
- log.puts(keys[keys.size-1]+':'+v+"\n")
48
+ (keys.size - 1).times { keys[keys.size - 1] = ' ' + keys[keys.size - 1] } # Add indentation for children keys
49
+ log.puts(keys[keys.size - 1] + ':' + v + "\n")
49
50
  end
50
51
  end
51
52
  end
52
-
53
53
  end
54
54
  end
@@ -1,7 +1,7 @@
1
- TRUSTY_CMS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..")) unless defined? TRUSTY_CMS_ROOT
1
+ TRUSTY_CMS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) unless defined? TRUSTY_CMS_ROOT
2
2
 
3
3
  unless defined? TrustyCms::VERSION
4
4
  module TrustyCms
5
- VERSION = '4.1.1'
5
+ VERSION = '4.1.6'.freeze
6
6
  end
7
7
  end
@@ -18,10 +18,10 @@ module TrustyCms
18
18
  end
19
19
 
20
20
  def [](id)
21
- unless id.kind_of? Integer
22
- self.find {|subnav_item| subnav_item.name.to_s.titleize == id.to_s.titleize }
23
- else
21
+ if id.is_a? Integer
24
22
  super
23
+ else
24
+ find { |subnav_item| subnav_item.name.to_s.titleize == id.to_s.titleize }
25
25
  end
26
26
  end
27
27
 
@@ -29,6 +29,7 @@ module TrustyCms
29
29
  options = args.extract_options!
30
30
  item = args.size > 1 ? deprecated_add(*(args << caller)) : args.first
31
31
  raise DuplicateTabNameError.new("duplicate tab name `#{item.name}'") if self[item.name]
32
+
32
33
  item.tab = self if item.respond_to?(:tab=)
33
34
  if options.empty?
34
35
  super(item)
@@ -79,8 +80,9 @@ module TrustyCms
79
80
  attr_reader :name, :url
80
81
  attr_accessor :tab
81
82
 
82
- def initialize(name, url = "#")
83
- @name, @url = name, url
83
+ def initialize(name, url = '#')
84
+ @name = name
85
+ @url = url
84
86
  end
85
87
 
86
88
  def visible?(user)
@@ -92,8 +94,9 @@ module TrustyCms
92
94
  end
93
95
 
94
96
  private
97
+
95
98
  def visible_by_controller?(user)
96
- params = TrustyCms::Application.routes.recognize_path(url, :method => :get)
99
+ params = TrustyCms::Application.routes.recognize_path(url, method: :get)
97
100
  if params && params[:controller]
98
101
  klass = "#{params[:controller].camelize}Controller".constantize
99
102
  klass.user_has_access_to_action?(user, params[:action])
@@ -131,24 +134,24 @@ module TrustyCms
131
134
  end
132
135
 
133
136
  def initialize_nav
134
- @nav = NavTab.new("Tab Container")
137
+ @nav = NavTab.new('Tab Container')
135
138
  load_default_nav
136
139
  end
137
140
 
138
141
  def load_default_nav
139
- content = nav_tab("Content")
140
- content << nav_item("Pages", "/admin/pages")
142
+ content = nav_tab('Content')
143
+ content << nav_item('Pages', '/admin/pages')
141
144
  nav << content
142
145
 
143
- design = nav_tab("Design")
144
- design << nav_item("Layouts", "/admin/layouts")
146
+ design = nav_tab('Design')
147
+ design << nav_item('Layouts', '/admin/layouts')
145
148
  nav << design
146
149
 
147
- settings = nav_tab("Settings")
148
- settings << nav_item("General", "/admin/configuration")
149
- settings << nav_item("Personal", "/admin/preferences")
150
- settings << nav_item("Users", "/admin/users")
151
- settings << nav_item("Extensions", "/admin/extensions")
150
+ settings = nav_tab('Settings')
151
+ settings << nav_item('General', '/admin/configuration')
152
+ settings << nav_item('Personal', '/admin/preferences')
153
+ settings << nav_item('Users', '/admin/users')
154
+ settings << nav_item('Extensions', '/admin/extensions')
152
155
  nav << settings
153
156
  end
154
157
 
@@ -1,6 +1,6 @@
1
1
  class TrustyCms::AdminUI::RegionPartials
2
2
  def initialize(template)
3
- @partials = Hash.new {|h,k| h[k] = "<strong>`#{k}' default partial not found!</strong>" }
3
+ @partials = Hash.new { |h, k| h[k] = "<strong>`#{k}' default partial not found!</strong>" }
4
4
  @template = template
5
5
  end
6
6
 
@@ -8,13 +8,14 @@ class TrustyCms::AdminUI::RegionPartials
8
8
  @partials[key.to_s]
9
9
  end
10
10
 
11
- def method_missing(method, *args, &block)
11
+ def method_missing(method, *_args, &block)
12
12
  if block_given?
13
13
  # Ruby 1.9.2 yields self in instance_eval... see https://gist.github.com/479572
14
14
  # lambdas are as strict as methods in 1.9.x, making sure that the args match, Procs are not.
15
- if RUBY_VERSION =~ /^1\.9/ and block.lambda? and block.arity != 1
15
+ if RUBY_VERSION =~ /^1\.9/ && block.lambda? && (block.arity != 1)
16
16
  raise "You can only pass a proc ('Proc.new') or a lambda that takes exactly one arg (for self) to TrustyCms::AdminUI::RegionPartials' method_missing."
17
17
  end
18
+
18
19
  @partials[method.to_s] = @template.capture(&block)
19
20
  else
20
21
  @partials[method.to_s]
@@ -1,7 +1,6 @@
1
1
  class TrustyCms::AdminUI::RegionSet
2
-
3
2
  def initialize
4
- @regions = Hash.new do |h,k|
3
+ @regions = Hash.new do |h, k|
5
4
  h[k] = []
6
5
  end
7
6
  yield self if block_given?
@@ -11,8 +10,9 @@ class TrustyCms::AdminUI::RegionSet
11
10
  @regions[region.to_sym]
12
11
  end
13
12
 
14
- def add(region=nil, partial=nil, options={})
15
- raise ArgumentError, "You must specify a region and a partial" unless region and partial
13
+ def add(region = nil, partial = nil, options = {})
14
+ raise ArgumentError, 'You must specify a region and a partial' unless region && partial
15
+
16
16
  if options[:before]
17
17
  index = @regions[region].empty? ? 0 : (@regions[region].index(options[:before]) || @regions[region].size)
18
18
  self[region].insert(index, partial)
@@ -31,5 +31,4 @@ class TrustyCms::AdminUI::RegionSet
31
31
  super
32
32
  end
33
33
  end
34
-
35
34
  end
@@ -1,5 +1,4 @@
1
1
  module TrustyCms::AvailableLocales
2
-
3
2
  # Returns the list of available locale files in options_for_select format.
4
3
  #
5
4
  def self.locales
@@ -8,12 +7,11 @@ module TrustyCms::AvailableLocales
8
7
  if File.exists?(path) && path !~ /_available_tags/
9
8
  locale_yaml = YAML.load_file(path)
10
9
  stem = File.basename(path, '.yml')
11
- if locale_yaml[stem] && lang = locale_yaml[stem]["this_file_language"]
10
+ if locale_yaml[stem] && lang = locale_yaml[stem]['this_file_language']
12
11
  available_locales[lang] = stem
13
12
  end
14
13
  end
15
14
  end
16
- available_locales.collect {|k,v| [k, v]}.sort_by { |s| s[0] }
15
+ available_locales.collect { |k, v| [k, v] }.sort_by { |s| s[0] }
17
16
  end
18
-
19
17
  end
@@ -1,7 +1,6 @@
1
1
  module TrustyCms
2
2
  class Config
3
3
  class Definition
4
-
5
4
  attr_reader :empty, :default, :type, :notes, :validate_with, :select_from, :allow_blank, :allow_display, :allow_change, :units, :definer
6
5
 
7
6
  # Configuration 'definitions' are metadata held in memory that add restriction and description to individual config entries.
@@ -22,8 +21,8 @@ module TrustyCms
22
21
  #
23
22
  # See the method documentation in TrustyCms::Config for options and conventions.
24
23
  #
25
- def initialize(options={})
26
- [:empty, :default, :type, :notes, :validate_with, :select_from, :allow_blank, :allow_change, :allow_display, :units, :definer].each do |attribute|
24
+ def initialize(options = {})
25
+ %i[empty default type notes validate_with select_from allow_blank allow_change allow_display units definer].each do |attribute|
27
26
  instance_variable_set "@#{attribute}".to_sym, options[attribute]
28
27
  end
29
28
  end
@@ -61,7 +60,7 @@ module TrustyCms
61
60
  choices = select_from
62
61
  choices = choices.call if choices.respond_to? :call
63
62
  choices = normalize_selection(choices)
64
- choices.unshift ["",""] if allow_blank?
63
+ choices.unshift ['', ''] if allow_blank?
65
64
  choices
66
65
  end
67
66
  end
@@ -71,14 +70,14 @@ module TrustyCms
71
70
  #
72
71
  def normalize_selection(choices)
73
72
  choices = choices.to_a if Hash === choices
74
- choices = choices.collect{|c| (c.is_a? Array) ? c : [c,c]}
73
+ choices = choices.collect { |c| (c.is_a? Array) ? c : [c, c] }
75
74
  end
76
75
 
77
76
  # If the config item is a selector and :select_from specifies [name, value] pairs (as hash or array),
78
77
  # this will return the name corresponding to the currently selected value.
79
78
  #
80
79
  def selected(value)
81
- if value && selector? && pair = selection.find{|s| s.last == value}
80
+ if value && selector? && pair = selection.find { |s| s.last == value }
82
81
  pair.first
83
82
  end
84
83
  end
@@ -103,13 +102,18 @@ module TrustyCms
103
102
  setting.errors.add :value, :not_permitted unless selectable?(setting.value)
104
103
  end
105
104
  if integer?
106
- Integer(setting.value) rescue setting.errors.add :value, :not_a_number
105
+ begin
106
+ Integer(setting.value)
107
+ rescue StandardError
108
+ setting.errors.add :value, :not_a_number
109
+ end
107
110
  end
108
111
  end
109
112
 
110
113
  # Returns true if the value is one of the permitted selections. Not case-sensitive.
111
114
  def selectable?(value)
112
115
  return true unless selector?
116
+
113
117
  selection.map(&:last).map(&:downcase).include?(value.downcase)
114
118
  end
115
119
 
@@ -135,7 +139,6 @@ module TrustyCms
135
139
  def hidden?
136
140
  true if allow_display == false
137
141
  end
138
-
139
142
  end
140
143
  end
141
144
  end
@@ -1,21 +1,20 @@
1
1
  module TrustyCms
2
2
  class Engine < Rails::Engine
3
- paths["app/helpers"] = []
4
- initializer "trusty_cms.assets.precompile" do |app|
3
+ paths['app/helpers'] = []
4
+ initializer 'trusty_cms.assets.precompile' do |app|
5
5
  app.config.assets.paths << Rails.root.join('../trusty-cms/node_modules')
6
6
  app.config.assets.precompile += %w(
7
- admin/main.css admin.js
8
- ckeditor/config.js
9
- ckeditor/contents.css
10
- ckeditor/config.js
11
- ckeditor/styles.js
12
- ckeditor/skins/moono/editor.css
13
- ckeditor/lang/en.js
14
- rad_social/rad_screen.css
15
- rad_social/captcha.js
16
- rad_social/rad_email.js
17
- rad_social/rad_widget.js
18
- )
7
+ admin/main.css admin.js
8
+ ckeditor/config.js
9
+ ckeditor/contents.css
10
+ ckeditor/config.js
11
+ ckeditor/styles.js
12
+ ckeditor/skins/moono/editor.css
13
+ ckeditor/lang/en.js
14
+ rad_social/rad_screen.css
15
+ rad_social/rad_email.js
16
+ rad_social/rad_widget.js
17
+ )
19
18
  end
20
19
  end
21
20
  end
@@ -33,7 +33,7 @@ module TrustyCms
33
33
  end
34
34
 
35
35
  def migrations_path
36
- File.join(self.root, 'db', 'migrate')
36
+ File.join(root, 'db', 'migrate')
37
37
  end
38
38
 
39
39
  def migrates_from
@@ -41,11 +41,11 @@ module TrustyCms
41
41
  end
42
42
 
43
43
  def routing_file
44
- File.join(self.root, 'config', 'routes.rb')
44
+ File.join(root, 'config', 'routes.rb')
45
45
  end
46
46
 
47
47
  def load_initializers
48
- Dir["#{self.root}/config/initializers/**/*.rb"].sort.each do |initializer|
48
+ Dir["#{root}/config/initializers/**/*.rb"].sort.each do |initializer|
49
49
  require initializer
50
50
  end
51
51
  end
@@ -53,7 +53,7 @@ module TrustyCms
53
53
  def migrator
54
54
  unless @migrator
55
55
  extension = self
56
- @migrator = Class.new(ExtensionMigrator){ self.extension = extension }
56
+ @migrator = Class.new(ExtensionMigrator) { self.extension = extension }
57
57
  end
58
58
  @migrator
59
59
  end
@@ -62,7 +62,7 @@ module TrustyCms
62
62
  AdminUI.instance
63
63
  end
64
64
 
65
- def tab(name, options={}, &block)
65
+ def tab(name, options = {}, &block)
66
66
  @the_tab = admin.nav[name]
67
67
  unless @the_tab
68
68
  @the_tab = TrustyCms::AdminUI::NavTab.new(name)
@@ -81,7 +81,7 @@ module TrustyCms
81
81
  if block_given?
82
82
  block.call(@the_tab)
83
83
  end
84
- return @the_tab
84
+ @the_tab
85
85
  end
86
86
  alias :add_tab :tab
87
87
 
@@ -95,18 +95,16 @@ module TrustyCms
95
95
  # ThirdPartyExtension.extend(MyExtension::IntegrationPoints)
96
96
  # end
97
97
  def extension_enabled?(extension)
98
- begin
99
- extension = (extension.to_s.camelcase + 'Extension').constantize
100
- extension.enabled?
101
- rescue NameError
102
- false
103
- end
98
+ extension = (extension.to_s.camelcase + 'Extension').constantize
99
+ extension.enabled?
100
+ rescue NameError
101
+ false
104
102
  end
105
103
 
106
104
  class << self
107
-
108
105
  def activate_extension
109
106
  return if instance.active?
107
+
110
108
  instance.activate_extension if instance.respond_to? :activate
111
109
  Dir["#{Rails.root}/config/routes/**/*.rb"].each do |route_file|
112
110
  end
@@ -115,6 +113,7 @@ module TrustyCms
115
113
 
116
114
  def deactivate_extension
117
115
  return unless instance.active?
116
+
118
117
  instance.active = false
119
118
  instance.deactivate if instance.respond_to? :deactivate
120
119
  end
@@ -124,14 +123,13 @@ module TrustyCms
124
123
  subclass.extension_name = subclass.name.to_name('Extension')
125
124
  end
126
125
 
127
- def migrate_from(extension_name, until_migration=nil)
126
+ def migrate_from(extension_name, until_migration = nil)
128
127
  instance.migrates_from[extension_name] = until_migration
129
128
  end
130
129
 
131
- def extension_config(&block)
130
+ def extension_config
132
131
  yield Rails.configuration
133
132
  end
134
-
135
133
  end
136
134
  end
137
135
  end