trusty-cms 4.0.1 → 4.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +106 -106
  4. data/Rakefile +7 -7
  5. data/app/assets/images/admin/spinner.gif +0 -0
  6. data/app/assets/javascripts/admin.js +3 -0
  7. data/app/assets/javascripts/admin/more-or-less.js +2 -2
  8. data/app/assets/javascripts/admin/tabcontrol.js.erb +1 -2
  9. data/app/assets/stylesheets/admin/_base.scss +22 -6
  10. data/app/assets/stylesheets/admin/_multi_site_main.scss +28 -29
  11. data/app/assets/stylesheets/admin/_reset.scss +5 -4
  12. data/app/assets/stylesheets/admin/_site_chooser.scss +44 -69
  13. data/app/assets/stylesheets/admin/assets.scss +138 -141
  14. data/app/assets/stylesheets/admin/main.scss +10 -12
  15. data/app/assets/stylesheets/admin/modules/_boxes.scss +0 -3
  16. data/app/assets/stylesheets/admin/modules/_buttons.scss +30 -0
  17. data/app/assets/stylesheets/admin/modules/_links.scss +1 -1
  18. data/app/assets/stylesheets/admin/partials/_actions.scss +29 -46
  19. data/app/assets/stylesheets/admin/partials/_avatars.scss +3 -2
  20. data/app/assets/stylesheets/admin/partials/_content.scss +15 -38
  21. data/app/assets/stylesheets/admin/partials/_dateinput.scss +23 -14
  22. data/app/assets/stylesheets/admin/partials/_drawer.scss +78 -0
  23. data/app/assets/stylesheets/admin/partials/_dropdown.scss +9 -12
  24. data/app/assets/stylesheets/admin/partials/_footer.scss +4 -3
  25. data/app/assets/stylesheets/admin/partials/_forms.scss +64 -491
  26. data/app/assets/stylesheets/admin/partials/_header.scss +9 -118
  27. data/app/assets/stylesheets/admin/partials/_layout.scss +26 -2
  28. data/app/assets/stylesheets/admin/partials/_login_form.scss +28 -0
  29. data/app/assets/stylesheets/admin/partials/_messages.scss +10 -5
  30. data/app/assets/stylesheets/admin/partials/_popup.scss +61 -50
  31. data/app/assets/stylesheets/admin/partials/_preferences.scss +37 -0
  32. data/app/assets/stylesheets/admin/partials/_sidebar.scss +55 -0
  33. data/app/assets/stylesheets/admin/partials/_tabcontrol.scss +24 -36
  34. data/app/assets/stylesheets/admin/partials/{_index.scss → _table.scss} +53 -84
  35. data/app/assets/stylesheets/admin/partials/_toolbar.scss +11 -6
  36. data/app/assets/stylesheets/admin/partials/_treetable.scss +1 -71
  37. data/app/assets/stylesheets/admin/partials/_typography.scss +30 -55
  38. data/app/assets/stylesheets/admin/partials/_validations.scss +6 -5
  39. data/app/assets/stylesheets/rad_social/rad_screen.scss +65 -64
  40. data/app/controllers/admin/assets_controller.rb +21 -31
  41. data/app/controllers/admin/configuration_controller.rb +9 -11
  42. data/app/controllers/admin/extensions_controller.rb +3 -3
  43. data/app/controllers/admin/layouts_controller.rb +3 -4
  44. data/app/controllers/admin/page_attachments_controller.rb +5 -5
  45. data/app/controllers/admin/page_fields_controller.rb +3 -4
  46. data/app/controllers/admin/page_parts_controller.rb +4 -5
  47. data/app/controllers/admin/pages_controller.rb +55 -56
  48. data/app/controllers/admin/references_controller.rb +1 -1
  49. data/app/controllers/admin/resource_controller.rb +132 -128
  50. data/app/controllers/admin/sites_controller.rb +4 -4
  51. data/app/controllers/admin/snippets_controller.rb +3 -4
  52. data/app/controllers/admin/users_controller.rb +16 -16
  53. data/app/controllers/application_controller.rb +47 -48
  54. data/app/controllers/site_controller.rb +51 -48
  55. data/app/controllers/social_mailer_controller.rb +13 -16
  56. data/app/helpers/admin/configuration_helper.rb +19 -20
  57. data/app/helpers/admin/layouts_helper.rb +0 -1
  58. data/app/helpers/admin/node_helper.rb +27 -24
  59. data/app/helpers/admin/pages_helper.rb +2 -2
  60. data/app/helpers/admin/preferences_helper.rb +0 -1
  61. data/app/helpers/admin/references_helper.rb +9 -10
  62. data/app/helpers/admin/regions_helper.rb +3 -3
  63. data/app/helpers/application_helper.rb +34 -35
  64. data/app/helpers/rad_social_helper.rb +8 -11
  65. data/app/helpers/scoped_helper.rb +1 -3
  66. data/app/helpers/sites_helper.rb +4 -4
  67. data/app/mailers/devise_mailer.rb +3 -4
  68. data/app/mailers/rad_social_mailer.rb +8 -8
  69. data/app/models/asset.rb +62 -63
  70. data/app/models/asset_type.rb +38 -39
  71. data/app/models/deprecated_tags.rb +3 -4
  72. data/app/models/file_not_found_page.rb +1 -3
  73. data/app/models/haml_filter.rb +1 -1
  74. data/app/models/layout.rb +4 -5
  75. data/app/models/legacy_user.rb +2 -2
  76. data/app/models/menu_renderer.rb +16 -18
  77. data/app/models/page.rb +96 -93
  78. data/app/models/page_attachment.rb +1 -2
  79. data/app/models/page_context.rb +11 -12
  80. data/app/models/page_part.rb +3 -4
  81. data/app/models/rails_page.rb +10 -12
  82. data/app/models/site.rb +22 -21
  83. data/app/models/snippet.rb +6 -8
  84. data/app/models/snippet_finder.rb +3 -3
  85. data/app/models/snippet_tags.rb +4 -4
  86. data/app/models/standard_tags.rb +258 -252
  87. data/app/models/status.rb +8 -8
  88. data/app/models/trusty_cms/config.rb +25 -25
  89. data/app/models/trusty_cms/page_response_cache_director.rb +2 -3
  90. data/app/models/user.rb +15 -14
  91. data/app/models/user_action_observer.rb +3 -3
  92. data/app/users/_choose_site.html.haml +3 -7
  93. data/app/views/admin/assets/_form.html.haml +2 -1
  94. data/app/views/admin/assets/_search.html.haml +2 -1
  95. data/app/views/admin/assets/edit.html.haml +2 -10
  96. data/app/views/admin/assets/index.html.haml +4 -2
  97. data/app/views/admin/assets/new.html.haml +4 -8
  98. data/app/views/admin/assets/remove.html.haml +2 -1
  99. data/app/views/admin/configuration/edit.html.haml +7 -7
  100. data/app/views/admin/configuration/show.html.haml +6 -8
  101. data/app/views/admin/layouts/_choose_site.html.haml +2 -3
  102. data/app/views/admin/layouts/_form.html.haml +13 -12
  103. data/app/views/admin/layouts/_site_chooser.html.haml +2 -2
  104. data/app/views/admin/layouts/index.html.haml +11 -4
  105. data/app/views/admin/layouts/remove.html.haml +6 -5
  106. data/app/views/admin/page_attachments/_attachment.html.haml +2 -2
  107. data/app/views/admin/page_fields/_page_field.html.haml +3 -3
  108. data/app/views/admin/page_parts/_page_part.html.haml +5 -6
  109. data/app/views/admin/pages/_asset_popups.html.haml +15 -16
  110. data/app/views/admin/pages/_assets.html.haml +8 -7
  111. data/app/views/admin/pages/_fields.html.haml +16 -13
  112. data/app/views/admin/pages/_node.html.haml +3 -3
  113. data/app/views/admin/pages/_popups.html.haml +11 -11
  114. data/app/views/admin/pages/edit.html.haml +2 -2
  115. data/app/views/admin/pages/index.html.haml +5 -2
  116. data/app/views/admin/pages/new.html.haml +3 -3
  117. data/app/views/admin/pages/remove.html.haml +4 -3
  118. data/app/views/admin/preferences/edit.html.haml +5 -5
  119. data/app/views/admin/references/filters.haml +1 -1
  120. data/app/views/admin/references/tags.haml +3 -3
  121. data/app/views/admin/removed/_assets_bucket.html.haml +3 -3
  122. data/app/views/admin/removed/_assets_container.html.haml +18 -18
  123. data/app/views/admin/removed/_bucket.html.haml +1 -1
  124. data/app/views/admin/removed/_bucket_asset.html.haml +3 -3
  125. data/app/views/admin/removed/_show_bucket_link.html.haml +1 -1
  126. data/app/views/admin/removed/_upload_to_page.html.haml +5 -5
  127. data/app/views/admin/sites/_form.haml +18 -18
  128. data/app/views/admin/sites/edit.haml +1 -1
  129. data/app/views/admin/sites/index.haml +8 -4
  130. data/app/views/admin/sites/new.haml +1 -1
  131. data/app/views/admin/snippets/_choose_site.html.haml +4 -5
  132. data/app/views/admin/snippets/_form.html.haml +8 -9
  133. data/app/views/admin/snippets/edit.html.haml +1 -1
  134. data/app/views/admin/snippets/index.html.haml +11 -4
  135. data/app/views/admin/snippets/new.html.haml +1 -1
  136. data/app/views/admin/snippets/remove.html.haml +7 -6
  137. data/app/views/admin/users/_avatar.html.haml +2 -2
  138. data/app/views/admin/users/_choose_site.html.haml +3 -7
  139. data/app/views/admin/users/_form.html.haml +18 -21
  140. data/app/views/admin/users/_password_fields.html.haml +6 -6
  141. data/app/views/admin/users/index.html.haml +13 -6
  142. data/app/views/admin/users/remove.html.haml +4 -4
  143. data/app/views/admin/welcome/login.html.haml +8 -8
  144. data/app/views/devise/passwords/edit.html.haml +6 -6
  145. data/app/views/devise/passwords/new.html.haml +3 -3
  146. data/app/views/devise/sessions/new.html.haml +8 -8
  147. data/app/views/devise/shared/_links.html.haml +2 -2
  148. data/app/views/layouts/application.html.haml +24 -19
  149. data/app/views/rad_social_mailer/social_mail_form.html.haml +15 -15
  150. data/app/views/widget/_email_form.html.haml +14 -14
  151. data/app/views/widget/_horizontal_widget.html.haml +5 -5
  152. data/bin/rails +4 -4
  153. data/bin/trusty_cms +3 -5
  154. data/config.ru +1 -1
  155. data/config/application.rb +14 -15
  156. data/config/boot.rb +1 -2
  157. data/config/environment.rb +1 -1
  158. data/config/environments/production.rb +0 -1
  159. data/config/environments/test.rb +1 -2
  160. data/config/initializers/devise.rb +1 -1
  161. data/config/initializers/kraken.rb +2 -2
  162. data/config/initializers/tmp.rb +1 -1
  163. data/config/initializers/trusty_cms_config.rb +48 -48
  164. data/config/locales/en.yml +8 -8
  165. data/config/routes.rb +6 -7
  166. data/lib/active_record_extensions/active_record_extensions.rb +1 -2
  167. data/lib/annotatable.rb +3 -5
  168. data/lib/configuration_extensions/configuration_extensions.rb +1 -1
  169. data/lib/inheritable_class_attributes.rb +13 -9
  170. data/lib/login_system.rb +73 -73
  171. data/lib/method_observer.rb +13 -12
  172. data/lib/ostruct.rb +7 -10
  173. data/lib/simpleton.rb +0 -4
  174. data/lib/string_extensions/string_extensions.rb +3 -3
  175. data/lib/symbol_extensions/symbol_extensions.rb +1 -1
  176. data/lib/tasks/database.rake +28 -28
  177. data/lib/tasks/extensions.rake +18 -18
  178. data/lib/tasks/framework.rake +68 -68
  179. data/lib/tasks/radiant_config.rake +4 -4
  180. data/lib/tasks/snippets_extension_tasks.rake +11 -11
  181. data/lib/tasks/translate.rake +14 -14
  182. data/lib/tasks/upgrade_to_devise.rake +1 -1
  183. data/lib/translation_support.rb +22 -22
  184. data/lib/trusty_cms.rb +2 -2
  185. data/lib/trusty_cms/admin_ui.rb +19 -16
  186. data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
  187. data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
  188. data/lib/trusty_cms/available_locales.rb +2 -4
  189. data/lib/trusty_cms/config/definition.rb +11 -8
  190. data/lib/trusty_cms/engine.rb +14 -14
  191. data/lib/trusty_cms/extension.rb +14 -16
  192. data/lib/trusty_cms/extension_loader.rb +6 -6
  193. data/lib/trusty_cms/extension_migrator.rb +42 -41
  194. data/lib/trusty_cms/extension_path.rb +20 -19
  195. data/lib/trusty_cms/initializer.rb +5 -8
  196. data/lib/trusty_cms/pagination/controller.rb +7 -10
  197. data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
  198. data/lib/trusty_cms/resource_responses.rb +3 -3
  199. data/lib/trusty_cms/setup.rb +130 -132
  200. data/lib/trusty_cms/taggable.rb +19 -22
  201. data/lib/trusty_cms/task_support.rb +9 -6
  202. data/package.json +10 -2
  203. data/public/dispatch.fcgi +1 -1
  204. data/public/dispatch.rb +2 -2
  205. data/script/extension +1 -1
  206. data/script/rails +2 -2
  207. data/spec/dummy/package.json +1 -1
  208. data/spec/dummy/yarn.lock +3 -3
  209. data/trusty_cms.gemspec +25 -25
  210. data/vendor/extensions/clipped-extension/lib/clipped_admin_ui.rb +1 -1
  211. data/yarn.lock +1992 -4
  212. metadata +54 -42
  213. data/app/assets/stylesheets/admin/partials/_deprecated.scss +0 -65
  214. data/app/assets/stylesheets/admin/partials/_jquery-ui-structure.scss +0 -258
  215. data/app/assets/stylesheets/admin/partials/_jquery-ui-theme.scss +0 -410
  216. data/app/assets/stylesheets/admin/partials/_jquery-ui.scss +0 -650
  217. 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.0.1'
5
+ VERSION = '4.1.3'.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,21 @@
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/captcha.js
16
+ rad_social/rad_email.js
17
+ rad_social/rad_widget.js
18
+ )
19
19
  end
20
20
  end
21
21
  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