camaleon_cms 2.7.4 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of camaleon_cms might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +20 -20
- data/app/apps/plugins/attack/config/config.json +2 -2
- data/app/apps/plugins/front_cache/admin_controller.rb +4 -6
- data/app/apps/plugins/front_cache/config/config.json +1 -1
- data/app/apps/plugins/front_cache/config/locales/translation.yml +1 -1
- data/app/apps/plugins/front_cache/front_cache_helper.rb +3 -3
- data/app/apps/plugins/visibility_post/config/config.json +2 -2
- data/app/apps/themes/camaleon_first/assets/js/main.js +1 -1
- data/app/apps/themes/camaleon_first/views/index.html.erb +1 -1
- data/app/apps/themes/default/assets/js/main.js +1 -1
- data/app/apps/themes/new/assets/js/main.js +1 -1
- data/app/apps/themes/new/views/index.html.erb +4 -4
- data/app/apps/themes/new/views/layouts/_footer.html.erb +2 -2
- data/app/assets/javascripts/camaleon_cms/admin/_posttype.js +7 -6
- data/app/assets/javascripts/camaleon_cms/admin/admin-basic-manifest.js +2 -2
- data/app/assets/javascripts/camaleon_cms/admin/admin-manifest.js +1 -1
- data/app/assets/javascripts/camaleon_cms/admin/nav_menu.js +20 -29
- data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/de.js +2 -2
- data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/en.js +2 -2
- data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/fr.js +2 -2
- data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/it.js +2 -2
- data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/nl.js +1 -1
- data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/pt-BR.js +2 -2
- data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/ru.js +2 -2
- data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/uk.js +2 -2
- data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/zh-CN.js +1 -1
- data/app/assets/javascripts/camaleon_cms/admin/uploader/_media_manager.js +2 -2
- data/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb +15 -10
- data/app/controllers/camaleon_cms/admin/installers_controller.rb +1 -1
- data/app/controllers/camaleon_cms/admin/media_controller.rb +6 -19
- data/app/controllers/camaleon_cms/admin/settings_controller.rb +3 -2
- data/app/controllers/camaleon_cms/camaleon_controller.rb +8 -2
- data/app/decorators/camaleon_cms/application_decorator.rb +8 -0
- data/app/decorators/camaleon_cms/category_decorator.rb +3 -2
- data/app/decorators/camaleon_cms/post_decorator.rb +5 -5
- data/app/decorators/camaleon_cms/post_type_decorator.rb +5 -4
- data/app/decorators/camaleon_cms/site_decorator.rb +2 -1
- data/app/decorators/camaleon_cms/term_taxonomy_decorator.rb +1 -1
- data/app/helpers/camaleon_cms/admin/category_helper.rb +1 -1
- data/app/helpers/camaleon_cms/frontend/nav_menu_helper.rb +12 -11
- data/app/helpers/camaleon_cms/html_helper.rb +6 -6
- data/app/helpers/camaleon_cms/plugins_helper.rb +1 -1
- data/app/helpers/camaleon_cms/session_helper.rb +1 -1
- data/app/helpers/camaleon_cms/short_code_helper.rb +1 -1
- data/app/helpers/camaleon_cms/site_helper.rb +1 -1
- data/app/helpers/camaleon_cms/theme_helper.rb +1 -1
- data/app/helpers/camaleon_cms/uploader_helper.rb +10 -5
- data/app/mailers/camaleon_cms/html_mailer.rb +5 -2
- data/app/models/camaleon_cms/ability.rb +1 -1
- data/app/models/camaleon_cms/custom_field_group.rb +2 -2
- data/app/models/camaleon_cms/nav_menu.rb +1 -1
- data/app/models/camaleon_cms/post.rb +1 -1
- data/app/models/camaleon_cms/post_default.rb +1 -1
- data/app/models/camaleon_cms/post_type.rb +8 -8
- data/app/models/camaleon_cms/site.rb +1 -1
- data/app/models/camaleon_cms/term_taxonomy.rb +13 -0
- data/app/models/concerns/camaleon_cms/custom_fields_read.rb +11 -22
- data/app/models/concerns/camaleon_cms/site_default_settings.rb +1 -1
- data/app/uploaders/camaleon_cms_uploader.rb +5 -0
- data/app/validators/camaleon_cms/post_uniq_validator.rb +15 -15
- data/app/validators/camaleon_cms/uniq_validator.rb +9 -3
- data/app/validators/camaleon_cms/user_url_validator.rb +207 -0
- data/app/views/camaleon_cms/admin/media/index.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/_email_settings.html.erb +2 -2
- data/app/views/camaleon_cms/default_theme/index.html.erb +4 -4
- data/app/views/camaleon_cms/default_theme/sitemap.xml.builder +3 -3
- data/app/views/layouts/camaleon_cms/admin/_footer.html.erb +1 -1
- data/config/initializers/custom_initializers.rb +14 -0
- data/config/locales/camaleon_cms/admin/en.yml +11 -1
- data/lib/camaleon_cms/engine.rb +1 -1
- data/lib/camaleon_cms/version.rb +1 -1
- data/lib/ext/hash.rb +1 -1
- data/lib/ext/string.rb +2 -2
- data/lib/generators/camaleon_cms/theme_template/assets/js/main.js +1 -1
- metadata +50 -7
@@ -476,7 +476,7 @@ window.cama_init_media = function(mediaPanel) {
|
|
476
476
|
'<div class="alert alert-danger">' +
|
477
477
|
I18n(
|
478
478
|
'msg.cors_error',
|
479
|
-
'Please verify the following: <ul><li>If the image exist: %{url_img}</li> <li>Check if cors configuration are defined well, only for external images: S3, cloudfront(if you are using cloudfront).</li></ul><br> More information about CORS: <a href="%{url_blog}" target="_blank">here.</a>', { url_img: data.url, url_blog: '
|
479
|
+
'Please verify the following: <ul><li>If the image exist: %{url_img}</li> <li>Check if cors configuration are defined well, only for external images: S3, cloudfront(if you are using cloudfront).</li></ul><br> More information about CORS: <a href="%{url_blog}" target="_blank">here.</a>', { url_img: data.url, url_blog: 'https://blog.digitalis.io/how-to-add-cors-to-s3-with-cloudfront-1be59c74abaa' }
|
480
480
|
) +
|
481
481
|
'</div>'
|
482
482
|
)
|
@@ -566,7 +566,7 @@ window.cama_media_get_custom_params = function(customSettings) {
|
|
566
566
|
}
|
567
567
|
|
568
568
|
$(() =>
|
569
|
-
// sample: $.fn.upload_url({url: '
|
569
|
+
// sample: $.fn.upload_url({url: 'https://camaleon.website/media/132/logo2.png', dimension: '120x120', versions: '200x200', folder: 'my_folder', thumb_size: '100x100'})
|
570
570
|
// dimension: default current dimension
|
571
571
|
// folder: default current folder
|
572
572
|
// private: (Boolean) if true => list private files
|
@@ -3,9 +3,11 @@ module CamaleonCms
|
|
3
3
|
module Appearances
|
4
4
|
class NavMenusController < CamaleonCms::AdminController
|
5
5
|
include CamaleonCms::Frontend::NavMenuHelper
|
6
|
+
|
6
7
|
add_breadcrumb I18n.t('camaleon_cms.admin.sidebar.appearance')
|
7
8
|
add_breadcrumb I18n.t('camaleon_cms.admin.sidebar.menus')
|
8
9
|
before_action :check_menu_permission
|
10
|
+
|
9
11
|
def index
|
10
12
|
@nav_menu = if params[:id].present?
|
11
13
|
current_site.nav_menus.find_by_id(params[:id])
|
@@ -64,7 +66,10 @@ module CamaleonCms
|
|
64
66
|
# render edit external menu item
|
65
67
|
def edit_menu_item
|
66
68
|
render '_external_menu', layout: false,
|
67
|
-
locals: {
|
69
|
+
locals: {
|
70
|
+
nav_menu: current_site.nav_menus.find(params[:nav_menu_id]),
|
71
|
+
menu_item: current_site.nav_menu_items.find(params[:id])
|
72
|
+
}
|
68
73
|
end
|
69
74
|
|
70
75
|
# update an external menu item
|
@@ -98,22 +103,22 @@ module CamaleonCms
|
|
98
103
|
def add_items
|
99
104
|
items = []
|
100
105
|
@nav_menu = current_site.nav_menus.find(params[:nav_menu_id])
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
106
|
+
external_params = params[:external]
|
107
|
+
if external_params.present?
|
108
|
+
external_item = @nav_menu.append_menu_item(parse_external_menu(external_params))
|
109
|
+
external_item.set_options(external_params.require(:options).permit!) if external_params[:options].present?
|
110
|
+
items << external_item
|
105
111
|
end
|
106
112
|
|
107
113
|
if params[:custom_items].present? # custom menu items
|
108
|
-
params[:custom_items].
|
109
|
-
type =
|
110
|
-
|
111
|
-
items << item
|
114
|
+
params[:custom_items].each_value do |custom_item|
|
115
|
+
type = custom_item['kind'].present? ? custom_item['kind'] : 'external'
|
116
|
+
items << @nav_menu.append_menu_item({ label: custom_item['label'], link: custom_item['url'], type: type })
|
112
117
|
end
|
113
118
|
end
|
114
119
|
|
115
120
|
if params[:items].present?
|
116
|
-
params[:items].
|
121
|
+
params[:items].each_value do |item|
|
117
122
|
item = @nav_menu.append_menu_item({ label: 'auto', link: item['id'], type: item['kind'] })
|
118
123
|
items << item
|
119
124
|
end
|
@@ -6,15 +6,6 @@ module CamaleonCms
|
|
6
6
|
skip_before_action :verify_authenticity_token, only: :upload, raise: false
|
7
7
|
before_action :init_media_vars, except: :download_private_file
|
8
8
|
|
9
|
-
LOCALHOST_DOMAIN_MATCHER = /
|
10
|
-
localhost|
|
11
|
-
127\.0\.0\.1|
|
12
|
-
0\.0\.0\.0|
|
13
|
-
0x7f\.0x0\.0x0\.0x1| # hex encoding
|
14
|
-
0177\.0\.0\.01| # octal encoding
|
15
|
-
2130706433 # dword encoding
|
16
|
-
/x.freeze
|
17
|
-
|
18
9
|
# render media section
|
19
10
|
def index
|
20
11
|
authorize! :manage, :media
|
@@ -71,13 +62,13 @@ module CamaleonCms
|
|
71
62
|
cama_uploader.delete_file(params[:folder].gsub('//', '/'))
|
72
63
|
render plain: ''
|
73
64
|
when 'crop_url'
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
r = if
|
78
|
-
{ error:
|
65
|
+
user_url = params[:url].to_s
|
66
|
+
user_url = "#{current_site.the_url(locale: nil)}#{user_url}" unless user_url.start_with?('data:', 'http')
|
67
|
+
url_validation_result = UserUrlValidator.validate(user_url)
|
68
|
+
r = if url_validation_result.is_a?(Array)
|
69
|
+
{ error: url_validation_result.join(', ') }
|
79
70
|
else
|
80
|
-
cama_tmp_upload(
|
71
|
+
cama_tmp_upload(user_url, formats: params[:formats], name: params[:name])
|
81
72
|
end
|
82
73
|
if r[:error].present?
|
83
74
|
render plain: helpers.sanitize(r[:error])
|
@@ -91,10 +82,6 @@ module CamaleonCms
|
|
91
82
|
end
|
92
83
|
end
|
93
84
|
|
94
|
-
def local_url?(url)
|
95
|
-
url.try :match?, LOCALHOST_DOMAIN_MATCHER
|
96
|
-
end
|
97
|
-
|
98
85
|
# upload files from media uploader
|
99
86
|
def upload(settings = {})
|
100
87
|
params[:dimension] = nil if params[:skip_auto_crop].present?
|
@@ -26,7 +26,7 @@ module CamaleonCms
|
|
26
26
|
flash[:notice] = t('camaleon_cms.admin.settings.message.site_updated')
|
27
27
|
args = { action: :site }
|
28
28
|
args[:host], args[:port] = @site.get_domain.to_s.split(':') if cache_slug != @site.slug
|
29
|
-
redirect_to(args)
|
29
|
+
redirect_to(args, allow_other_host: true)
|
30
30
|
else
|
31
31
|
render 'site'
|
32
32
|
end
|
@@ -70,7 +70,8 @@ module CamaleonCms
|
|
70
70
|
|
71
71
|
# send email test
|
72
72
|
def test_email
|
73
|
-
|
73
|
+
data = { content: 'Test content', current_site: current_site, url_base: cama_root_url }
|
74
|
+
CamaleonCms::HtmlMailer.sender(params[:email], 'Test', data).deliver_now
|
74
75
|
head :ok
|
75
76
|
rescue StandardError => e
|
76
77
|
render inline: e.message, status: 502
|
@@ -51,7 +51,7 @@ module CamaleonCms
|
|
51
51
|
# generate captcha image
|
52
52
|
def captcha
|
53
53
|
image = cama_captcha_build(params[:len])
|
54
|
-
send_data image.to_blob, type: image.
|
54
|
+
send_data image.to_blob, type: MiniMime.lookup_by_extension(image.type).content_type, disposition: 'inline'
|
55
55
|
end
|
56
56
|
|
57
57
|
private
|
@@ -103,7 +103,13 @@ module CamaleonCms
|
|
103
103
|
def cama_site_check_existence
|
104
104
|
if !current_site.present?
|
105
105
|
if Cama::Site.main_site.present?
|
106
|
-
|
106
|
+
url = Cama::Site.main_site.decorate.the_url
|
107
|
+
# TODO: Remove this condition when Rails 6.x won't be supported
|
108
|
+
if Rails.gem_version >= Gem::Version.new('7.0.0')
|
109
|
+
redirect_to url, allow_other_host: true
|
110
|
+
else
|
111
|
+
redirect_to url
|
112
|
+
end
|
107
113
|
else
|
108
114
|
redirect_to cama_admin_installers_path
|
109
115
|
end
|
@@ -4,6 +4,14 @@ module CamaleonCms
|
|
4
4
|
@_deco_locale = nil
|
5
5
|
include CamaleonCms::MetasDecoratorMethods
|
6
6
|
|
7
|
+
def marshal_dump
|
8
|
+
@object
|
9
|
+
end
|
10
|
+
|
11
|
+
def marshal_load(obj)
|
12
|
+
@object = obj
|
13
|
+
end
|
14
|
+
|
7
15
|
# return the keywords for this model
|
8
16
|
def the_keywords
|
9
17
|
k = object.get_option('keywords', '')
|
@@ -21,7 +21,7 @@ module CamaleonCms
|
|
21
21
|
|
22
22
|
# return all children categories for the current category (active_record) filtered by permissions + hidden posts + roles + etc...
|
23
23
|
# in return object, you can add custom where's or pagination like here:
|
24
|
-
#
|
24
|
+
# https://edgeguides.rubyonrails.org/active_record_querying.html
|
25
25
|
def the_categories
|
26
26
|
object.children
|
27
27
|
end
|
@@ -29,7 +29,8 @@ module CamaleonCms
|
|
29
29
|
# return a child category from this category with id (integer) or by slug (string)
|
30
30
|
def the_category(slug_or_id)
|
31
31
|
return object.categories.where(id: slug_or_id).first if slug_or_id.is_a?(Integer)
|
32
|
-
|
32
|
+
|
33
|
+
object.categories.find_by_slug(slug_or_id) if slug_or_id.is_a?(String)
|
33
34
|
end
|
34
35
|
|
35
36
|
# ---------------------
|
@@ -41,8 +41,8 @@ module CamaleonCms
|
|
41
41
|
if th.present?
|
42
42
|
th
|
43
43
|
else
|
44
|
-
|
45
|
-
|
44
|
+
default || object.post_type.get_option('default_thumb',
|
45
|
+
nil) || h.asset_url('camaleon_cms/image-not-found.png')
|
46
46
|
end
|
47
47
|
end
|
48
48
|
alias the_image_url the_thumb_url
|
@@ -61,12 +61,12 @@ module CamaleonCms
|
|
61
61
|
end
|
62
62
|
|
63
63
|
# return front url for this post
|
64
|
-
# sample:
|
64
|
+
# sample: https://localhost.com/my-page.html
|
65
65
|
# args:
|
66
66
|
# locale: language (default current language)
|
67
67
|
# as_path: return the path instead of full url, sample: /my-page.html
|
68
68
|
# Also, you can pass extra attributes as params for the url, sample: page.the_url(my_param: 'value', other: "asd")
|
69
|
-
# =>
|
69
|
+
# => https://localhost.com/my-page.html?my_param=value&other=asd
|
70
70
|
# Return String URL
|
71
71
|
def the_url(*args)
|
72
72
|
args = args.extract_options!
|
@@ -127,7 +127,7 @@ module CamaleonCms
|
|
127
127
|
end
|
128
128
|
|
129
129
|
# return a hash of frontend urls for this post
|
130
|
-
# sample: {es: '
|
130
|
+
# sample: {es: 'https://mydomain.com/es/articulo-3.html', en: 'https://mydomain.com/en/post-3.html'}
|
131
131
|
def the_urls(*args)
|
132
132
|
args = args.extract_options!
|
133
133
|
res = {}
|
@@ -55,14 +55,14 @@ module CamaleonCms
|
|
55
55
|
|
56
56
|
# return main categories (first level) for the post_type (active_record) filtered by permissions
|
57
57
|
# in return object, you can add custom where's or pagination like here:
|
58
|
-
#
|
58
|
+
# https://edgeguides.rubyonrails.org/active_record_querying.html
|
59
59
|
def the_categories
|
60
60
|
object.categories
|
61
61
|
end
|
62
62
|
|
63
63
|
# return full categories (all levels) for the post_type (active_record) filtered by permissions
|
64
64
|
# in return object, you can add custom where's or pagination like here:
|
65
|
-
#
|
65
|
+
# https://edgeguides.rubyonrails.org/active_record_querying.html
|
66
66
|
def the_full_categories
|
67
67
|
object.full_categories
|
68
68
|
end
|
@@ -70,12 +70,13 @@ module CamaleonCms
|
|
70
70
|
# return a category from this post_type with id (integer) or by slug (string)
|
71
71
|
def the_category(slug_or_id)
|
72
72
|
return the_categories.where(id: slug_or_id).first if slug_or_id.is_a?(Integer)
|
73
|
-
|
73
|
+
|
74
|
+
the_categories.find_by_slug(slug_or_id) if slug_or_id.is_a?(String)
|
74
75
|
end
|
75
76
|
|
76
77
|
# return all post_tags for the post_type (active_record) filtered by permissions + hidden posts + roles + etc...
|
77
78
|
# in return object, you can add custom where's or pagination like here:
|
78
|
-
#
|
79
|
+
# https://edgeguides.rubyonrails.org/active_record_querying.html
|
79
80
|
def the_post_tags
|
80
81
|
object.post_tags
|
81
82
|
end
|
@@ -80,7 +80,8 @@ module CamaleonCms
|
|
80
80
|
# slug_or_id: string => return all main categories of the post_type with slug = slug_or_id
|
81
81
|
def the_categories(slug_or_id = nil)
|
82
82
|
return the_post_type(slug_or_id).the_categories if slug_or_id.present?
|
83
|
-
|
83
|
+
|
84
|
+
object.categories unless slug_or_id.present?
|
84
85
|
end
|
85
86
|
|
86
87
|
# return the category object with id or slug = slug_or_id from this site
|
@@ -48,7 +48,7 @@ module CamaleonCms
|
|
48
48
|
# ---------------------- filters
|
49
49
|
# return all posts for this model (active_record) filtered by permissions + hidden posts + roles + etc...
|
50
50
|
# in return object, you can add custom where's or pagination like here:
|
51
|
-
#
|
51
|
+
# https://edgeguides.rubyonrails.org/active_record_querying.html
|
52
52
|
def the_posts
|
53
53
|
h.verify_front_visibility(object.posts)
|
54
54
|
end
|
@@ -17,7 +17,7 @@ module CamaleonCms
|
|
17
17
|
options << [('—' * level) + category.the_title, category.id]
|
18
18
|
children = attrs[:max_level] < level ? [] : category.children
|
19
19
|
children = [] if attrs[:until_cats].include?(category.id)
|
20
|
-
options += cama_category_get_options_html(children, level + 1, attrs)
|
20
|
+
options += cama_category_get_options_html(children, level + 1, attrs) unless children.empty?
|
21
21
|
end
|
22
22
|
options
|
23
23
|
end
|
@@ -23,7 +23,7 @@ module CamaleonCms
|
|
23
23
|
item_class_parent: 'dropdown', # class for all menu items that contain sub items
|
24
24
|
sub_container: 'ul', # type of container for sub items
|
25
25
|
sub_class: 'dropdown-menu', # class for sub container
|
26
|
-
callback_item: ->(args) {},
|
26
|
+
callback_item: ->(args) {}, # rubocop:disable Lint/ShadowingOuterLocalVariable
|
27
27
|
# callback executed for each item (args = { menu_item, link, level, settings, has_children, link_attrs = "", index}).
|
28
28
|
# menu_item: (Object) Menu object
|
29
29
|
# link: (Hash) link data: {link: '', name: ''}
|
@@ -48,10 +48,11 @@ module CamaleonCms
|
|
48
48
|
container_append: '' # content append for menu container
|
49
49
|
}
|
50
50
|
|
51
|
-
args = args_def.merge(args)
|
51
|
+
args = args_def.merge!(args)
|
52
52
|
nav_menu = current_site.nav_menus.find_by_slug(args[:menu_slug])
|
53
|
-
nav_menu
|
54
|
-
html = "<#{args[:container]} class='#{args[:container_class]}'
|
53
|
+
nav_menu ||= current_site.nav_menus.first
|
54
|
+
html = "<#{args[:container]} class='#{args[:container_class]}' "\
|
55
|
+
"id='#{args[:container_id]}'>#{args[:container_prepend]}{__}#{args[:container_append]}</#{args[:container]}>"
|
55
56
|
if nav_menu.present?
|
56
57
|
html.sub('{__}', cama_menu_draw_items(args, nav_menu.children.reorder(:term_order)))
|
57
58
|
else
|
@@ -69,10 +70,10 @@ module CamaleonCms
|
|
69
70
|
data_nav_item = cama_parse_menu_item(nav_menu_item)
|
70
71
|
next if data_nav_item == false
|
71
72
|
|
72
|
-
_is_current = data_nav_item[:current] || site_current_path == data_nav_item[:link] ||
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
_is_current = data_nav_item[:current] || site_current_path == data_nav_item[:link] ||
|
74
|
+
site_current_path == data_nav_item[:link].sub('.html', '')
|
75
|
+
has_children = nav_menu_item.have_children? && (args[:levels] == -1 ||
|
76
|
+
(args[:levels] != -1 && level <= args[:levels]))
|
76
77
|
r = {
|
77
78
|
menu_item: nav_menu_item.decorate,
|
78
79
|
link: data_nav_item,
|
@@ -116,7 +117,7 @@ module CamaleonCms
|
|
116
117
|
index += 1
|
117
118
|
end
|
118
119
|
|
119
|
-
if level
|
120
|
+
if level == 0
|
120
121
|
html
|
121
122
|
else
|
122
123
|
html = "<#{args[:sub_container]} class='#{args[:sub_class]} #{if parent_current
|
@@ -142,7 +143,7 @@ module CamaleonCms
|
|
142
143
|
'.html', ''
|
143
144
|
)
|
144
145
|
has_children = nav_menu_item.have_children?
|
145
|
-
has_children = false if max_levels
|
146
|
+
has_children = false if max_levels > 0 && max_levels == internal_level
|
146
147
|
data_nav_item[:label] = data_nav_item[:name]
|
147
148
|
data_nav_item[:url] = data_nav_item[:link]
|
148
149
|
r = {
|
@@ -169,7 +170,7 @@ module CamaleonCms
|
|
169
170
|
res << r
|
170
171
|
end
|
171
172
|
|
172
|
-
if internal_level
|
173
|
+
if internal_level == 0
|
173
174
|
res
|
174
175
|
else
|
175
176
|
[res, is_current_parent, levels.max]
|
@@ -72,14 +72,14 @@ module CamaleonCms
|
|
72
72
|
def cama_draw_custom_assets
|
73
73
|
cama_html_helpers_init unless @_assets_libraries.present?
|
74
74
|
libs = []
|
75
|
-
@_assets_libraries.
|
75
|
+
@_assets_libraries.each_value do |assets|
|
76
76
|
libs += assets[:css] if assets[:css].present?
|
77
77
|
end
|
78
78
|
stylesheets = libs.uniq
|
79
79
|
css = stylesheet_link_tag(*stylesheets, media: 'all')
|
80
80
|
|
81
81
|
libs = []
|
82
|
-
@_assets_libraries.
|
82
|
+
@_assets_libraries.each_value do |assets|
|
83
83
|
libs += assets[:js] if assets[:js].present?
|
84
84
|
end
|
85
85
|
javascripts = libs.uniq
|
@@ -98,7 +98,7 @@ module CamaleonCms
|
|
98
98
|
terms.all.each do |term|
|
99
99
|
options << [('—' * level) + term.name, term.id] unless @term.id == term.id
|
100
100
|
children = term.children
|
101
|
-
options += cama_get_options_html_from_items(children, level + 1)
|
101
|
+
options += cama_get_options_html_from_items(children, level + 1) unless children.empty?
|
102
102
|
end
|
103
103
|
options
|
104
104
|
end
|
@@ -121,18 +121,18 @@ module CamaleonCms
|
|
121
121
|
libs[:datepicker] = { js: [] }
|
122
122
|
libs[:datetimepicker] = { js: [], css: [] }
|
123
123
|
libs[:tinymce] =
|
124
|
-
{ js: [
|
124
|
+
{ js: %w[camaleon_cms/admin/tinymce/tinymce.min camaleon_cms/admin/tinymce/plugins/filemanager/plugin.min],
|
125
125
|
css: ['camaleon_cms/admin/tinymce/skins/lightgray/content.min'] }
|
126
126
|
libs[:form_ajax] = { js: ['camaleon_cms/admin/form/jquery.form'] }
|
127
127
|
libs[:cropper] = {} # loaded by default
|
128
128
|
libs[:post] =
|
129
|
-
{ js: [
|
129
|
+
{ js: %w[camaleon_cms/admin/jquery.tagsinput.min camaleon_cms/admin/post],
|
130
130
|
css: ['camaleon_cms/admin/jquery.tagsinput'] }
|
131
131
|
libs[:multiselect] = { js: ['camaleon_cms/admin/bootstrap-select.js'] }
|
132
132
|
libs[:validate] = { js: ['camaleon_cms/admin/jquery.validate'] }
|
133
133
|
libs[:nav_menu] =
|
134
134
|
{ css: ['camaleon_cms/admin/nestable/jquery.nestable'],
|
135
|
-
js: [
|
135
|
+
js: %w[camaleon_cms/admin/jquery.nestable camaleon_cms/admin/nav_menu] }
|
136
136
|
libs[:admin_intro] =
|
137
137
|
{ js: ['camaleon_cms/admin/introjs/intro.min'], css: ['camaleon_cms/admin/introjs/introjs.min'] }
|
138
138
|
@_cama_assets_libraries = libs
|
@@ -127,7 +127,7 @@ module CamaleonCms
|
|
127
127
|
# asset: (String) asset name
|
128
128
|
# plugin_key: (optional) plugin name, default (current plugin caller to this function)
|
129
129
|
# sample:
|
130
|
-
# plugin_asset_url("css/main.css") => return:
|
130
|
+
# plugin_asset_url("css/main.css") => return: https://myhost.com/assets/plugins/my_plugin/assets/css/main-54505620f.css
|
131
131
|
def plugin_asset_url(asset, plugin_key = nil)
|
132
132
|
key = plugin_key || self_plugin_key(1)
|
133
133
|
p = PluginRoutes.plugin_info(key)['gem_mode'] ? "plugins/#{key}/#{asset}" : "plugins/#{key}/assets/#{asset}"
|
@@ -6,7 +6,7 @@ module CamaleonCms
|
|
6
6
|
# redirect_url (default nil): after initialized the session, this will be redirected to
|
7
7
|
# "redirect_url" if defined
|
8
8
|
# it doesn't redirect if redirect_url === false
|
9
|
-
# return to previous page if defined the cookie['return_to'] or login url received extra param: return_to=
|
9
|
+
# return to previous page if defined the cookie['return_to'] or login url received extra param: return_to=https://mysite.com
|
10
10
|
def login_user(user, remember_me = false, redirect_url = nil)
|
11
11
|
c = { value: [user.auth_token, request.user_agent, request.ip], expires: 24.hours.from_now }
|
12
12
|
c[:domain] = :all if PluginRoutes.system_info['users_share_sites'].present? && CamaleonCms::Site.count > 1
|
@@ -32,7 +32,7 @@ module CamaleonCms
|
|
32
32
|
nil
|
33
33
|
end
|
34
34
|
unless r[:site].present?
|
35
|
-
Rails.logger.error 'Camaleon CMS - Please define your current site: $current_site = CamaleonCms::Site.first.decorate or map your domains:
|
35
|
+
Rails.logger.error 'Camaleon CMS - Please define your current site: $current_site = CamaleonCms::Site.first.decorate or map your domains: https://camaleon.website/documentation/category/139779-examples/how.html'.cama_log_style(:red)
|
36
36
|
end
|
37
37
|
@current_site = r[:site]
|
38
38
|
end
|
@@ -26,7 +26,7 @@ module CamaleonCms
|
|
26
26
|
# asset: (String) asset name
|
27
27
|
# theme_name: (optional) theme name, default (current theme caller to this function)
|
28
28
|
# sample:
|
29
|
-
# theme_asset_url("css/main.css") => return:
|
29
|
+
# theme_asset_url("css/main.css") => return: https://myhost.com/assets/themes/my_theme/assets/css/main-54505620f.css
|
30
30
|
def theme_asset_url(asset, theme_name = nil)
|
31
31
|
p = theme_asset_path(asset, theme_name)
|
32
32
|
begin
|
@@ -16,7 +16,7 @@ module CamaleonCms
|
|
16
16
|
# sample "test.png", versions: '200x200,450x450' will generate: thumb/test-png_200x200.png, test-png_450x450.png
|
17
17
|
# thumb_size: String (redefine the dimensions of the thumbnail, sample: '100x100' ==> only for images)
|
18
18
|
# temporal_time: if great than 0 seconds, then this file will expire (removed) in that time (default: 0)
|
19
|
-
# To manage jobs, please check
|
19
|
+
# To manage jobs, please check https://edgeguides.rubyonrails.org/active_job_basics.html
|
20
20
|
# Note: if you are using temporal_time, you will need to copy the file to another directory later
|
21
21
|
# sample: upload_file(params[:my_file], {formats: "images", folder: "temporal"})
|
22
22
|
# sample: upload_file(params[:my_file], {formats: "jpg,png,gif,mp3,mp4", temporal_time: 10.minutes, maximum: 10.megabytes})
|
@@ -45,7 +45,7 @@ module CamaleonCms
|
|
45
45
|
generate_thumb: true,
|
46
46
|
temporal_time: 0,
|
47
47
|
filename: begin
|
48
|
-
|
48
|
+
cached_name || uploaded_io.original_filename
|
49
49
|
rescue StandardError
|
50
50
|
uploaded_io.path.split('/').last
|
51
51
|
end.cama_fix_filename,
|
@@ -72,7 +72,6 @@ module CamaleonCms
|
|
72
72
|
# save file
|
73
73
|
key = File.join(settings[:folder], settings[:filename]).to_s.cama_fix_slash
|
74
74
|
res = cama_uploader.add_file(settings[:uploaded_io], key, { same_name: settings[:same_name] })
|
75
|
-
{} if (settings[:temporal_time]).positive?
|
76
75
|
|
77
76
|
# generate image versions
|
78
77
|
if res['file_type'] == 'image'
|
@@ -92,6 +91,12 @@ module CamaleonCms
|
|
92
91
|
FileUtils.rm_f(uploaded_io.path) if settings[:remove_source] && File.exist?(uploaded_io.path)
|
93
92
|
|
94
93
|
hooks_run('after_upload', settings)
|
94
|
+
|
95
|
+
# temporal file upload (always put as local for temporal files)
|
96
|
+
if settings[:temporal_time] > 0
|
97
|
+
CamaleonCmsUploader.delete_block.call(settings, cama_uploader, key)
|
98
|
+
end
|
99
|
+
|
95
100
|
res
|
96
101
|
end
|
97
102
|
|
@@ -237,7 +242,7 @@ module CamaleonCms
|
|
237
242
|
# upload tmp file
|
238
243
|
# support for url and local path
|
239
244
|
# sample:
|
240
|
-
# cama_tmp_upload('
|
245
|
+
# cama_tmp_upload('https://camaleon.website/media/132/logo2.png') ==> /var/rails/my_project/public/tmp/1/logo2.png
|
241
246
|
# cama_tmp_upload('/var/www/media/132/logo 2.png') ==> /var/rails/my_project/public/tmp/1/logo-2.png
|
242
247
|
# accept args:
|
243
248
|
# name: to indicate the name to use, sample: cama_tmp_upload('/var/www/media/132/logo 2.png', {name: 'owen.png', formats: 'images'})
|
@@ -324,7 +329,7 @@ module CamaleonCms
|
|
324
329
|
cloud_front: current_site.get_option('filesystem_s3_cloudfront'),
|
325
330
|
aws_file_upload_settings: lambda { |settings|
|
326
331
|
settings
|
327
|
-
}, # permit to add your custom attributes for file_upload
|
332
|
+
}, # permit to add your custom attributes for file_upload https://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Object.html#upload_file-instance_method
|
328
333
|
aws_file_read_settings: lambda { |data, _s3_file|
|
329
334
|
data
|
330
335
|
} # permit to read custom attributes from aws file and add to file parsed object
|
@@ -58,8 +58,11 @@ module CamaleonCms
|
|
58
58
|
prepend_view_path(Rails.root.join(views_dir).to_s)
|
59
59
|
|
60
60
|
theme = @current_site.get_theme
|
61
|
-
|
62
|
-
|
61
|
+
if theme.settings && theme.settings['gem_mode']
|
62
|
+
lookup_context.prefixes.prepend("themes/#{theme.slug}")
|
63
|
+
else
|
64
|
+
lookup_context.prefixes.prepend("themes/#{theme.slug}/views")
|
65
|
+
end
|
63
66
|
lookup_context.use_camaleon_partial_prefixes = true
|
64
67
|
((data[:files] || []) + (data[:attachments] || [])).each do |attach|
|
65
68
|
if File.exist?(attach) && !File.directory?(attach)
|
@@ -105,7 +105,7 @@ module CamaleonCms
|
|
105
105
|
end
|
106
106
|
|
107
107
|
# support for custom abilities for each posttype
|
108
|
-
# sample:
|
108
|
+
# sample: https://camaleon.website/documentation/category/40756-uncategorized/custom-models.html
|
109
109
|
@roles_post_type.each do |k, v|
|
110
110
|
next if %w[edit edit_other edit_publish publish manage_categories].include?(k.to_s)
|
111
111
|
|
@@ -5,8 +5,8 @@ module CamaleonCms
|
|
5
5
|
alias_attribute :site_id, :parent_id
|
6
6
|
|
7
7
|
default_scope do
|
8
|
-
where
|
9
|
-
|
8
|
+
where("object_class != '_fields'")
|
9
|
+
.reorder("#{CamaleonCms::CustomField.table_name}.field_order ASC")
|
10
10
|
end
|
11
11
|
|
12
12
|
has_many :metas, -> { where(object_class: 'CustomFieldGroup') }, foreign_key: :objectid, dependent: :destroy
|
@@ -10,7 +10,7 @@ module CamaleonCms
|
|
10
10
|
# add menu item for current menu
|
11
11
|
# value: (Hash) is a hash object that contains label, type, link
|
12
12
|
# options for type: post | category | post_type | post_tag | external
|
13
|
-
# sample: {label: "my label", type: "external", link: "
|
13
|
+
# sample: {label: "my label", type: "external", link: "https://camaleon.website", target: '_blank'}
|
14
14
|
# sample: {label: "my label", type: "post", link: 10}
|
15
15
|
# sample: {label: "my label", type: "category", link: 12}
|
16
16
|
# return item created
|
@@ -42,7 +42,7 @@ module CamaleonCms
|
|
42
42
|
validates_with CamaleonCms::PostUniqValidator
|
43
43
|
attr_accessor :show_title_with_parent
|
44
44
|
|
45
|
-
before_create :fix_post_order, if: ->(p) { !p.post_order.present? || p.post_order
|
45
|
+
before_create :fix_post_order, if: ->(p) { !p.post_order.present? || p.post_order == 0 }
|
46
46
|
|
47
47
|
# return all parents for current page hierarchy ordered bottom to top
|
48
48
|
def parents
|
@@ -42,7 +42,7 @@ module CamaleonCms
|
|
42
42
|
res = where("#{CamaleonCms::Post.table_name}.slug = ? OR #{CamaleonCms::Post.table_name}.slug LIKE ? ", slug,
|
43
43
|
"%-->#{slug}<!--%")
|
44
44
|
# end
|
45
|
-
res.
|
45
|
+
res.take
|
46
46
|
end
|
47
47
|
|
48
48
|
# return the parent of a post (support for sub contents or tree of posts)
|