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.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +104 -104
- data/README.md +1 -1
- data/Rakefile +7 -7
- data/app/assets/javascripts/admin/assets.js +1 -1
- data/app/assets/javascripts/rad_social/rad_ajax_form.js +3 -0
- data/app/assets/javascripts/rad_social/rad_email.js +0 -1
- data/app/assets/javascripts/rad_social/rad_email_form.js +2 -7
- data/app/assets/stylesheets/admin/partials/_content.scss +1 -2
- data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
- data/app/controllers/admin/assets_controller.rb +22 -21
- data/app/controllers/admin/configuration_controller.rb +9 -11
- data/app/controllers/admin/extensions_controller.rb +3 -3
- data/app/controllers/admin/layouts_controller.rb +3 -4
- data/app/controllers/admin/page_attachments_controller.rb +5 -5
- data/app/controllers/admin/page_fields_controller.rb +3 -4
- data/app/controllers/admin/page_parts_controller.rb +4 -5
- data/app/controllers/admin/pages_controller.rb +55 -56
- data/app/controllers/admin/references_controller.rb +1 -1
- data/app/controllers/admin/resource_controller.rb +132 -130
- data/app/controllers/admin/sites_controller.rb +4 -4
- data/app/controllers/admin/snippets_controller.rb +3 -4
- data/app/controllers/admin/users_controller.rb +16 -16
- data/app/controllers/application_controller.rb +47 -48
- data/app/controllers/site_controller.rb +51 -48
- data/app/controllers/social_mailer_controller.rb +12 -22
- data/app/helpers/admin/configuration_helper.rb +19 -20
- data/app/helpers/admin/layouts_helper.rb +0 -1
- data/app/helpers/admin/node_helper.rb +27 -24
- data/app/helpers/admin/pages_helper.rb +2 -2
- data/app/helpers/admin/preferences_helper.rb +0 -1
- data/app/helpers/admin/references_helper.rb +9 -10
- data/app/helpers/admin/regions_helper.rb +3 -3
- data/app/helpers/application_helper.rb +32 -33
- data/app/helpers/rad_social_helper.rb +8 -11
- data/app/helpers/scoped_helper.rb +1 -3
- data/app/helpers/sites_helper.rb +4 -4
- data/app/mailers/devise_mailer.rb +3 -4
- data/app/mailers/rad_social_mailer.rb +8 -8
- data/app/models/asset.rb +62 -63
- data/app/models/asset_type.rb +38 -39
- data/app/models/deprecated_tags.rb +3 -4
- data/app/models/file_not_found_page.rb +1 -3
- data/app/models/haml_filter.rb +1 -1
- data/app/models/layout.rb +4 -5
- data/app/models/legacy_user.rb +2 -2
- data/app/models/menu_renderer.rb +16 -18
- data/app/models/page.rb +96 -93
- data/app/models/page_attachment.rb +1 -2
- data/app/models/page_context.rb +11 -12
- data/app/models/page_part.rb +3 -4
- data/app/models/rails_page.rb +10 -12
- data/app/models/site.rb +22 -21
- data/app/models/snippet.rb +6 -8
- data/app/models/snippet_finder.rb +3 -3
- data/app/models/snippet_tags.rb +4 -4
- data/app/models/standard_tags.rb +258 -252
- data/app/models/status.rb +8 -8
- data/app/models/trusty_cms/config.rb +25 -25
- data/app/models/trusty_cms/page_response_cache_director.rb +2 -3
- data/app/models/user.rb +15 -14
- data/app/models/user_action_observer.rb +3 -3
- data/app/views/admin/assets/edit.html.haml +3 -0
- data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
- data/app/views/widget/_email_form.html.haml +0 -5
- data/bin/rails +4 -4
- data/bin/trusty_cms +3 -5
- data/config.ru +1 -1
- data/config/application.rb +14 -15
- data/config/boot.rb +1 -2
- data/config/environment.rb +1 -1
- data/config/environments/production.rb +0 -1
- data/config/environments/test.rb +1 -2
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/kraken.rb +2 -2
- data/config/initializers/tmp.rb +1 -1
- data/config/initializers/trusty_cms_config.rb +48 -48
- data/config/locales/en.yml +1 -0
- data/config/routes.rb +6 -6
- data/lib/active_record_extensions/active_record_extensions.rb +1 -2
- data/lib/annotatable.rb +3 -5
- data/lib/configuration_extensions/configuration_extensions.rb +1 -1
- data/lib/inheritable_class_attributes.rb +13 -9
- data/lib/login_system.rb +73 -73
- data/lib/method_observer.rb +13 -12
- data/lib/ostruct.rb +7 -10
- data/lib/simpleton.rb +0 -4
- data/lib/string_extensions/string_extensions.rb +3 -3
- data/lib/symbol_extensions/symbol_extensions.rb +1 -1
- data/lib/tasks/database.rake +28 -28
- data/lib/tasks/extensions.rake +18 -18
- data/lib/tasks/framework.rake +68 -68
- data/lib/tasks/radiant_config.rake +4 -4
- data/lib/tasks/snippets_extension_tasks.rake +11 -11
- data/lib/tasks/translate.rake +14 -14
- data/lib/tasks/upgrade_to_devise.rake +1 -1
- data/lib/translation_support.rb +22 -22
- data/lib/trusty_cms.rb +2 -2
- data/lib/trusty_cms/admin_ui.rb +19 -16
- data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
- data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
- data/lib/trusty_cms/available_locales.rb +2 -4
- data/lib/trusty_cms/config/definition.rb +11 -8
- data/lib/trusty_cms/engine.rb +13 -14
- data/lib/trusty_cms/extension.rb +14 -16
- data/lib/trusty_cms/extension_loader.rb +6 -6
- data/lib/trusty_cms/extension_migrator.rb +42 -41
- data/lib/trusty_cms/extension_path.rb +20 -19
- data/lib/trusty_cms/initializer.rb +5 -8
- data/lib/trusty_cms/pagination/controller.rb +7 -10
- data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
- data/lib/trusty_cms/resource_responses.rb +3 -3
- data/lib/trusty_cms/setup.rb +130 -132
- data/lib/trusty_cms/taggable.rb +19 -22
- data/lib/trusty_cms/task_support.rb +9 -6
- data/public/dispatch.fcgi +1 -1
- data/public/dispatch.rb +2 -2
- data/script/extension +1 -1
- data/script/rails +2 -2
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
- data/trusty_cms.gemspec +24 -24
- data/yarn.lock +3 -3
- metadata +7602 -103
- 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');
|
@@ -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
|
-
|
76
|
-
}
|
71
|
+
}
|
77
72
|
|
78
73
|
function displayErrorMessage(msg) {
|
79
74
|
var error_msg_div = $('.rad-email-error');
|
@@ -1,15 +1,15 @@
|
|
1
1
|
class Admin::AssetsController < Admin::ResourceController
|
2
|
-
paginate_models(:
|
3
|
-
COMPRESS_FILE_TYPE = [
|
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(
|
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 :
|
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
|
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 ==
|
37
|
-
flash[:notice] =
|
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(:
|
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(:
|
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 :
|
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, { :
|
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, :
|
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
|
-
|
12
|
-
|
13
|
-
|
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
|
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 :
|
31
|
+
redirect_to action: :show
|
33
32
|
end
|
34
33
|
rescue ActiveRecord::RecordInvalid => e
|
35
|
-
flash[:error] =
|
36
|
-
render :
|
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 :
|
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
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
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 :
|
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 :
|
13
|
+
render nothing: true, layout: false
|
14
14
|
end
|
15
|
-
self.model = PageAttachment.new(:
|
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
|
-
|
3
|
+
model.attributes = page_fields_params
|
4
4
|
@controller_name = 'page'
|
5
5
|
@template_name = 'edit'
|
6
|
-
render :
|
7
|
-
|
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
|
-
|
3
|
+
model.attributes = page_parts_params
|
4
4
|
@controller_name = 'page'
|
5
5
|
@template_name = 'edit'
|
6
|
-
render :
|
7
|
-
|
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, :
|
3
|
-
before_action :count_deleted_pages, :
|
4
|
-
rescue_from ActiveRecord::RecordInvalid, :
|
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 :
|
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 =>
|
38
|
-
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
def validation_error(e)
|
50
|
+
flash[:error] = e.message
|
51
|
+
render :new
|
52
|
+
end
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
99
|
-
|
100
|
-
|
97
|
+
def count_deleted_pages
|
98
|
+
@count = model.children.count + 1
|
99
|
+
end
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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)
|