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
@@ -1,10 +1,10 @@
1
1
  class Admin::SitesController < Admin::ResourceController
2
2
  helper :sites
3
3
  only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
4
- :when => :admin,
5
- :denied_url => { :controller => 'pages', :action => 'index' },
6
- :denied_message => 'You must have administrative privileges to perform this action.'
7
-
4
+ when: :admin,
5
+ denied_url: { controller: 'pages', action: 'index' },
6
+ denied_message: 'You must have administrative privileges to perform this action.'
7
+
8
8
  %w(move_higher move_lower move_to_top move_to_bottom).each do |action|
9
9
  define_method action do
10
10
  model.send(action)
@@ -1,8 +1,7 @@
1
1
  class Admin::SnippetsController < Admin::ResourceController
2
2
  paginate_models
3
3
  only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
4
- :when => [:designer, :admin],
5
- :denied_url => { :controller => 'admin/pages', :action => 'index' },
6
- :denied_message => 'You must have designer privileges to perform this action.'
7
-
4
+ when: %i[designer admin],
5
+ denied_url: { controller: 'admin/pages', action: 'index' },
6
+ denied_message: 'You must have designer privileges to perform this action.'
8
7
  end
@@ -1,11 +1,11 @@
1
1
  class Admin::UsersController < Admin::ResourceController
2
2
  paginate_models
3
3
  only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
4
- :when => :admin,
5
- :denied_url => { :controller => 'pages', :action => 'index' },
6
- :denied_message => 'You must have administrative privileges to perform this action.'
4
+ when: :admin,
5
+ denied_url: { controller: 'pages', action: 'index' },
6
+ denied_message: 'You must have administrative privileges to perform this action.'
7
7
 
8
- before_action :ensure_deletable, :only => [:remove, :destroy]
8
+ before_action :ensure_deletable, only: %i[remove destroy]
9
9
 
10
10
  def show
11
11
  redirect_to edit_admin_user_path(params[:id])
@@ -20,7 +20,7 @@ class Admin::UsersController < Admin::ResourceController
20
20
  flash[:error] = 'There was an error saving the user. Please try again.'
21
21
  render :new
22
22
  end
23
- end
23
+ end
24
24
 
25
25
  def update
26
26
  user_params = params[model_symbol].permit!
@@ -34,7 +34,7 @@ class Admin::UsersController < Admin::ResourceController
34
34
  else
35
35
  flash[:error] = 'There was an error saving the user. Please try again.'
36
36
  render :edit
37
- end
37
+ end
38
38
  end
39
39
 
40
40
  def ensure_deletable
@@ -46,16 +46,16 @@ class Admin::UsersController < Admin::ResourceController
46
46
 
47
47
  private
48
48
 
49
- def user_params
50
- params.require(:user).permit(:first_name, :last_name, :admin, :designer,
51
- :password, :password_confirmation, :email, :site_id, :notes)
52
- end
49
+ def user_params
50
+ params.require(:user).permit(:first_name, :last_name, :admin, :designer,
51
+ :password, :password_confirmation, :email, :site_id, :notes)
52
+ end
53
53
 
54
- def announce_cannot_delete_self
55
- flash[:error] = t('users_controller.cannot_delete_self')
56
- end
54
+ def announce_cannot_delete_self
55
+ flash[:error] = t('users_controller.cannot_delete_self')
56
+ end
57
57
 
58
- def announce_cannot_remove_self_from_admin_role
59
- flash[:error] = 'You cannot remove yourself from the admin role.'
60
- end
58
+ def announce_cannot_remove_self_from_admin_role
59
+ flash[:error] = 'You cannot remove yourself from the admin role.'
60
+ end
61
61
  end
@@ -1,17 +1,17 @@
1
- #require_dependency 'trusty_cms'
1
+ # require_dependency 'trusty_cms'
2
2
  require 'login_system'
3
3
 
4
4
  class ApplicationController < ActionController::Base
5
5
  include LoginSystem
6
6
  prepend_view_path("#{TRUSTY_CMS_ROOT}/app/views")
7
-
7
+
8
8
  protect_from_forgery with: :exception
9
9
  before_action :authenticate_user!
10
10
  before_action :set_timezone
11
11
  before_action :set_user_locale
12
12
  before_action :set_javascripts_and_stylesheets
13
13
  before_action :force_utf8_params if RUBY_VERSION =~ /1\.9/
14
- before_action :set_standard_body_style, :only => [:new, :edit, :update, :create]
14
+ before_action :set_standard_body_style, only: %i[new edit update create]
15
15
  before_action :set_mailer
16
16
 
17
17
  attr_accessor :trusty_config, :cache
@@ -23,15 +23,15 @@ class ApplicationController < ActionController::Base
23
23
  @trusty_config = TrustyCms::Config
24
24
  end
25
25
 
26
- def after_sign_in_path_for(resource)
26
+ def after_sign_in_path_for(_resource)
27
27
  admin_pages_path
28
28
  end
29
29
 
30
30
  def template_name
31
- case self.action_name
31
+ case action_name
32
32
  when 'index'
33
33
  'index'
34
- when 'new','create'
34
+ when 'new', 'create'
35
35
  'new'
36
36
  when 'show'
37
37
  'show'
@@ -40,58 +40,57 @@ class ApplicationController < ActionController::Base
40
40
  when 'remove', 'destroy'
41
41
  'remove'
42
42
  else
43
- self.action_name
43
+ action_name
44
44
  end
45
45
  end
46
46
 
47
47
  private
48
48
 
49
- def set_mailer
50
- ActionMailer::Base.default_url_options[:host] = request.host_with_port
51
- end
49
+ def set_mailer
50
+ ActionMailer::Base.default_url_options[:host] = request.host_with_port
51
+ end
52
52
 
53
- def set_user_locale
54
- I18n.locale = current_user && !current_user.locale.blank? ? current_user.locale : TrustyCms::Config['default_locale']
55
- end
53
+ def set_user_locale
54
+ I18n.locale = current_user && !current_user.locale.blank? ? current_user.locale : TrustyCms::Config['default_locale']
55
+ end
56
56
 
57
- def set_timezone
58
- Time.zone = TrustyCms::Config['local.timezone'] != nil && TrustyCms::Config['local.timezone'].empty? ? Time.zone_default : TrustyCms::Config['local.timezone']
59
- end
57
+ def set_timezone
58
+ Time.zone = !TrustyCms::Config['local.timezone'].nil? && TrustyCms::Config['local.timezone'].empty? ? Time.zone_default : TrustyCms::Config['local.timezone']
59
+ end
60
60
 
61
- def set_javascripts_and_stylesheets
62
- @stylesheets ||= []
63
- @stylesheets.concat %w(admin/main)
64
- @javascripts ||= []
65
- end
61
+ def set_javascripts_and_stylesheets
62
+ @stylesheets ||= []
63
+ @stylesheets.concat %w(admin/main)
64
+ @javascripts ||= []
65
+ end
66
66
 
67
- def set_standard_body_style
68
- @body_classes ||= []
69
- @body_classes.concat(%w(reversed))
70
- end
67
+ def set_standard_body_style
68
+ @body_classes ||= []
69
+ @body_classes.concat(%w(reversed))
70
+ end
71
71
 
72
- # When using TrustyCms with Ruby 1.9, the strings that come in from forms are ASCII-8BIT encoded.
73
- # That causes problems, especially when using special chars and with certain DBs, like DB2
74
- # That's why we force the encoding of the params to UTF-8
75
- # That's what's happening in Rails 3, too: https://github.com/rails/rails/commit/25215d7285db10e2c04d903f251b791342e4dd6a
76
- #
77
- # See http://stackoverflow.com/questions/8268778/rails-2-3-9-encoding-of-query-parameters
78
- # See https://rails.lighthouseapp.com/projects/8994/tickets/4807
79
- # See http://jasoncodes.com/posts/ruby19-rails2-encodings (thanks for the following code, Jason!)
80
- def force_utf8_params
81
- traverse = lambda do |object, block|
82
- if object.kind_of?(Hash)
83
- object.each_value { |o| traverse.call(o, block) }
84
- elsif object.kind_of?(Array)
85
- object.each { |o| traverse.call(o, block) }
86
- else
87
- block.call(object)
88
- end
89
- object
90
- end
91
- force_encoding = lambda do |o|
92
- o.force_encoding(Encoding::UTF_8) if o.respond_to?(:force_encoding)
72
+ # When using TrustyCms with Ruby 1.9, the strings that come in from forms are ASCII-8BIT encoded.
73
+ # That causes problems, especially when using special chars and with certain DBs, like DB2
74
+ # That's why we force the encoding of the params to UTF-8
75
+ # That's what's happening in Rails 3, too: https://github.com/rails/rails/commit/25215d7285db10e2c04d903f251b791342e4dd6a
76
+ #
77
+ # See http://stackoverflow.com/questions/8268778/rails-2-3-9-encoding-of-query-parameters
78
+ # See https://rails.lighthouseapp.com/projects/8994/tickets/4807
79
+ # See http://jasoncodes.com/posts/ruby19-rails2-encodings (thanks for the following code, Jason!)
80
+ def force_utf8_params
81
+ traverse = lambda do |object, block|
82
+ if object.is_a?(Hash)
83
+ object.each_value { |o| traverse.call(o, block) }
84
+ elsif object.is_a?(Array)
85
+ object.each { |o| traverse.call(o, block) }
86
+ else
87
+ block.call(object)
93
88
  end
94
- traverse.call(params, force_encoding)
89
+ object
95
90
  end
96
-
91
+ force_encoding = lambda do |o|
92
+ o.force_encoding(Encoding::UTF_8) if o.respond_to?(:force_encoding)
93
+ end
94
+ traverse.call(params, force_encoding)
95
+ end
97
96
  end
@@ -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,33 @@
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
15
 
17
16
  if verify_recaptcha(action: 'emailSeats')
18
17
  RadSocialMailer.social_mail(mailer_options).deliver_now
19
18
  head :ok
20
19
  else
21
- head :bad_request, :ErrorMsg => 'We have detected suspicious activity and have disabled this feature for your user.'
20
+ head :bad_request, ErrorMsg: 'We have detected suspicious activity and have disabled this feature for your user.'
22
21
  end
23
-
24
22
  end
25
23
 
26
24
  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]
25
+ render template: 'rad_social_mailer/social_mail_form',
26
+ layout: false,
27
+ locals: {
28
+ email_message: params[:email_message],
29
+ email_subject: params[:email_subject],
30
+ email_action_url: params[:email_action_url],
33
31
  }
34
32
  end
35
-
36
33
  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