trusty-cms 4.1.2 → 4.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +104 -104
  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/_content.scss +1 -2
  11. data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
  12. data/app/controllers/admin/assets_controller.rb +22 -21
  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 -0
  65. data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
  66. data/app/views/widget/_email_form.html.haml +0 -5
  67. data/bin/rails +4 -4
  68. data/bin/trusty_cms +3 -5
  69. data/config.ru +1 -1
  70. data/config/application.rb +14 -15
  71. data/config/boot.rb +1 -2
  72. data/config/environment.rb +1 -1
  73. data/config/environments/production.rb +0 -1
  74. data/config/environments/test.rb +1 -2
  75. data/config/initializers/devise.rb +1 -1
  76. data/config/initializers/kraken.rb +2 -2
  77. data/config/initializers/tmp.rb +1 -1
  78. data/config/initializers/trusty_cms_config.rb +48 -48
  79. data/config/locales/en.yml +1 -0
  80. data/config/routes.rb +6 -6
  81. data/lib/active_record_extensions/active_record_extensions.rb +1 -2
  82. data/lib/annotatable.rb +3 -5
  83. data/lib/configuration_extensions/configuration_extensions.rb +1 -1
  84. data/lib/inheritable_class_attributes.rb +13 -9
  85. data/lib/login_system.rb +73 -73
  86. data/lib/method_observer.rb +13 -12
  87. data/lib/ostruct.rb +7 -10
  88. data/lib/simpleton.rb +0 -4
  89. data/lib/string_extensions/string_extensions.rb +3 -3
  90. data/lib/symbol_extensions/symbol_extensions.rb +1 -1
  91. data/lib/tasks/database.rake +28 -28
  92. data/lib/tasks/extensions.rake +18 -18
  93. data/lib/tasks/framework.rake +68 -68
  94. data/lib/tasks/radiant_config.rake +4 -4
  95. data/lib/tasks/snippets_extension_tasks.rake +11 -11
  96. data/lib/tasks/translate.rake +14 -14
  97. data/lib/tasks/upgrade_to_devise.rake +1 -1
  98. data/lib/translation_support.rb +22 -22
  99. data/lib/trusty_cms.rb +2 -2
  100. data/lib/trusty_cms/admin_ui.rb +19 -16
  101. data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
  102. data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
  103. data/lib/trusty_cms/available_locales.rb +2 -4
  104. data/lib/trusty_cms/config/definition.rb +11 -8
  105. data/lib/trusty_cms/engine.rb +13 -14
  106. data/lib/trusty_cms/extension.rb +14 -16
  107. data/lib/trusty_cms/extension_loader.rb +6 -6
  108. data/lib/trusty_cms/extension_migrator.rb +42 -41
  109. data/lib/trusty_cms/extension_path.rb +20 -19
  110. data/lib/trusty_cms/initializer.rb +5 -8
  111. data/lib/trusty_cms/pagination/controller.rb +7 -10
  112. data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
  113. data/lib/trusty_cms/resource_responses.rb +3 -3
  114. data/lib/trusty_cms/setup.rb +130 -132
  115. data/lib/trusty_cms/taggable.rb +19 -22
  116. data/lib/trusty_cms/task_support.rb +9 -6
  117. data/public/dispatch.fcgi +1 -1
  118. data/public/dispatch.rb +2 -2
  119. data/script/extension +1 -1
  120. data/script/rails +2 -2
  121. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
  122. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
  123. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
  124. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
  125. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
  126. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
  127. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
  128. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
  129. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
  130. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
  131. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
  132. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
  133. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
  134. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
  135. data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
  136. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
  137. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
  138. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
  139. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
  140. data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
  141. data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
  142. data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
  143. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
  144. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
  145. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
  146. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
  147. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
  148. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
  149. data/trusty_cms.gemspec +24 -24
  150. data/yarn.lock +3 -3
  151. metadata +7602 -103
  152. data/app/assets/javascripts/rad_social/captcha.js +0 -42
@@ -16,6 +16,9 @@ function RadAjaxForm(form) {
16
16
  type: "POST",
17
17
  url: form.find('input[name=submit_url]').attr('value'),
18
18
  data: form.serialize(),
19
+ beforeSend: function ( xhr ) {
20
+ xhr.setRequestHeader("X-CSRF-Token", $('meta[name=csrf-token]').attr('content'));
21
+ },
19
22
  success: function(data, status, xhr) {
20
23
  form.find(".loader").removeClass('ajax-loader');
21
24
  form.find(".loader-small").removeClass('ajax-loader-small');
@@ -1,6 +1,5 @@
1
1
  //= require jquery
2
2
  //= require 'rad_social/jquery.validate.min'
3
3
  //= require 'rad_social/rad_ajax_form'
4
- //= require 'rad_social/captcha'
5
4
  //= require 'rad_social/rad_email_validator'
6
5
  //= require 'rad_social/rad_email_form'
@@ -63,17 +63,12 @@ $(document).ready(function() {
63
63
  $('#rs-from_name').val('');
64
64
  $('#rs-to').val('');
65
65
  $('#rs-message').val($('#rs-base-message').val());
66
- var captcha = new Captcha("#recaptcha-container");
67
- captcha.reload();
68
66
  }
69
67
 
70
- function processFailure(xhr)
71
- {
72
- var captcha = new Captcha("#recaptcha-container");
68
+ function processFailure(xhr) {
73
69
  var error_msg = xhr.getResponseHeader("ErrorMsg");
74
70
  displayErrorMessage(error_msg);
75
- captcha.reload();
76
- }
71
+ }
77
72
 
78
73
  function displayErrorMessage(msg) {
79
74
  var error_msg_div = $('.rad-email-error');
@@ -1,13 +1,12 @@
1
1
  main {
2
2
  float: left;
3
3
  grid-area: content;
4
- padding: 1em 0 1em 1em;
5
4
  width: 100%;
6
5
  }
7
6
 
8
7
  .reversed main {
9
8
  .content {
10
- padding: 1em 0;
9
+ padding: 1em;
11
10
  }
12
11
  }
13
12
 
@@ -55,10 +55,6 @@
55
55
  float: right;
56
56
  }
57
57
 
58
- .rad-email-form .captcha-container {
59
- padding: 10px 0px;
60
- }
61
-
62
58
  .rad-email-form input.std_input {
63
59
  margin-bottom: 10px;
64
60
  }
@@ -1,15 +1,15 @@
1
1
  class Admin::AssetsController < Admin::ResourceController
2
- paginate_models(:per_page => 50)
3
- COMPRESS_FILE_TYPE = ["image/jpeg", "image/png", "image/gif", "image/svg+xml"]
2
+ paginate_models(per_page: 50)
3
+ COMPRESS_FILE_TYPE = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'].freeze
4
4
 
5
5
  def index
6
- assets = Asset.order("created_at DESC")
6
+ assets = Asset.order('created_at DESC')
7
7
  @page = Page.find(params[:page_id]) if params[:page_id]
8
8
 
9
9
  @term = params[:search] || ''
10
10
  assets = assets.matching(@term) if @term && !@term.blank?
11
11
 
12
- @types = params[:filter] ? params[:filter].split(",") : []
12
+ @types = params[:filter] ? params[:filter].split(',') : []
13
13
  if @types.include?('all')
14
14
  params[:filter] = nil
15
15
  elsif @types.any?
@@ -18,36 +18,36 @@ class Admin::AssetsController < Admin::ResourceController
18
18
 
19
19
  @assets = paginated? ? assets.paginate(pagination_parameters) : assets.all
20
20
  respond_to do |format|
21
-
22
- format.js {
21
+ format.js do
23
22
  @page = Page.find_by_id(params[:page_id])
24
- render :partial => 'asset_table', :locals => {:with_pagination => true}
25
- }
26
- format.html {
23
+ render partial: 'asset_table', locals: { with_pagination: true }
24
+ end
25
+ format.html do
27
26
  render
28
- }
27
+ end
29
28
  end
30
29
  end
31
30
 
32
31
  def create
33
- @assets, @page_attachments = [], []
32
+ @assets = []
33
+ @page_attachments = []
34
34
  compress = current_site.try(:compress) ? current_site.compress : true
35
35
  asset_params[:asset][:asset].to_a.each do |uploaded_asset|
36
- if uploaded_asset.content_type == "application/octet-stream"
37
- flash[:notice] = "Please only upload assets that have a valid extension in the name."
36
+ if uploaded_asset.content_type == 'application/octet-stream'
37
+ flash[:notice] = 'Please only upload assets that have a valid extension in the name.'
38
38
  else
39
39
  uploaded_asset = compress(uploaded_asset) if $kraken.api_key.present? && COMPRESS_FILE_TYPE.include?(uploaded_asset.content_type) && compress
40
- @asset = Asset.create(:asset => uploaded_asset, :caption => asset_params[:asset][:caption])
40
+ @asset = Asset.create(asset: uploaded_asset, caption: asset_params[:asset][:caption])
41
41
  set_owner_or_editor
42
42
  if params[:for_attachment]
43
43
  @page = Page.find_by_id(params[:page_id]) || Page.new
44
- @page_attachments << @page_attachment = @asset.page_attachments.build(:page => @page)
44
+ @page_attachments << @page_attachment = @asset.page_attachments.build(page: @page)
45
45
  end
46
46
  @assets << @asset
47
47
  end
48
48
  end
49
49
  if asset_params[:for_attachment]
50
- render :partial => 'admin/page_attachments/attachment', :collection => @page_attachments
50
+ render partial: 'admin/page_attachments/attachment', collection: @page_attachments
51
51
  else
52
52
  response_for :create
53
53
  end
@@ -64,20 +64,21 @@ class Admin::AssetsController < Admin::ResourceController
64
64
  end
65
65
  end
66
66
 
67
- private
67
+ private
68
+
68
69
  def compress(uploaded_asset)
69
70
  data = $kraken.upload(uploaded_asset.tempfile.path, 'lossy' => true)
70
- File.write(uploaded_asset.tempfile, open(data.kraked_url).read, { :mode => 'wb' })
71
+ File.write(uploaded_asset.tempfile, open(data.kraked_url).read, { mode: 'wb' })
71
72
  uploaded_asset
72
73
  end
73
74
 
74
75
  def set_owner_or_editor
75
- @asset.created_by_id = current_user.id
76
- @asset.updated_by_id = current_user.id
76
+ @asset.created_by_id = current_user.id
77
+ @asset.updated_by_id = current_user.id
77
78
  @asset.save! if @asset.id.present?
78
79
  end
79
80
 
80
81
  def asset_params
81
- params.permit(:id, :for_attachment, :asset => [:caption, :for_attachment, :asset => []])
82
+ params.permit(:id, :for_attachment, asset: [:caption, :for_attachment, asset: []])
82
83
  end
83
84
  end
@@ -1,5 +1,4 @@
1
1
  class Admin::ConfigurationController < ApplicationController
2
-
3
2
  # Admin::ConfigurationController handles the batch-updating of TrustyCms::Config entries.
4
3
  # It accepts any set of config name-value pairs but is accessible only to administrators.
5
4
  # Note that configuration is routed as a singular resource so we only deal with show/edit/update
@@ -8,9 +7,9 @@ class Admin::ConfigurationController < ApplicationController
8
7
  before_action :initialize_config
9
8
 
10
9
  only_allow_access_to :edit, :update,
11
- :when => [:admin],
12
- :denied_url => { :controller => 'admin/configuration', :action => 'show' },
13
- :denied_message => 'You must have admin privileges to edit site configuration.'
10
+ when: [:admin],
11
+ denied_url: { controller: 'admin/configuration', action: 'show' },
12
+ denied_message: 'You must have admin privileges to edit site configuration.'
14
13
 
15
14
  def show
16
15
  @user = current_user
@@ -27,24 +26,23 @@ class Admin::ConfigurationController < ApplicationController
27
26
  TrustyCms.config.transaction do
28
27
  params[:trusty_config].each_pair do |key, value|
29
28
  @trusty_config[key] = TrustyCms::Config.find_or_initialize_by(key: key)
30
- @trusty_config[key].value = value # validation sets errors on @trusty_config['key'] that the helper methods will pick up
29
+ @trusty_config[key].value = value # validation sets errors on @trusty_config['key'] that the helper methods will pick up
31
30
  end
32
- redirect_to :action => :show
31
+ redirect_to action: :show
33
32
  end
34
33
  rescue ActiveRecord::RecordInvalid => e
35
- flash[:error] = "Configuration error: please check the form"
36
- render :action => :edit
34
+ flash[:error] = 'Configuration error: please check the form'
35
+ render action: :edit
37
36
  rescue TrustyCms::Config::ConfigError => e
38
37
  flash[:error] = "Configuration error: #{e}"
39
- render :action => :edit
38
+ render action: :edit
40
39
  end
41
40
  end
42
41
  end
43
42
 
44
- protected
43
+ protected
45
44
 
46
45
  def initialize_config
47
46
  @trusty_config = {}
48
47
  end
49
-
50
48
  end
@@ -1,8 +1,8 @@
1
1
  class Admin::ExtensionsController < ApplicationController
2
2
  only_allow_access_to :index,
3
- :when => :admin,
4
- :denied_url => { :controller => 'pages', :action => 'index' },
5
- :denied_message => 'You must have administrative privileges to perform this action.'
3
+ when: :admin,
4
+ denied_url: { controller: 'pages', action: 'index' },
5
+ denied_message: 'You must have administrative privileges to perform this action.'
6
6
 
7
7
  def index
8
8
  @template_name = 'index' # for Admin::RegionsHelper
@@ -1,8 +1,7 @@
1
1
  class Admin::LayoutsController < 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
@@ -2,7 +2,7 @@ class Admin::PageAttachmentsController < Admin::ResourceController
2
2
  helper 'admin/assets'
3
3
 
4
4
  def new
5
- render :partial => 'attachment', :object => model
5
+ render partial: 'attachment', object: model
6
6
  end
7
7
 
8
8
  def load_model
@@ -10,14 +10,14 @@ class Admin::PageAttachmentsController < Admin::ResourceController
10
10
  @asset = Asset.find(params[:asset_id])
11
11
  @page = page_attachment_params[:page_id].blank? ? Page.new : Page.find_by_id(page_attachment_params[:page_id])
12
12
  rescue ActiveRecord::RecordNotFound
13
- render :nothing => true, :layout => false
13
+ render nothing: true, layout: false
14
14
  end
15
- self.model = PageAttachment.new(:asset => @asset, :page => @page)
15
+ self.model = PageAttachment.new(asset: @asset, page: @page)
16
16
  end
17
17
 
18
- private
18
+ private
19
+
19
20
  def page_attachment_params
20
21
  params.permit(:asset_id, :page_id)
21
22
  end
22
-
23
23
  end
@@ -1,10 +1,10 @@
1
1
  class Admin::PageFieldsController < Admin::ResourceController
2
2
  def create
3
- self.model.attributes = page_fields_params
3
+ model.attributes = page_fields_params
4
4
  @controller_name = 'page'
5
5
  @template_name = 'edit'
6
- render :partial => "page_field", :object => model,
7
- :locals => { :page_field_counter => params[:page_field_counter].to_i}
6
+ render partial: 'page_field', object: model,
7
+ locals: { page_field_counter: params[:page_field_counter].to_i }
8
8
  end
9
9
 
10
10
  private
@@ -12,5 +12,4 @@ class Admin::PageFieldsController < Admin::ResourceController
12
12
  def page_fields_params
13
13
  params.require(:page_field).permit(:name, :content, :page_id)
14
14
  end
15
-
16
15
  end
@@ -1,16 +1,15 @@
1
1
  class Admin::PagePartsController < Admin::ResourceController
2
2
  def create
3
- self.model.attributes = page_parts_params
3
+ model.attributes = page_parts_params
4
4
  @controller_name = 'page'
5
5
  @template_name = 'edit'
6
- render :partial => "page_part", :object => model,
7
- :locals => {:page_part_counter => params[:index].to_i}
6
+ render partial: 'page_part', object: model,
7
+ locals: { page_part_counter: params[:index].to_i }
8
8
  end
9
9
 
10
- private
10
+ private
11
11
 
12
12
  def page_parts_params
13
13
  params.require(:page_part).permit(:name, :filter_id, :content)
14
14
  end
15
-
16
15
  end
@@ -1,7 +1,7 @@
1
1
  class Admin::PagesController < Admin::ResourceController
2
- before_action :initialize_meta_rows_and_buttons, :only => [:new, :edit, :create, :update]
3
- before_action :count_deleted_pages, :only => [:destroy]
4
- rescue_from ActiveRecord::RecordInvalid, :with => :validation_error
2
+ before_action :initialize_meta_rows_and_buttons, only: %i[new edit create update]
3
+ before_action :count_deleted_pages, only: [:destroy]
4
+ rescue_from ActiveRecord::RecordInvalid, with: :validation_error
5
5
 
6
6
  class PreviewStop < ActiveRecord::Rollback
7
7
  def message
@@ -13,11 +13,11 @@ class Admin::PagesController < Admin::ResourceController
13
13
  r.plural.js do
14
14
  @level = params[:level].to_i
15
15
  @index = params[:index].to_i
16
- @rendered_html = ""
16
+ @rendered_html = ''
17
17
  @template_name = 'index'
18
18
  self.models = Page.find(params[:page_id]).children.all
19
19
  response.headers['Content-Type'] = 'text/html;charset=utf-8'
20
- render :action => 'children.html.haml', :layout => false
20
+ render action: 'children.html.haml', layout: false
21
21
  end
22
22
  end
23
23
 
@@ -34,8 +34,8 @@ class Admin::PagesController < Admin::ResourceController
34
34
 
35
35
  def preview
36
36
  render_preview
37
- rescue PreviewStop => exception
38
- render :text => exception.message unless @performed_render
37
+ rescue PreviewStop => e
38
+ render text: e.message unless @performed_render
39
39
  end
40
40
 
41
41
  def save_table_position
@@ -44,67 +44,66 @@ class Admin::PagesController < Admin::ResourceController
44
44
  head :ok
45
45
  end
46
46
 
47
-
48
47
  private
49
48
 
50
- def validation_error(e)
51
- flash[:error] = e.message
52
- render :new
53
- end
49
+ def validation_error(e)
50
+ flash[:error] = e.message
51
+ render :new
52
+ end
54
53
 
55
- def assign_page_attributes
56
- if params[:page_id].blank?
57
- self.model.slug = '/'
58
- end
59
- self.model.parent_id = params[:page_id]
54
+ def assign_page_attributes
55
+ if params[:page_id].blank?
56
+ model.slug = '/'
60
57
  end
58
+ model.parent_id = params[:page_id]
59
+ end
61
60
 
62
- def model_class
63
- if Page.descendants.any? { |d| d.to_s == params[:page_class] }
64
- verify_page_class(params[:page_class])
65
- elsif params[:page_id]
66
- Page.find(params[:page_id]).children
67
- else
68
- Page
69
- end
61
+ def model_class
62
+ if Page.descendants.any? { |d| d.to_s == params[:page_class] }
63
+ verify_page_class(params[:page_class])
64
+ elsif params[:page_id]
65
+ Page.find(params[:page_id]).children
66
+ else
67
+ Page
70
68
  end
69
+ end
71
70
 
72
- def render_preview
73
- params.permit!
74
- Page.transaction do
75
- page_class = Page.descendants.include?(model_class) ? model_class : Page
76
- if request.referer =~ %r{/admin/pages/(\d+)/edit}
77
- page = Page.find($1).becomes(page_class)
78
- layout_id = page.layout_id
79
- page.update_attributes(params[:page])
80
- page.published_at ||= Time.now
81
- else
82
- page = page_class.new(params[:page])
83
- page.published_at = page.updated_at = page.created_at = Time.now
84
- page.parent = Page.find($1) if request.referer =~ %r{/admin/pages/(\d+)/children/new}
85
- end
86
- page.pagination_parameters = pagination_parameters
87
- process_with_exception(page)
71
+ def render_preview
72
+ params.permit!
73
+ Page.transaction do
74
+ page_class = Page.descendants.include?(model_class) ? model_class : Page
75
+ if request.referer =~ %r{/admin/pages/(\d+)/edit}
76
+ page = Page.find($1).becomes(page_class)
77
+ layout_id = page.layout_id
78
+ page.update_attributes(params[:page])
79
+ page.published_at ||= Time.now
80
+ else
81
+ page = page_class.new(params[:page])
82
+ page.published_at = page.updated_at = page.created_at = Time.now
83
+ page.parent = Page.find($1) if request.referer =~ %r{/admin/pages/(\d+)/children/new}
88
84
  end
85
+ page.pagination_parameters = pagination_parameters
86
+ process_with_exception(page)
89
87
  end
88
+ end
90
89
 
91
- def process_with_exception(page)
92
- page.process(request, response)
93
- @performed_render = true
94
- render template: 'site/show_page', layout: false
95
- raise PreviewStop
96
- end
90
+ def process_with_exception(page)
91
+ page.process(request, response)
92
+ @performed_render = true
93
+ render template: 'site/show_page', layout: false
94
+ raise PreviewStop
95
+ end
97
96
 
98
- def count_deleted_pages
99
- @count = model.children.count + 1
100
- end
97
+ def count_deleted_pages
98
+ @count = model.children.count + 1
99
+ end
101
100
 
102
- def initialize_meta_rows_and_buttons
103
- @buttons_partials ||= []
104
- @meta ||= []
105
- @meta << {:field => "slug", :type => "text_field", :args => [{:class => 'textbox'}]}
106
- @meta << {:field => "breadcrumb", :type => "text_field", :args => [{:class => 'textbox'}]}
107
- end
101
+ def initialize_meta_rows_and_buttons
102
+ @buttons_partials ||= []
103
+ @meta ||= []
104
+ @meta << { field: 'slug', type: 'text_field', args: [{ class: 'textbox' }] }
105
+ @meta << { field: 'breadcrumb', type: 'text_field', args: [{ class: 'textbox' }] }
106
+ end
108
107
 
109
108
  def verify_page_class(page_class)
110
109
  if page_class.constantize.ancestors.include?(Page)