trusty-cms 4.1.0 → 4.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +98 -98
  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/admin/partials/_messages.scss +7 -2
  12. data/app/assets/stylesheets/admin/partials/_popup.scss +1 -1
  13. data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
  14. data/app/controllers/admin/assets_controller.rb +21 -31
  15. data/app/controllers/admin/configuration_controller.rb +9 -11
  16. data/app/controllers/admin/extensions_controller.rb +3 -3
  17. data/app/controllers/admin/layouts_controller.rb +3 -4
  18. data/app/controllers/admin/page_attachments_controller.rb +5 -5
  19. data/app/controllers/admin/page_fields_controller.rb +3 -4
  20. data/app/controllers/admin/page_parts_controller.rb +4 -5
  21. data/app/controllers/admin/pages_controller.rb +55 -56
  22. data/app/controllers/admin/references_controller.rb +1 -1
  23. data/app/controllers/admin/resource_controller.rb +132 -130
  24. data/app/controllers/admin/sites_controller.rb +4 -4
  25. data/app/controllers/admin/snippets_controller.rb +3 -4
  26. data/app/controllers/admin/users_controller.rb +16 -16
  27. data/app/controllers/application_controller.rb +47 -48
  28. data/app/controllers/site_controller.rb +51 -48
  29. data/app/controllers/social_mailer_controller.rb +12 -22
  30. data/app/helpers/admin/configuration_helper.rb +19 -20
  31. data/app/helpers/admin/layouts_helper.rb +0 -1
  32. data/app/helpers/admin/node_helper.rb +27 -24
  33. data/app/helpers/admin/pages_helper.rb +2 -2
  34. data/app/helpers/admin/preferences_helper.rb +0 -1
  35. data/app/helpers/admin/references_helper.rb +9 -10
  36. data/app/helpers/admin/regions_helper.rb +3 -3
  37. data/app/helpers/application_helper.rb +32 -33
  38. data/app/helpers/rad_social_helper.rb +8 -11
  39. data/app/helpers/scoped_helper.rb +1 -3
  40. data/app/helpers/sites_helper.rb +4 -4
  41. data/app/mailers/devise_mailer.rb +3 -4
  42. data/app/mailers/rad_social_mailer.rb +8 -8
  43. data/app/models/asset.rb +62 -63
  44. data/app/models/asset_type.rb +38 -39
  45. data/app/models/deprecated_tags.rb +3 -4
  46. data/app/models/file_not_found_page.rb +1 -3
  47. data/app/models/haml_filter.rb +1 -1
  48. data/app/models/layout.rb +4 -5
  49. data/app/models/legacy_user.rb +2 -2
  50. data/app/models/menu_renderer.rb +16 -18
  51. data/app/models/page.rb +96 -93
  52. data/app/models/page_attachment.rb +1 -2
  53. data/app/models/page_context.rb +11 -12
  54. data/app/models/page_part.rb +3 -4
  55. data/app/models/rails_page.rb +10 -12
  56. data/app/models/site.rb +22 -21
  57. data/app/models/snippet.rb +6 -8
  58. data/app/models/snippet_finder.rb +3 -3
  59. data/app/models/snippet_tags.rb +4 -4
  60. data/app/models/standard_tags.rb +258 -252
  61. data/app/models/status.rb +8 -8
  62. data/app/models/trusty_cms/config.rb +25 -25
  63. data/app/models/trusty_cms/page_response_cache_director.rb +2 -3
  64. data/app/models/user.rb +15 -14
  65. data/app/models/user_action_observer.rb +3 -3
  66. data/app/views/admin/assets/edit.html.haml +0 -9
  67. data/app/views/admin/assets/new.html.haml +0 -3
  68. data/app/views/admin/assets/remove.html.haml +1 -1
  69. data/app/views/admin/layouts/remove.html.haml +4 -3
  70. data/app/views/admin/page_parts/_page_part.html.haml +1 -1
  71. data/app/views/admin/pages/remove.html.haml +2 -1
  72. data/app/views/admin/sites/index.haml +3 -1
  73. data/app/views/admin/snippets/remove.html.haml +5 -4
  74. data/app/views/admin/users/remove.html.haml +2 -2
  75. data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
  76. data/app/views/widget/_email_form.html.haml +0 -5
  77. data/bin/rails +4 -4
  78. data/bin/trusty_cms +3 -5
  79. data/config.ru +1 -1
  80. data/config/application.rb +14 -15
  81. data/config/boot.rb +1 -2
  82. data/config/environment.rb +1 -1
  83. data/config/environments/production.rb +0 -1
  84. data/config/environments/test.rb +1 -2
  85. data/config/initializers/devise.rb +1 -1
  86. data/config/initializers/kraken.rb +2 -2
  87. data/config/initializers/tmp.rb +1 -1
  88. data/config/initializers/trusty_cms_config.rb +48 -48
  89. data/config/locales/en.yml +8 -8
  90. data/config/routes.rb +6 -7
  91. data/lib/active_record_extensions/active_record_extensions.rb +1 -2
  92. data/lib/annotatable.rb +3 -5
  93. data/lib/configuration_extensions/configuration_extensions.rb +1 -1
  94. data/lib/inheritable_class_attributes.rb +13 -9
  95. data/lib/login_system.rb +73 -73
  96. data/lib/method_observer.rb +13 -12
  97. data/lib/ostruct.rb +7 -10
  98. data/lib/simpleton.rb +0 -4
  99. data/lib/string_extensions/string_extensions.rb +3 -3
  100. data/lib/symbol_extensions/symbol_extensions.rb +1 -1
  101. data/lib/tasks/database.rake +28 -28
  102. data/lib/tasks/extensions.rake +18 -18
  103. data/lib/tasks/framework.rake +68 -68
  104. data/lib/tasks/radiant_config.rake +4 -4
  105. data/lib/tasks/snippets_extension_tasks.rake +11 -11
  106. data/lib/tasks/translate.rake +14 -14
  107. data/lib/tasks/upgrade_to_devise.rake +1 -1
  108. data/lib/translation_support.rb +22 -22
  109. data/lib/trusty_cms.rb +2 -2
  110. data/lib/trusty_cms/admin_ui.rb +19 -16
  111. data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
  112. data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
  113. data/lib/trusty_cms/available_locales.rb +2 -4
  114. data/lib/trusty_cms/config/definition.rb +11 -8
  115. data/lib/trusty_cms/engine.rb +13 -14
  116. data/lib/trusty_cms/extension.rb +14 -16
  117. data/lib/trusty_cms/extension_loader.rb +6 -6
  118. data/lib/trusty_cms/extension_migrator.rb +42 -41
  119. data/lib/trusty_cms/extension_path.rb +20 -19
  120. data/lib/trusty_cms/initializer.rb +5 -8
  121. data/lib/trusty_cms/pagination/controller.rb +7 -10
  122. data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
  123. data/lib/trusty_cms/resource_responses.rb +3 -3
  124. data/lib/trusty_cms/setup.rb +130 -132
  125. data/lib/trusty_cms/taggable.rb +19 -22
  126. data/lib/trusty_cms/task_support.rb +9 -6
  127. data/package.json +1 -1
  128. data/public/dispatch.fcgi +1 -1
  129. data/public/dispatch.rb +2 -2
  130. data/script/extension +1 -1
  131. data/script/rails +2 -2
  132. data/spec/dummy/package.json +1 -1
  133. data/spec/dummy/yarn.lock +3 -3
  134. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
  135. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
  136. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
  137. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
  138. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
  139. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
  140. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
  141. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
  142. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
  143. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
  144. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
  145. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
  146. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
  147. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
  148. data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
  149. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
  150. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
  151. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
  152. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
  153. data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
  154. data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
  155. data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
  156. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
  157. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
  158. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
  159. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
  160. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
  161. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
  162. data/trusty_cms.gemspec +25 -25
  163. data/vendor/extensions/clipped-extension/lib/clipped_admin_ui.rb +1 -1
  164. data/yarn.lock +7 -7
  165. metadata +7609 -105
  166. data/app/assets/javascripts/rad_social/captcha.js +0 -42
  167. data/app/views/admin/assets/refresh.html.haml +0 -14
@@ -6,32 +6,34 @@ class SiteController < ApplicationController
6
6
  skip_before_action :authenticate_user!
7
7
 
8
8
  def self.cache_timeout=(val)
9
- TrustyCms::PageResponseCacheDirector.cache_timeout=(val)
9
+ TrustyCms::PageResponseCacheDirector.cache_timeout = val
10
10
  end
11
+
11
12
  def self.cache_timeout
12
13
  TrustyCms::PageResponseCacheDirector.cache_timeout
13
14
  end
14
15
 
15
16
  def show_page
16
17
  url = params[:url]
17
- if Array === url
18
- url = url.join('/')
19
- else
20
- url = url.to_s
21
- end
18
+ url = if Array === url
19
+ url.join('/')
20
+ else
21
+ url.to_s
22
+ end
22
23
  if @page = find_page(url)
23
- batch_page_status_refresh if (url == "/" || url == "")
24
+ batch_page_status_refresh if url == '/' || url == ''
24
25
  # This is a bit of a hack to get Vanity URL pages working in another extension
25
26
  # In Rails 2, redirect_to halted execution, so process_page could be aliased and
26
27
  # a redirect could be used. This no longer works. There's a better fix for this,
27
28
  # but for now, anything that aliases process_page can return false if it's rendering
28
29
  # or redirecting on its own.
29
30
  return unless process_page(@page)
31
+
30
32
  set_cache_control
31
33
  @performed_render ||= true
32
34
  render layout: false
33
35
  else
34
- render :template => 'site/not_found', :status => 404, layout: false
36
+ render template: 'site/not_found', status: 404, layout: false
35
37
  end
36
38
  rescue Page::MissingRootPageError
37
39
  redirect_to welcome_path
@@ -42,7 +44,7 @@ class SiteController < ApplicationController
42
44
  end
43
45
  # hide_action :cacheable_request?
44
46
 
45
- def set_expiry(time, options={})
47
+ def set_expiry(time, options = {})
46
48
  expires_in time, options
47
49
  end
48
50
  # hide_action :set_expiry
@@ -53,52 +55,53 @@ class SiteController < ApplicationController
53
55
  # hide_action :set_expiry
54
56
 
55
57
  private
56
- def batch_page_status_refresh
57
- @changed_pages = []
58
- @pages = Page.where({:status_id => Status[:scheduled].id})
59
- @pages.each do |page|
60
- if page.published_at <= Time.now
61
- page.status_id = Status[:published].id
62
- page.save
63
- @changed_pages << page.id
64
- end
65
- end
66
58
 
67
- expires_in nil, :private=>true, "no-cache" => true if @changed_pages.length > 0
59
+ def batch_page_status_refresh
60
+ @changed_pages = []
61
+ @pages = Page.where({ status_id: Status[:scheduled].id })
62
+ @pages.each do |page|
63
+ if page.published_at <= Time.now
64
+ page.status_id = Status[:published].id
65
+ page.save
66
+ @changed_pages << page.id
67
+ end
68
68
  end
69
69
 
70
- def set_cache_control
71
- response_cache_director(@page).set_cache_control
72
- end
70
+ expires_in nil, :private => true, 'no-cache' => true if @changed_pages.length > 0
71
+ end
73
72
 
74
- def response_cache_director(page)
75
- klass_name = "TrustyCms::#{page.class}ResponseCacheDirector"
76
- begin
77
- klass = klass_name.constantize
78
- rescue NameError, LoadError
79
- director_klass = "TrustyCms::PageResponseCacheDirector"
80
- #Rubocop: The use of eval is a serious security risk.
81
- #eval(%Q{class #{klass_name} < #{director_klass}; end}, TOPLEVEL_BINDING)
82
- klass = director_klass.constantize
83
- end
84
- klass.new(page, self)
85
- end
73
+ def set_cache_control
74
+ response_cache_director(@page).set_cache_control
75
+ end
86
76
 
87
- def find_page(url)
88
- found = Page.find_by_path(url, live?)
89
- found if found and (found.published? or dev?)
77
+ def response_cache_director(page)
78
+ klass_name = "TrustyCms::#{page.class}ResponseCacheDirector"
79
+ begin
80
+ klass = klass_name.constantize
81
+ rescue NameError, LoadError
82
+ director_klass = 'TrustyCms::PageResponseCacheDirector'
83
+ # Rubocop: The use of eval is a serious security risk.
84
+ # eval(%Q{class #{klass_name} < #{director_klass}; end}, TOPLEVEL_BINDING)
85
+ klass = director_klass.constantize
90
86
  end
87
+ klass.new(page, self)
88
+ end
91
89
 
92
- def process_page(page)
93
- page.pagination_parameters = pagination_parameters
94
- page.process(request, response)
95
- end
90
+ def find_page(url)
91
+ found = Page.find_by_path(url, live?)
92
+ found if found && (found.published? || dev?)
93
+ end
96
94
 
97
- def dev?
98
- request.host == @trusty_config['dev.host'] || request.host =~ /^dev\./
99
- end
95
+ def process_page(page)
96
+ page.pagination_parameters = pagination_parameters
97
+ page.process(request, response)
98
+ end
100
99
 
101
- def live?
102
- not dev?
103
- end
100
+ def dev?
101
+ request.host == @trusty_config['dev.host'] || request.host =~ /^dev\./
102
+ end
103
+
104
+ def live?
105
+ not dev?
106
+ end
104
107
  end
@@ -1,36 +1,26 @@
1
1
  class SocialMailerController < ApplicationController
2
2
  include ShareLayouts::Controllers::ActionController
3
- trusty_layout "default", {:only => :create_social_mail}
3
+ trusty_layout 'default', { only: :create_social_mail }
4
4
  # no_login_required
5
5
  skip_before_action :authenticate_user!
6
6
 
7
7
  def create_social_mail
8
-
9
8
  mailer_options = {
10
- :to => params[:to],
11
- :from => params[:from],
12
- :from_name => params[:from_name],
13
- :message => params[:message],
14
- :subject => params[:subject]
9
+ to: params[:to],
10
+ from: params[:from],
11
+ from_name: params[:from_name],
12
+ message: params[:message],
13
+ subject: params[:subject],
15
14
  }
16
-
17
- if verify_recaptcha(action: 'emailSeats')
18
- RadSocialMailer.social_mail(mailer_options).deliver_now
19
- head :ok
20
- else
21
- head :bad_request, :ErrorMsg => 'We have detected suspicious activity and have disabled this feature for your user.'
22
- end
23
-
24
15
  end
25
16
 
26
17
  def social_mail_form
27
- render :template => "rad_social_mailer/social_mail_form",
28
- :layout => false,
29
- :locals => {
30
- :email_message => params[:email_message],
31
- :email_subject => params[:email_subject],
32
- :email_action_url => params[:email_action_url]
18
+ render template: 'rad_social_mailer/social_mail_form',
19
+ layout: false,
20
+ locals: {
21
+ email_message: params[:email_message],
22
+ email_subject: params[:email_subject],
23
+ email_action_url: params[:email_action_url],
33
24
  }
34
25
  end
35
-
36
26
  end
@@ -6,21 +6,21 @@ module Admin::ConfigurationHelper
6
6
  # show_config("admin.title")
7
7
  # => <label for="admin_title">Admin title<label><span id="admin_title">TrustyCms CMS</span>
8
8
  #
9
- def show_config(key, options={})
9
+ def show_config(key, options = {})
10
10
  setting = setting_for(key)
11
11
  setting.valid?
12
12
  domkey = key.gsub(/\W/, '_')
13
- html = ""
14
- html << content_tag(:label, t("trusty_config.#{key}").titlecase, :for => domkey)
13
+ html = ''
14
+ html << content_tag(:label, t("trusty_config.#{key}").titlecase, for: domkey)
15
15
  if setting.boolean?
16
16
  value = setting.checked? ? t('yes') : t('no')
17
- html << content_tag(:span, value, :id => domkey, :class => "#{value} #{options[:class]}")
17
+ html << content_tag(:span, value, id: domkey, class: "#{value} #{options[:class]}")
18
18
  else
19
19
  value = setting.selected_value || setting.value
20
- html << content_tag(:span, value, :id => domkey, :class => options[:class])
20
+ html << content_tag(:span, value, id: domkey, class: options[:class])
21
21
  end
22
- html << content_tag(:span, " #{t("units.#{setting.units}")}", :class => 'units') if setting.units
23
- html << content_tag(:span, " #{t('warning')}: #{[setting.errors[:value]].flatten.first}", :class => 'warning') if setting.errors.messages[:value].present?
22
+ html << content_tag(:span, " #{t("units.#{setting.units}")}", class: 'units') if setting.units
23
+ html << content_tag(:span, " #{t('warning')}: #{[setting.errors[:value]].flatten.first}", class: 'warning') if setting.errors.messages[:value].present?
24
24
  Rails.logger.error(html)
25
25
  html.html_safe
26
26
  end
@@ -41,34 +41,34 @@ module Admin::ConfigurationHelper
41
41
  # edit_setting("user.allow_password_reset?")
42
42
  # => <label for="user_allow_password_reset_">Admin title<label><input type="checkbox" name="config['user.allow_password_reset?']" id="user_allow_password_reset_" value="1" checked="checked" />
43
43
  #
44
- def edit_config(key, options={})
44
+ def edit_config(key, _options = {})
45
45
  setting = setting_for(key)
46
46
  domkey = key.gsub(/\W/, '_')
47
47
  name = "trusty_config[#{key}]"
48
48
  title = t("trusty_config.#{key}").titlecase
49
- title << content_tag(:span, " (#{t("units.#{setting.units}")})", :class => 'units') if setting.units
49
+ title << content_tag(:span, " (#{t("units.#{setting.units}")})", class: 'units') if setting.units
50
50
  value = params[key.to_sym].nil? ? setting.value : params[key.to_sym]
51
- html = ""
51
+ html = ''
52
52
  if setting.boolean?
53
53
  html << hidden_field_tag(name, 0)
54
- html << check_box_tag(name, 1, value, :class => 'setting', :id => domkey)
55
- html << content_tag(:label, title.html_safe, :class => 'checkbox', :for => domkey)
54
+ html << check_box_tag(name, 1, value, class: 'setting', id: domkey)
55
+ html << content_tag(:label, title.html_safe, class: 'checkbox', for: domkey)
56
56
  elsif setting.selector?
57
- html << content_tag(:label, title.html_safe, :for => domkey)
58
- html << select_tag(name, options_for_select(setting.definition.selection, value), :class => 'setting', :id => domkey)
57
+ html << content_tag(:label, title.html_safe, for: domkey)
58
+ html << select_tag(name, options_for_select(setting.definition.selection, value), class: 'setting', id: domkey)
59
59
  else
60
- html << content_tag(:label, title.html_safe, :for => domkey)
61
- html << text_field_tag(name, value, :class => 'textbox', :id => domkey)
60
+ html << content_tag(:label, title.html_safe, for: domkey)
61
+ html << text_field_tag(name, value, class: 'textbox', id: domkey)
62
62
  end
63
63
  if setting.errors[:value].present?
64
- html << content_tag(:span, [setting.errors[:value]].flatten.first, :class => 'error')
65
- html = content_tag(:span, html.html_safe, :class => "error-with-field")
64
+ html << content_tag(:span, [setting.errors[:value]].flatten.first, class: 'error')
65
+ html = content_tag(:span, html.html_safe, class: 'error-with-field')
66
66
  end
67
67
  html.html_safe
68
68
  end
69
69
 
70
70
  def setting_for(key)
71
- @trusty_config ||= {} # normally initialized in Admin::ConfigurationController
71
+ @trusty_config ||= {} # normally initialized in Admin::ConfigurationController
72
72
  @trusty_config[key] ||= TrustyCms.config.find_or_initialize_by(key: key)
73
73
  end
74
74
 
@@ -77,5 +77,4 @@ module Admin::ConfigurationHelper
77
77
  setting.definition
78
78
  end
79
79
  end
80
-
81
80
  end
@@ -1,3 +1,2 @@
1
1
  module Admin::LayoutsHelper
2
-
3
2
  end
@@ -1,18 +1,16 @@
1
1
  module Admin::NodeHelper
2
-
3
2
  def render_nodes(page, starting_index, parent_index = nil, simple = false)
4
- @rendered_html = ""
3
+ @rendered_html = ''
5
4
  render_node page, starting_index, parent_index, simple
6
5
  @rendered_html
7
6
  end
8
7
 
9
8
  def render_node(page, index, parent_index = nil, simple = false)
10
-
11
9
  @current_node = prepare_page(page)
12
10
 
13
- @rendered_html += (render :partial => 'admin/pages/node',
14
- :locals => {level: index, index: index, parent_index: parent_index,
15
- page: page, simple: simple, branch: (page.children.count > 0) })
11
+ @rendered_html += (render partial: 'admin/pages/node',
12
+ locals: { level: index, index: index, parent_index: parent_index,
13
+ page: page, simple: simple, branch: (page.children.count > 0) })
16
14
  index
17
15
  end
18
16
 
@@ -35,14 +33,19 @@ module Admin::NodeHelper
35
33
 
36
34
  def expanded_rows
37
35
  unless @expanded_rows
38
- @expanded_rows = case
39
- when rows = cookies[:expanded_rows]
40
- rows.split(',').map { |x| Integer(x) rescue nil }.compact
41
- else
42
- []
36
+ @expanded_rows = if rows = cookies[:expanded_rows]
37
+ rows.split(',').map do |x|
38
+ begin
39
+ Integer(x)
40
+ rescue StandardError
41
+ nil
42
+ end
43
+ end .compact
44
+ else
45
+ []
43
46
  end
44
47
 
45
- if homepage and !@expanded_rows.include?(homepage.id)
48
+ if homepage && !@expanded_rows.include?(homepage.id)
46
49
  @expanded_rows << homepage.id
47
50
  end
48
51
  end
@@ -54,37 +57,37 @@ module Admin::NodeHelper
54
57
  end
55
58
 
56
59
  def expander(level)
57
- unless @current_node.children.empty? or level == 0
58
- image((expanded ? "collapse" : "expand"),
59
- :class => "expander", :alt => 'toggle children',
60
- :title => '')
60
+ if @current_node.children.empty? || (level == 0)
61
+ ''
61
62
  else
62
- ""
63
+ image((expanded ? 'collapse' : 'expand'),
64
+ class: 'expander', alt: 'toggle children',
65
+ title: '')
63
66
  end
64
67
  end
65
68
 
66
69
  def icon
67
70
  icon_name = @current_node.virtual? ? 'virtual_page' : 'page'
68
- image(icon_name, :class => "icon", :alt => '', :title => '')
71
+ image(icon_name, class: 'icon', alt: '', title: '')
69
72
  end
70
73
 
71
74
  def node_title
72
- %{<span class="title">#{ h(@current_node.title) }</span>}.html_safe
75
+ %{<span class="title">#{h(@current_node.title)}</span>}.html_safe
73
76
  end
74
77
 
75
78
  def page_type
76
79
  display_name = @current_node.class.display_name
77
80
  if display_name == 'Page'
78
- ""
81
+ ''
79
82
  else
80
- %{<span class="info">(#{ h(display_name) })</span>}.html_safe
83
+ %{<span class="info">(#{h(display_name)})</span>}.html_safe
81
84
  end
82
85
  end
83
86
 
84
87
  def spinner
85
88
  image('spinner.gif',
86
- :class => 'busy', :id => "busy_#{@current_node.id}",
87
- :alt => "", :title => "",
88
- :style => 'display: none;')
89
+ class: 'busy', id: "busy_#{@current_node.id}",
90
+ alt: '', title: '',
91
+ style: 'display: none;')
89
92
  end
90
93
  end
@@ -16,10 +16,10 @@ module Admin::PagesHelper
16
16
 
17
17
  def status_to_display
18
18
  @page.status_id = 100 if @page.status_id == 90
19
- @display_status = Status.selectable.map{ |s| [I18n.translate(s.name.downcase), s.id] }
19
+ @display_status = Status.selectable.map { |s| [I18n.translate(s.name.downcase), s.id] }
20
20
  end
21
21
 
22
22
  def clean_page_description(page)
23
- page.description.to_s.strip.gsub(/\t/,'').gsub(/\s+/,' ')
23
+ page.description.to_s.strip.gsub(/\t/, '').gsub(/\s+/, ' ')
24
24
  end
25
25
  end
@@ -1,3 +1,2 @@
1
1
  module Admin::PreferencesHelper
2
-
3
2
  end
@@ -1,27 +1,26 @@
1
- require "RedCloth"
1
+ require 'RedCloth'
2
2
 
3
3
  module Admin::ReferencesHelper
4
4
  def tag_reference
5
5
  String.new.tap do |output|
6
6
  class_of_page.tag_descriptions.sort.each do |tag_name, description|
7
- value = t("desc.#{tag_name.gsub(':','-')}").match('desc') ? description : t("desc.#{tag_name.gsub(':','-')}")
8
- output << render(:partial => "admin/references/tag_reference.haml",
9
- :locals => {:tag_name => tag_name,
10
- :description => RedCloth.new(TrustyCms::Taggable::Util.strip_leading_whitespace(value)).to_html
11
- })
7
+ value = t("desc.#{tag_name.gsub(':', '-')}").match('desc') ? description : t("desc.#{tag_name.gsub(':', '-')}")
8
+ output << render(partial: 'admin/references/tag_reference.haml',
9
+ locals: { tag_name: tag_name,
10
+ description: RedCloth.new(TrustyCms::Taggable::Util.strip_leading_whitespace(value)).to_html })
12
11
  end
13
12
  end
14
13
  end
15
14
 
16
15
  def filter_reference
17
- unless filter.blank?
16
+ if filter.blank?
17
+ 'There is no filter on the current page part.'
18
+ else
18
19
  if filter.description.blank?
19
- "There is no documentation on this filter."
20
+ 'There is no documentation on this filter.'
20
21
  else
21
22
  filter.description
22
23
  end
23
- else
24
- "There is no filter on the current page part."
25
24
  end
26
25
  end
27
26
 
@@ -1,14 +1,14 @@
1
1
  module Admin::RegionsHelper
2
- def render_region(region, options={}, &block)
2
+ def render_region(region, options = {}, &block)
3
3
  lazy_initialize_region_set
4
4
  default_partials = TrustyCms::AdminUI::RegionPartials.new(self)
5
5
  if block_given?
6
6
  block.call(default_partials)
7
- (options[:locals] ||= {}).merge!(:defaults => default_partials)
7
+ (options[:locals] ||= {}).merge!(defaults: default_partials)
8
8
  end
9
9
  output = @region_set[region].compact.map do |partial|
10
10
  begin
11
- render options.merge(:partial => partial)
11
+ render options.merge(partial: partial)
12
12
  rescue ::ActionView::MissingTemplate # couldn't find template
13
13
  default_partials[partial]
14
14
  rescue ::ActionView::TemplateError => e # error in template