camaleon_cms 2.3.3 → 2.3.4
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/Rakefile +7 -12
- data/app/assets/javascripts/camaleon_cms/admin/_custom_fields.js +1 -2
- data/app/assets/javascripts/camaleon_cms/admin/_data.js +1 -0
- data/app/assets/javascripts/camaleon_cms/admin/_post.js +1 -1
- data/app/assets/javascripts/camaleon_cms/admin/_posttype.js.coffee +21 -0
- data/app/assets/javascripts/camaleon_cms/admin/admin-manifest.js +2 -0
- data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/fr.js +49 -0
- data/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb +11 -6
- data/app/controllers/camaleon_cms/admin/appearances/themes_controller.rb +6 -0
- data/app/controllers/camaleon_cms/admin/media_controller.rb +3 -0
- data/app/controllers/camaleon_cms/admin/users_controller.rb +3 -0
- data/app/controllers/camaleon_cms/camaleon_controller.rb +5 -0
- data/app/controllers/camaleon_cms/frontend_controller.rb +1 -1
- data/app/controllers/concerns/camaleon_cms/frontend_concern.rb +1 -1
- data/app/decorators/camaleon_cms/site_decorator.rb +1 -1
- data/app/decorators/camaleon_cms/user_decorator.rb +4 -0
- data/app/helpers/camaleon_cms/admin/custom_fields_helper.rb +4 -4
- data/app/helpers/camaleon_cms/camaleon_helper.rb +5 -0
- data/app/helpers/camaleon_cms/frontend/nav_menu_helper.rb +16 -16
- data/app/helpers/camaleon_cms/hooks_helper.rb +10 -4
- data/app/helpers/camaleon_cms/plugins_helper.rb +1 -1
- data/app/helpers/camaleon_cms/session_helper.rb +9 -4
- data/app/helpers/camaleon_cms/short_code_helper.rb +1 -1
- data/app/helpers/camaleon_cms/theme_helper.rb +1 -1
- data/app/helpers/camaleon_cms/uploader_helper.rb +10 -7
- data/app/mailers/camaleon_cms/html_mailer.rb +33 -17
- data/app/models/camaleon_cms/ability.rb +2 -2
- data/app/models/camaleon_cms/nav_menu.rb +2 -2
- data/app/models/camaleon_cms/nav_menu_item.rb +5 -3
- data/app/models/camaleon_cms/site.rb +5 -101
- data/app/models/camaleon_cms/user.rb +8 -144
- data/app/models/camaleon_cms/user_relationship.rb +1 -1
- data/app/models/camaleon_cms/user_role.rb +0 -2
- data/app/models/concerns/camaleon_cms/custom_fields_read.rb +14 -7
- data/app/models/concerns/camaleon_cms/metas.rb +5 -4
- data/app/models/concerns/camaleon_cms/site_default_settings.rb +87 -0
- data/app/models/concerns/camaleon_cms/user_methods.rb +142 -0
- data/app/uploaders/camaleon_cms_aws_uploader.rb +13 -4
- data/app/uploaders/camaleon_cms_uploader.rb +3 -1
- data/app/views/camaleon_cms/admin/appearances/nav_menus/_custom_menus.html.erb +11 -5
- data/app/views/camaleon_cms/admin/appearances/nav_menus/_external_menu.html.erb +8 -0
- data/app/views/camaleon_cms/admin/settings/_media_settings.html.erb +4 -0
- data/app/views/camaleon_cms/admin/settings/custom_fields/_get_items.html.erb +155 -154
- data/app/views/camaleon_cms/admin/settings/custom_fields/_render.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_checkbox.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_checkboxes.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_posts.html.erb +2 -5
- data/app/views/camaleon_cms/admin/settings/custom_fields/form.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/post_types/_form.html.erb +24 -16
- data/app/views/camaleon_cms/admin/users/form.html.erb +2 -2
- data/app/views/camaleon_cms/default_theme/single.html.erb +1 -1
- data/app/views/layouts/camaleon_cms/admin.html.erb +2 -2
- data/config/initializers/model_alias.rb +10 -3
- data/config/locales/camaleon_cms/admin/en.yml +10 -0
- data/config/locales/camaleon_cms/admin/fr.yml +663 -0
- data/config/locales/camaleon_cms/common.yml +66 -0
- data/config/routes/frontend.rb +1 -1
- data/config/system.json +2 -2
- data/db/migrate/20150611161134_post_table_into_utf8.rb +6 -5
- data/lib/camaleon_cms/engine.rb +3 -0
- data/lib/camaleon_cms/version.rb +1 -1
- data/lib/ext/string.rb +1 -54
- data/lib/plugin_routes.rb +5 -0
- data/spec/decorators/post_type_spec.rb +13 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +26 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +186 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/features/categories_spec.rb +25 -0
- data/spec/features/comments_spec.rb +45 -0
- data/spec/features/contact_form_spec.rb +53 -0
- data/spec/features/content_groups_spec.rb +45 -0
- data/spec/features/custom_fields_spec.rb +47 -0
- data/spec/features/frontend/pages_spec.rb +5 -0
- data/spec/features/languages_spec.rb +27 -0
- data/spec/features/media_spec.rb +50 -0
- data/spec/features/menus_spec.rb +46 -0
- data/spec/features/pages_spec.rb +30 -0
- data/spec/features/plugins_spec.rb +29 -0
- data/spec/features/posts_spec.rb +36 -0
- data/spec/features/session_spec.rb +52 -0
- data/spec/features/settings_spec.rb +17 -0
- data/spec/features/shortcodes_spec.rb +11 -0
- data/spec/features/sites_spec.rb +45 -0
- data/spec/features/tags_spec.rb +25 -0
- data/spec/features/themes_spec.rb +18 -0
- data/spec/features/user_roles_spec.rb +60 -0
- data/spec/features/users_spec.rb +79 -0
- data/spec/features/widgets_spec.rb +50 -0
- data/spec/helpers/email_helper_spec.rb +16 -0
- data/spec/mailers/send_mail_spec.rb +37 -0
- data/spec/rails_helper.rb +1 -0
- data/spec/routing/post_type_routes_spec.rb +12 -0
- data/spec/spec_helper.rb +191 -0
- data/spec/support/common.rb +113 -0
- data/spec/support/wait_for_ajax.rb +36 -0
- metadata +326 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a1a20fa498412de4a487828a91854cfe77b7a84d
|
|
4
|
+
data.tar.gz: b593e384f3f368dc448d7f277d39434263dcec6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34d8cf7a34b944d2330e5c65d622346c506ea1701f378781b3171c5a306b74c3771802b3cc3c19a468a5636db46b8ebf3f3aad2cb0bc6c01148b393b6e306d9a
|
|
7
|
+
data.tar.gz: fa8b8e7054f8b9999e658d03b9f47e19bfcc7da777c2bc12aea4d8b1b8ee6d30ca781e596ef4827f068128868f75ee7d1c052e329d71bd2bd908a548ab558b84
|
data/Rakefile
CHANGED
|
@@ -14,24 +14,19 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
|
18
18
|
load 'rails/tasks/engine.rake'
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
load 'rails/tasks/statistics.rake'
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
22
|
Bundler::GemHelper.install_tasks
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
t.libs << 'test'
|
|
32
|
-
t.pattern = 'test/**/*_test.rb'
|
|
33
|
-
t.verbose = false
|
|
34
|
-
end
|
|
26
|
+
require 'rspec/core'
|
|
27
|
+
require 'rspec/core/rake_task'
|
|
35
28
|
|
|
29
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
|
30
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
|
36
31
|
|
|
37
|
-
task default
|
|
32
|
+
task :default => :spec
|
|
@@ -61,7 +61,7 @@ function cama_build_custom_field(panel, field_data, values){
|
|
|
61
61
|
field.prepend(field_actions);
|
|
62
62
|
if(field_counter == 0) field.children('.actions').find('.fa-times').remove();
|
|
63
63
|
}
|
|
64
|
-
field.find('input, textarea, select').each(function(){ $(this).attr('name', $(this).attr('name').replace('[]', '['+field_counter+']')) });
|
|
64
|
+
if(!$field.find('.group-input-fields-content').hasClass('cama_skip_cf_rename_multiple')) field.find('input, textarea, select').each(function(){ $(this).attr('name', $(this).attr('name').replace('[]', '['+field_counter+']')) });
|
|
65
65
|
if(field_data.disabled){
|
|
66
66
|
field.find('input, textarea, select').prop('readonly', true).filter('select').click(function(){ return false; }).focus(function(){ $(this).blur(); });
|
|
67
67
|
field.find('.btn').addClass('disabled').unbind().click(function(){ return false; });
|
|
@@ -119,7 +119,6 @@ function custom_field_checkboxs_val($field, values) {
|
|
|
119
119
|
var selector = values.map(function (value) {
|
|
120
120
|
return "input[value='" + value + "']"
|
|
121
121
|
}).join(',');
|
|
122
|
-
$field.find('input').prop('checked', false);
|
|
123
122
|
$field.find(selector).prop('checked', true);
|
|
124
123
|
}
|
|
125
124
|
}
|
|
@@ -242,7 +242,7 @@ function init_post(obj) {
|
|
|
242
242
|
if ($(this).valid()) $form.data("submitted", 1);
|
|
243
243
|
});
|
|
244
244
|
window.onbeforeunload = function () {
|
|
245
|
-
if ($form.data("submitted"))
|
|
245
|
+
if ($form.data("submitted") || $('#form-post').length == 0)
|
|
246
246
|
return;
|
|
247
247
|
if ($form.data("hash") != get_hash_form()) {
|
|
248
248
|
return "You sure to leave the page without saving changes?";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
window['cama_init_posttype_form'] = ->
|
|
2
|
+
form = $("#post_type_form");
|
|
3
|
+
form.find('.unput_upload').input_upload();
|
|
4
|
+
|
|
5
|
+
# permit hierarchy route only for post types enabled "Manage page hierarchy"
|
|
6
|
+
form.find("[name='meta[has_parent_structure]']").change(->
|
|
7
|
+
item = form.find("#meta_contents_route_format_hierarchy_post");
|
|
8
|
+
item.parent().siblings().find("input").prop("disabled", $(this).is(":checked"))
|
|
9
|
+
if($(this).is(":checked"))
|
|
10
|
+
item.prop("checked", true).prop("disabled", false)
|
|
11
|
+
else
|
|
12
|
+
item.prop("disabled", true)
|
|
13
|
+
).trigger("change")
|
|
14
|
+
|
|
15
|
+
form.find('[name="meta[has_picture]"]').change(->
|
|
16
|
+
items = form.find('.picture_settings input')
|
|
17
|
+
if($(this).is(":checked"))
|
|
18
|
+
items.prop("disabled", false)
|
|
19
|
+
else
|
|
20
|
+
items.prop("disabled", true)
|
|
21
|
+
).trigger("change")
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Translated default messages for the jQuery validation plugin.
|
|
3
|
+
* Locale: FR (French; français)
|
|
4
|
+
*/
|
|
5
|
+
$.extend( $.validator.messages, {
|
|
6
|
+
required: "Ce champ est obligatoire.",
|
|
7
|
+
remote: "Veuillez corriger ce champ.",
|
|
8
|
+
email: "Veuillez fournir une adresse électronique valide.",
|
|
9
|
+
url: "Veuillez fournir une adresse URL valide.",
|
|
10
|
+
date: "Veuillez fournir une date valide.",
|
|
11
|
+
dateISO: "Veuillez fournir une date valide (ISO).",
|
|
12
|
+
number: "Veuillez fournir un numéro valide.",
|
|
13
|
+
digits: "Veuillez fournir seulement des chiffres.",
|
|
14
|
+
creditcard: "Veuillez fournir un numéro de carte de crédit valide.",
|
|
15
|
+
equalTo: "Veuillez fournir encore la même valeur.",
|
|
16
|
+
extension: "Veuillez fournir une valeur avec une extension valide.",
|
|
17
|
+
maxlength: $.validator.format( "Veuillez fournir au plus {0} caractères." ),
|
|
18
|
+
minlength: $.validator.format( "Veuillez fournir au moins {0} caractères." ),
|
|
19
|
+
rangelength: $.validator.format( "Veuillez fournir une valeur qui contient entre {0} et {1} caractères." ),
|
|
20
|
+
range: $.validator.format( "Veuillez fournir une valeur entre {0} et {1}." ),
|
|
21
|
+
max: $.validator.format( "Veuillez fournir une valeur inférieure ou égale à {0}." ),
|
|
22
|
+
min: $.validator.format( "Veuillez fournir une valeur supérieure ou égale à {0}." ),
|
|
23
|
+
maxWords: $.validator.format( "Veuillez fournir au plus {0} mots." ),
|
|
24
|
+
minWords: $.validator.format( "Veuillez fournir au moins {0} mots." ),
|
|
25
|
+
rangeWords: $.validator.format( "Veuillez fournir entre {0} et {1} mots." ),
|
|
26
|
+
letterswithbasicpunc: "Veuillez fournir seulement des lettres et des signes de ponctuation.",
|
|
27
|
+
alphanumeric: "Veuillez fournir seulement des lettres, nombres, espaces et soulignages.",
|
|
28
|
+
lettersonly: "Veuillez fournir seulement des lettres.",
|
|
29
|
+
nowhitespace: "Veuillez ne pas inscrire d'espaces blancs.",
|
|
30
|
+
ziprange: "Veuillez fournir un code postal entre 902xx-xxxx et 905-xx-xxxx.",
|
|
31
|
+
integer: "Veuillez fournir un nombre non décimal qui est positif ou négatif.",
|
|
32
|
+
vinUS: "Veuillez fournir un numéro d'identification du véhicule (VIN).",
|
|
33
|
+
dateITA: "Veuillez fournir une date valide.",
|
|
34
|
+
time: "Veuillez fournir une heure valide entre 00:00 et 23:59.",
|
|
35
|
+
phoneUS: "Veuillez fournir un numéro de téléphone valide.",
|
|
36
|
+
phoneUK: "Veuillez fournir un numéro de téléphone valide.",
|
|
37
|
+
mobileUK: "Veuillez fournir un numéro de téléphone mobile valide.",
|
|
38
|
+
strippedminlength: $.validator.format( "Veuillez fournir au moins {0} caractères." ),
|
|
39
|
+
email2: "Veuillez fournir une adresse électronique valide.",
|
|
40
|
+
url2: "Veuillez fournir une adresse URL valide.",
|
|
41
|
+
creditcardtypes: "Veuillez fournir un numéro de carte de crédit valide.",
|
|
42
|
+
ipv4: "Veuillez fournir une adresse IP v4 valide.",
|
|
43
|
+
ipv6: "Veuillez fournir une adresse IP v6 valide.",
|
|
44
|
+
require_from_group: "Veuillez fournir au moins {0} de ces champs.",
|
|
45
|
+
nifES: "Veuillez fournir un numéro NIF valide.",
|
|
46
|
+
nieES: "Veuillez fournir un numéro NIE valide.",
|
|
47
|
+
cifES: "Veuillez fournir un numéro CIF valide.",
|
|
48
|
+
postalCodeCA: "Veuillez fournir un code postal valide."
|
|
49
|
+
} );
|
|
@@ -53,7 +53,7 @@ class CamaleonCms::Admin::Appearances::NavMenusController < CamaleonCms::AdminCo
|
|
|
53
53
|
|
|
54
54
|
def save_custom_settings
|
|
55
55
|
@nav_menu_item = current_site.nav_menu_items.find(params[:id])
|
|
56
|
-
@nav_menu_item.set_field_values(params
|
|
56
|
+
@nav_menu_item.set_field_values(params.require(:field_options).permit!)
|
|
57
57
|
render nothing: true
|
|
58
58
|
end
|
|
59
59
|
|
|
@@ -66,8 +66,8 @@ class CamaleonCms::Admin::Appearances::NavMenusController < CamaleonCms::AdminCo
|
|
|
66
66
|
def update_menu_item
|
|
67
67
|
@nav_menu = current_site.nav_menus.find(params[:nav_menu_id])
|
|
68
68
|
item = current_site.nav_menu_items.find(params[:id])
|
|
69
|
-
item.update_menu_item(
|
|
70
|
-
item.set_options(params
|
|
69
|
+
item.update_menu_item(parse_external_menu(params))
|
|
70
|
+
item.set_options(params.require(:options).permit!) if params[:options].present?
|
|
71
71
|
render partial: 'menu_items', locals: {items: [item], nav_menu: @nav_menu}
|
|
72
72
|
end
|
|
73
73
|
|
|
@@ -94,8 +94,8 @@ class CamaleonCms::Admin::Appearances::NavMenusController < CamaleonCms::AdminCo
|
|
|
94
94
|
items = []
|
|
95
95
|
@nav_menu = current_site.nav_menus.find(params[:nav_menu_id])
|
|
96
96
|
if params[:external].present?
|
|
97
|
-
item = @nav_menu.append_menu_item(
|
|
98
|
-
item.set_options(params[:external]
|
|
97
|
+
item = @nav_menu.append_menu_item(parse_external_menu(params[:external]))
|
|
98
|
+
item.set_options(params[:external].require(:options).permit!) if params[:external][:options].present?
|
|
99
99
|
items << item
|
|
100
100
|
end
|
|
101
101
|
|
|
@@ -145,6 +145,11 @@ class CamaleonCms::Admin::Appearances::NavMenusController < CamaleonCms::AdminCo
|
|
|
145
145
|
helper_method :parse_menu_item
|
|
146
146
|
|
|
147
147
|
def check_menu_permission
|
|
148
|
-
authorize! :manage, :
|
|
148
|
+
authorize! :manage, :nav_menu
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# return params to be saved for external menu
|
|
152
|
+
def parse_external_menu(_params)
|
|
153
|
+
{label: _params[:external_label], link: _params[:external_url], type: "external", target: _params[:target]}
|
|
149
154
|
end
|
|
150
155
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
class CamaleonCms::Admin::Appearances::ThemesController < CamaleonCms::AdminController
|
|
2
|
+
before_action :check_theme_permission
|
|
2
3
|
# list themes or update a theme status
|
|
3
4
|
add_breadcrumb I18n.t("camaleon_cms.admin.sidebar.appearance")
|
|
4
5
|
def index
|
|
@@ -20,4 +21,9 @@ class CamaleonCms::Admin::Appearances::ThemesController < CamaleonCms::AdminCont
|
|
|
20
21
|
def preview
|
|
21
22
|
render layout: false
|
|
22
23
|
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
def check_theme_permission
|
|
27
|
+
authorize! :manage, :themes
|
|
28
|
+
end
|
|
23
29
|
end
|
|
@@ -31,6 +31,9 @@ class CamaleonCms::Admin::MediaController < CamaleonCms::AdminController
|
|
|
31
31
|
|
|
32
32
|
# render media for modal content
|
|
33
33
|
def ajax
|
|
34
|
+
if current_site.get_option('file_actions_in_modals') == 'yes'
|
|
35
|
+
@show_file_actions = true
|
|
36
|
+
end
|
|
34
37
|
@tree = cama_uploader.search(params[:search]) if params[:search].present?
|
|
35
38
|
if params[:partial].present?
|
|
36
39
|
render partial: "files_list", locals: { files: @tree[:files], folders: @tree[:folders] }
|
|
@@ -26,11 +26,13 @@ class CamaleonCms::Admin::UsersController < CamaleonCms::AdminController
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def update
|
|
29
|
+
r={user: @user}; hooks_run('user_update', r)
|
|
29
30
|
if @user.update(params.require(:user).permit!)
|
|
30
31
|
@user.set_metas(params[:meta]) if params[:meta].present?
|
|
31
32
|
@user.set_field_values(params[:field_options])
|
|
32
33
|
r = {user: @user, message: t('camaleon_cms.admin.users.message.updated'), params: params}; hooks_run('user_after_edited', r)
|
|
33
34
|
flash[:notice] = r[:message]
|
|
35
|
+
r={user: @user}; hooks_run('user_updated', r)
|
|
34
36
|
if cama_current_user.id == @user.id
|
|
35
37
|
redirect_to action: :profile_edit
|
|
36
38
|
else
|
|
@@ -65,6 +67,7 @@ class CamaleonCms::Admin::UsersController < CamaleonCms::AdminController
|
|
|
65
67
|
def create
|
|
66
68
|
user_data = params.require(:user).permit!
|
|
67
69
|
@user = current_site.users.new(user_data)
|
|
70
|
+
r={user: @user}; hooks_run('user_create', r)
|
|
68
71
|
if @user.save
|
|
69
72
|
@user.set_metas(params[:meta]) if params[:meta].present?
|
|
70
73
|
@user.set_field_values(params[:field_options])
|
|
@@ -28,6 +28,7 @@ class CamaleonCms::CamaleonController < ApplicationController
|
|
|
28
28
|
# For APIs, you may want to use :null_session instead.
|
|
29
29
|
protect_from_forgery with: :exception
|
|
30
30
|
layout Proc.new { |controller| controller.request.xhr? ? false : 'default' }
|
|
31
|
+
helper_method :current_user
|
|
31
32
|
|
|
32
33
|
# show page error
|
|
33
34
|
def render_error(status = 404, exception = nil, message = "")
|
|
@@ -109,4 +110,8 @@ class CamaleonCms::CamaleonController < ApplicationController
|
|
|
109
110
|
end
|
|
110
111
|
end
|
|
111
112
|
end
|
|
113
|
+
|
|
114
|
+
def current_user
|
|
115
|
+
cama_current_user
|
|
116
|
+
end
|
|
112
117
|
end
|
|
@@ -2,7 +2,7 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
|
|
|
2
2
|
before_action :init_frontent
|
|
3
3
|
include CamaleonCms::FrontendConcern
|
|
4
4
|
include CamaleonCms::Frontend::ApplicationHelper
|
|
5
|
-
layout Proc.new { |controller| params[:cama_ajax_request].present? ? "cama_ajax" : 'index' }
|
|
5
|
+
layout Proc.new { |controller| args = {layout: (params[:cama_ajax_request].present? ? "cama_ajax" : 'index'), controller: controller}; hooks_run("front_default_layout", args); args[:layout] }
|
|
6
6
|
before_action :before_hooks
|
|
7
7
|
after_action :after_hooks
|
|
8
8
|
# rescue_from ActiveRecord::RecordNotFound, with: :page_not_found
|
|
@@ -28,7 +28,7 @@ module CamaleonCms::FrontendConcern extend ActiveSupport::Concern
|
|
|
28
28
|
# save comment from a post
|
|
29
29
|
def save_comment
|
|
30
30
|
@post = current_site.posts.find_by_id(params[:post_id]).decorate
|
|
31
|
-
user =
|
|
31
|
+
user = cama_current_user
|
|
32
32
|
comment_data = {}
|
|
33
33
|
if !user.present? && current_site.get_option('permit_anonimos_comment', false)
|
|
34
34
|
user = current_site.get_anonymous_user
|
|
@@ -187,7 +187,7 @@ class CamaleonCms::SiteDecorator < CamaleonCms::TermTaxonomyDecorator
|
|
|
187
187
|
|
|
188
188
|
# check if current user can manage sites
|
|
189
189
|
def manage_sites?
|
|
190
|
-
self.main_site? && h.
|
|
190
|
+
self.main_site? && h.cama_current_user.admin?
|
|
191
191
|
end
|
|
192
192
|
|
|
193
193
|
# return the text status of current site
|
|
@@ -195,14 +195,14 @@ module CamaleonCms::Admin::CustomFieldsHelper
|
|
|
195
195
|
{
|
|
196
196
|
type: 'text_box',
|
|
197
197
|
key: 'dimension',
|
|
198
|
-
label:
|
|
199
|
-
description:
|
|
198
|
+
label: cama_t('camaleon_cms.admin.custom_field.fields.image_dimension'),
|
|
199
|
+
description: cama_t('camaleon_cms.admin.custom_field.fields.image_dimension_descr'),
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
type: 'text_box',
|
|
203
203
|
key: 'versions',
|
|
204
|
-
label:
|
|
205
|
-
description:
|
|
204
|
+
label: cama_t('camaleon_cms.admin.custom_field.fields.image_versions'),
|
|
205
|
+
description: cama_t('camaleon_cms.admin.custom_field.fields.image_versions_descr')
|
|
206
206
|
}
|
|
207
207
|
]
|
|
208
208
|
}
|
|
@@ -74,4 +74,9 @@ module CamaleonCms::CamaleonHelper
|
|
|
74
74
|
@_cama_timer = Time.current
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
+
# return normal translation with default value with translation of english
|
|
78
|
+
def cama_t(key, args = {})
|
|
79
|
+
args[:default] = I18n.t(key, args.dup.merge(locale: :en)) unless args[:default].present?
|
|
80
|
+
I18n.t(key, args)
|
|
81
|
+
end
|
|
77
82
|
end
|
|
@@ -90,7 +90,7 @@ module CamaleonCms::Frontend::NavMenuHelper
|
|
|
90
90
|
parent_current = true if _is_current || current_children
|
|
91
91
|
|
|
92
92
|
html += "<#{_args[:item_container]} #{r[:item_container_attrs]} class='#{_args[:item_class]} #{_args[:item_class_parent] if has_children} #{"#{_args[:item_current]}" if _is_current} #{"current-menu-ancestor" if current_children }'>#{_args[:link_before]}
|
|
93
|
-
<a #{r[:link_attrs]} href='#{data_nav_item[:link]}' class='#{args[:link_current] if _is_current} #{_args[:link_class_parent] if has_children} #{_args[:link_class]}' #{"data-toggle='dropdown'" if has_children } >#{_args[:before]}#{data_nav_item[:name]}#{_args[:after]}</a> #{_args[:link_after]}
|
|
93
|
+
<a #{r[:link_attrs]} #{" target='#{nav_menu_item.target}'" if nav_menu_item.target.present?} href='#{data_nav_item[:link]}' class='#{args[:link_current] if _is_current} #{_args[:link_class_parent] if has_children} #{_args[:link_class]}' #{"data-toggle='dropdown'" if has_children } >#{_args[:before]}#{data_nav_item[:name]}#{_args[:after]}</a> #{_args[:link_after]}
|
|
94
94
|
#{ html_children }
|
|
95
95
|
</#{_args[:item_container]}>"
|
|
96
96
|
index += 1
|
|
@@ -110,7 +110,7 @@ module CamaleonCms::Frontend::NavMenuHelper
|
|
|
110
110
|
# internal_level: ingnore (managed by internal recursion)
|
|
111
111
|
def cama_menu_parse_items(items, max_levels=-1, internal_level=0)
|
|
112
112
|
res, is_current_parent, levels = [], false, [0]
|
|
113
|
-
items.each_with_index do |nav_menu_item, index|
|
|
113
|
+
items.reorder(:term_order).each_with_index do |nav_menu_item, index|
|
|
114
114
|
data_nav_item = _get_link_nav_menu(nav_menu_item)
|
|
115
115
|
next if data_nav_item == false
|
|
116
116
|
_is_current = data_nav_item[:current] || site_current_path == data_nav_item[:link] || site_current_path == data_nav_item[:link].sub(".html", "")
|
|
@@ -129,7 +129,7 @@ module CamaleonCms::Frontend::NavMenuHelper
|
|
|
129
129
|
}.merge(data_nav_item.except(:current, :name, :link))
|
|
130
130
|
|
|
131
131
|
if has_children
|
|
132
|
-
r[:children], _is_current_parent, r[:levels] = cama_menu_parse_items(nav_menu_item.children
|
|
132
|
+
r[:children], _is_current_parent, r[:levels] = cama_menu_parse_items(nav_menu_item.children, max_levels, internal_level + 1)
|
|
133
133
|
if _is_current_parent
|
|
134
134
|
is_current_parent = true
|
|
135
135
|
r[:current_parent] = true
|
|
@@ -176,13 +176,12 @@ module CamaleonCms::Frontend::NavMenuHelper
|
|
|
176
176
|
|
|
177
177
|
private
|
|
178
178
|
def _get_link_nav_menu(nav_menu_item)
|
|
179
|
-
type_menu = nav_menu_item.kind
|
|
179
|
+
type_menu, r = nav_menu_item.kind, false
|
|
180
180
|
begin
|
|
181
181
|
case type_menu
|
|
182
182
|
when 'post'
|
|
183
183
|
post = CamaleonCms::Post.find(nav_menu_item.url).decorate
|
|
184
|
-
|
|
185
|
-
r = {link: post.the_url(as_path: true), name: post.the_title, type_menu: type_menu, current: @cama_visited_post.present? && @cama_visited_post.id == post.id}
|
|
184
|
+
r = {link: post.the_url(as_path: true), name: post.the_title, type_menu: type_menu, current: @cama_visited_post.present? && @cama_visited_post.id == post.id} if post.can_visit?
|
|
186
185
|
when 'category'
|
|
187
186
|
category = CamaleonCms::Category.find(nav_menu_item.url).decorate
|
|
188
187
|
r = {link: category.the_url(as_path: true), name: category.the_title, type_menu: type_menu, current: @cama_visited_category.present? && @cama_visited_category.id == category.id}
|
|
@@ -197,25 +196,26 @@ module CamaleonCms::Frontend::NavMenuHelper
|
|
|
197
196
|
r[:link] = cama_root_path if r[:link] == "root_url"
|
|
198
197
|
r[:link] = site_current_path if site_current_path == "#{current_site.the_path}#{r[:link]}"
|
|
199
198
|
r[:current] = r[:link] == site_current_url || r[:link] == site_current_path
|
|
199
|
+
|
|
200
200
|
# permit to customize or mark as current menu
|
|
201
201
|
# _args: (HASH) {menu_item: Model Menu Item, parsed_menu: Parsed Menu }
|
|
202
202
|
# Sample parsed_menu: {link: "url of the link", name: "Text of the menu", type_menu: 'external', current: Boolean (true => is current menu, false => not current menu item)}
|
|
203
203
|
_args = {menu_item: nav_menu_item, parsed_menu: r}; hooks_run("on_external_menu", _args)
|
|
204
204
|
r = _args[:parsed_menu]
|
|
205
|
-
return false if _args[:parsed_menu] == false
|
|
206
|
-
|
|
207
|
-
else
|
|
208
|
-
return false
|
|
209
205
|
end
|
|
210
206
|
rescue => e
|
|
211
207
|
puts "-------------------------- menu item error: #{e.message}"
|
|
212
|
-
return false
|
|
213
208
|
end
|
|
214
209
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
210
|
+
if r != false
|
|
211
|
+
# permit to mark as a current menu custom paths
|
|
212
|
+
# sample: @cama_current_menu_path = '/my_section'
|
|
213
|
+
# sample2: @cama_current_menu_path = ['/my_section', '/mi_seccion'] # multi language support
|
|
214
|
+
r[:current] = true if @cama_current_menu_path.present? && !r[:current] && (@cama_current_menu_path.is_a?(String) ? @cama_current_menu_path == r[:link] : @cama_current_menu_path.include?(r[:link]))
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# permit to customize data of parsed menu item or skip menu item by assigning false into :parsed_menu
|
|
218
|
+
_args = {menu_item: nav_menu_item, parsed_menu: r}; hooks_run("on_render_front_menu_item", _args)
|
|
219
|
+
_args[:parsed_menu]
|
|
220
220
|
end
|
|
221
221
|
end
|
|
@@ -31,12 +31,18 @@ module CamaleonCms::HooksHelper
|
|
|
31
31
|
plugin["hooks"][hook_key].each do |hook|
|
|
32
32
|
next if @_hooks_skip.present? && @_hooks_skip.include?(hook)
|
|
33
33
|
begin
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
if params.nil?
|
|
35
|
+
send(hook)
|
|
36
|
+
else
|
|
37
|
+
send(hook, params)
|
|
38
|
+
end
|
|
36
39
|
rescue
|
|
37
40
|
plugin_load_helpers(plugin)
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
if params.nil?
|
|
42
|
+
send(hook)
|
|
43
|
+
else
|
|
44
|
+
send(hook, params)
|
|
45
|
+
end
|
|
40
46
|
end
|
|
41
47
|
end
|
|
42
48
|
end
|