trusty-cms 4.1.2 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +25 -25
- data/Rakefile +7 -7
- data/app/assets/stylesheets/admin/partials/_content.scss +1 -2
- 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 +13 -16
- 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/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/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 +14 -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/trusty_cms.gemspec +23 -23
- metadata +32 -32
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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, :
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
def announce_cannot_delete_self
|
|
55
|
+
flash[:error] = t('users_controller.cannot_delete_self')
|
|
56
|
+
end
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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, :
|
|
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(
|
|
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
|
|
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
|
-
|
|
43
|
+
action_name
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
private
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
def set_mailer
|
|
50
|
+
ActionMailer::Base.default_url_options[:host] = request.host_with_port
|
|
51
|
+
end
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
def set_javascripts_and_stylesheets
|
|
62
|
+
@stylesheets ||= []
|
|
63
|
+
@stylesheets.concat %w(admin/main)
|
|
64
|
+
@javascripts ||= []
|
|
65
|
+
end
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
def set_standard_body_style
|
|
68
|
+
@body_classes ||= []
|
|
69
|
+
@body_classes.concat(%w(reversed))
|
|
70
|
+
end
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
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=
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
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 :
|
|
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
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
end
|
|
70
|
+
expires_in nil, :private => true, 'no-cache' => true if @changed_pages.length > 0
|
|
71
|
+
end
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
def process_page(page)
|
|
96
|
+
page.pagination_parameters = pagination_parameters
|
|
97
|
+
page.process(request, response)
|
|
98
|
+
end
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
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
|
-
:
|
|
11
|
-
:
|
|
12
|
-
:
|
|
13
|
-
:
|
|
14
|
-
:
|
|
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, :
|
|
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 :
|
|
28
|
-
:
|
|
29
|
-
:
|
|
30
|
-
:
|
|
31
|
-
:
|
|
32
|
-
:
|
|
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, :
|
|
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, :
|
|
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, :
|
|
20
|
+
html << content_tag(:span, value, id: domkey, class: options[:class])
|
|
21
21
|
end
|
|
22
|
-
html << content_tag(:span, " #{t("units.#{setting.units}")}", :
|
|
23
|
-
html << content_tag(:span, " #{t('warning')}: #{[setting.errors[:value]].flatten.first}", :
|
|
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,
|
|
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}")})", :
|
|
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, :
|
|
55
|
-
html << content_tag(:label, title.html_safe, :
|
|
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, :
|
|
58
|
-
html << select_tag(name, options_for_select(setting.definition.selection, value), :
|
|
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, :
|
|
61
|
-
html << text_field_tag(name, value, :
|
|
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, :
|
|
65
|
-
html = content_tag(:span, html.html_safe, :
|
|
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 ||= {}
|
|
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
|