camaleon_cms 2.9.0 → 2.9.1

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.

Potentially problematic release.


This version of camaleon_cms might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bbfa67257bf8efd2830d5c4d20d1e00ce5db6293c145205326fc5c496a6ffd1
4
- data.tar.gz: 848c0feddb8c6dbe3be7d992d1b116c9b438006cea66af150468576e8096eb9c
3
+ metadata.gz: 6aace403e18b38c945faca659af2196ed66f130ed61e7b5454626137c59331ce
4
+ data.tar.gz: f104182791714153a963e03ccc23dec4720cd9e7528ab378b0facf33e351e2b4
5
5
  SHA512:
6
- metadata.gz: 1ff798ffbe98e5906feed579e437f3da2b8636f99b2d22f508afbcc6981c70752ea464ac21af2457f73e94087fe4d88ee863ce3fadaca956d7570422710eebb3
7
- data.tar.gz: 793bd8de6630499e71697966559066d74f38f1ccd225434fc2f4b101ce41fe1dbc62fbba94138bc57ca473a3abf9a9f48ecc820df1f0ec538b8ffed89b2268c4
6
+ metadata.gz: 28708ab09b20a2a0c78ae3f104e2a38c5560725596bc9e70e935fb3384230f0ef006523d9f56db6e3c4ee5238a066ca6e1d6ea31e710623c8b9c9b8777380fb2
7
+ data.tar.gz: c7fe66386eb9b15fd988afc2ad366a1ffd16d82f923219c10b61e590e5eda7f27b66413da745cb9eca8c736284500f35d9bbd41f6c39dd99828164ba8c308544
@@ -56,7 +56,7 @@ module CamaleonCms
56
56
  r = { posts: @posts, post_type: @post_type, btns: @btns, all_posts: posts_all, render: 'index',
57
57
  per_page: per_page }
58
58
  hooks_run('list_post', r)
59
- add_breadcrumb (@btns[params[:s].to_sym]).to_s if params[:s].present?
59
+ add_breadcrumb(@btns[params[:s].to_sym].to_s) if params[:s].present?
60
60
  @posts = r[:posts].paginate(page: params[:page], per_page: r[:per_page])
61
61
  render r[:render]
62
62
  end
@@ -52,10 +52,15 @@ module CamaleonCms
52
52
  def updated_ajax
53
53
  @user = current_site.users.find(params[:user_id])
54
54
  update_session = current_user_is?(@user)
55
- @user.update(params.require(:password).permit!)
56
- render inline: @user.errors.full_messages.join(', ')
55
+ attrs = params.require(:password).permit(%i[password password_confirmation])
56
+ @user.update(password: attrs.require(:password), password_confirmation: attrs.require(:password_confirmation))
57
+
58
+ return render inline: @user.errors.full_messages.join(', '), status: :unprocessable_entity if @user.errors.any?
59
+
57
60
  # keep user logged in when changing their own password
58
61
  update_auth_token_in_cookie @user.auth_token if update_session && @user.saved_change_to_password_digest?
62
+ rescue ActionController::ParameterMissing => e
63
+ render inline: "ERROR: #{e.class.name}, #{e.message}", status: :bad_request
59
64
  end
60
65
 
61
66
  def update_auth_token_in_cookie(token)
@@ -9,7 +9,7 @@ module CamaleonCms
9
9
  draw_menu({ menu_slug: key, container_class: class_name })
10
10
  end
11
11
 
12
- # draw menu as an html
12
+ # draw menu as html
13
13
  # default configurations is for bootstrap support
14
14
  def draw_menu(args = {})
15
15
  args_def = {
@@ -33,7 +33,7 @@ module CamaleonCms
33
33
  # index: (Integer) Index Position of this menu
34
34
  # link_attrs: (String) Here you can add your custom attrs for current link, sample: id='my_id' data-title='#{args[:link][:name]}'
35
35
  # item_container_attrs: (String) Here you can add your custom attrs for link container.
36
- # In settings you can change the values for this item, like after, before, ..:
36
+ # In settings, you can change the values for this item, like after, before, ..:
37
37
  # sample: lambda{|args| args[:settings][:after] = "<span class='caret'></span>" if args[:has_children]; args[:link_attrs] = "id='#{menu_item.id}'"; }
38
38
  # sample: lambda{|args| args[:settings][:before] = "<i class='fa fa-home'></i>" if args[:level] == 0 && args[:index] == 0; }
39
39
  before: '', # content before link text
@@ -99,7 +99,7 @@ module CamaleonCms
99
99
  html += "<#{_args[:item_container]} #{r[:item_container_attrs]} class='#{_args[:item_class]} #{if has_children
100
100
  _args[:item_class_parent]
101
101
  end} #{if _is_current
102
- (_args[:item_current]).to_s
102
+ _args[:item_current].to_s
103
103
  end} #{if current_children
104
104
  'current-menu-ancestor'
105
105
  end}'>#{_args[:link_before]}
@@ -129,8 +129,8 @@ module CamaleonCms
129
129
 
130
130
  # filter and parse all menu items visible for current user and adding the flag for current_parent or current_item
131
131
  # max_levels: max levels to iterate
132
- # return an multidimensional array with all items until level 'max_levels'
133
- # internal_level: ingnore (managed by internal recursion)
132
+ # return a multidimensional array with all items until level 'max_levels'
133
+ # internal_level: ignore (managed by internal recursion)
134
134
  def cama_menu_parse_items(items, max_levels = -1, internal_level = 0)
135
135
  res = []
136
136
  is_current_parent = false
@@ -154,7 +154,7 @@ module CamaleonCms
154
154
  current_item: _is_current,
155
155
  current_parent: false,
156
156
  levels: 0
157
- }.merge(data_nav_item.except(:current, :name, :link))
157
+ }.merge!(data_nav_item.except(:current, :name, :link))
158
158
 
159
159
  if has_children
160
160
  r[:children], _is_current_parent, r[:levels] = cama_menu_parse_items(nav_menu_item.children, max_levels,
@@ -2,5 +2,9 @@ module CamaleonCms
2
2
  class Meta < CamaleonRecord
3
3
  self.table_name = "#{PluginRoutes.static_system_info['db_prefix']}metas"
4
4
  # attr_accessible :objectid, :key, :value, :object_class
5
+
6
+ extend CamaleonCms::NormalizeAttrs
7
+
8
+ normalize_attrs(:value)
5
9
  end
6
10
  end
@@ -83,7 +83,7 @@ module CamaleonCms
83
83
 
84
84
  # check if this is in draft status
85
85
  def draft?
86
- status == 'draft' || status == 'draft_child'
86
+ %w[draft draft_child].include?(status)
87
87
  end
88
88
 
89
89
  def draft_child?
@@ -3,6 +3,8 @@ module CamaleonCms
3
3
  include CamaleonCms::Metas
4
4
  include CamaleonCms::CommonRelationships
5
5
 
6
+ extend CamaleonCms::NormalizeAttrs
7
+
6
8
  self.table_name = "#{PluginRoutes.static_system_info['db_prefix']}comments"
7
9
  # attr_accessible :user_id, :post_id, :content, :author, :author_email, :author_url, :author_IP, :approved, :agent, :agent, :typee, :comment_parent, :is_anonymous
8
10
  attr_accessor :is_anonymous
@@ -21,6 +23,8 @@ module CamaleonCms
21
23
  scope :comment_parent, -> { where(comment_parent: 'is not null') }
22
24
  scope :approveds, -> { where(approved: 'approved') }
23
25
 
26
+ normalize_attrs(:content)
27
+
24
28
  validates :content, presence: true
25
29
  validates_presence_of :author, :author_email, if: proc { |c| c.is_anonymous.present? }
26
30
  after_create :update_counter
@@ -179,7 +179,7 @@ module CamaleonCms
179
179
 
180
180
  # destroy all custom field groups assigned to this post type
181
181
  def destroy_field_groups
182
- if !destroyed_by_association.present? && (slug == 'post' || slug == 'page')
182
+ if !destroyed_by_association.present? && %w[post page].include?(slug)
183
183
  errors.add(:base, 'This post type can not be deleted.')
184
184
  return false
185
185
  end
@@ -3,11 +3,7 @@ module CamaleonCms
3
3
  include CamaleonCms::Metas
4
4
  include CamaleonCms::CustomFieldsRead
5
5
 
6
- TRANSLATION_TAG_HIDE_MAP = { '<!--' => '!--', '-->' => '--!' }.freeze
7
- TRANSLATION_TAG_HIDE_REGEX = Regexp.new(TRANSLATION_TAG_HIDE_MAP.keys.map { |x| Regexp.escape(x) }.join('|')).freeze
8
- TRANSLATION_TAG_RESTORE_MAP = { '--!' => '-->', '!--' => '<!--' }.freeze
9
- TRANSLATION_TAG_RESTORE_REGEX =
10
- Regexp.new(TRANSLATION_TAG_RESTORE_MAP.keys.map { |x| Regexp.escape(x) }.join('|')).freeze
6
+ extend CamaleonCms::NormalizeAttrs
11
7
 
12
8
  def self.inherited(subclass)
13
9
  super
@@ -22,23 +18,7 @@ module CamaleonCms
22
18
  # attr_accessible :data_options
23
19
  # attr_accessible :data_metas
24
20
 
25
- # TODO: Remove the 1st branch when support will be dropped of Rails < 7.1
26
- if ::Rails::VERSION::STRING < '7.1.0'
27
- before_validation(on: %i[create update]) do
28
- %i[name description].each do |attr|
29
- next unless new_record? || attribute_changed?(attr)
30
-
31
- self[attr] = ActionController::Base.helpers.sanitize(
32
- __send__(attr)&.gsub(TRANSLATION_TAG_HIDE_REGEX, TRANSLATION_TAG_HIDE_MAP)
33
- )&.gsub(TRANSLATION_TAG_RESTORE_REGEX, TRANSLATION_TAG_RESTORE_MAP)
34
- end
35
- end
36
- else
37
- normalizes :name, :description, with: lambda { |field|
38
- ActionController::Base.helpers.sanitize(field.gsub(TRANSLATION_TAG_HIDE_REGEX, TRANSLATION_TAG_HIDE_MAP))
39
- .gsub(TRANSLATION_TAG_RESTORE_REGEX, TRANSLATION_TAG_RESTORE_MAP)
40
- }
41
- end
21
+ normalize_attrs(:name, :description)
42
22
 
43
23
  # callbacks
44
24
  before_validation :before_validating
@@ -1,6 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class CamaleonRecord < ActiveRecord::Base
4
+ TRANSLATION_TAG_HIDE_MAP = { '<!--' => '!--', '-->' => '--!' }.freeze
5
+ TRANSLATION_TAG_HIDE_REGEX = Regexp.new(TRANSLATION_TAG_HIDE_MAP.keys.map { |x| Regexp.escape(x) }.join('|')).freeze
6
+ TRANSLATION_TAG_RESTORE_MAP = { '--!' => '-->', '!--' => '<!--' }.freeze
7
+ TRANSLATION_TAG_RESTORE_REGEX =
8
+ Regexp.new(TRANSLATION_TAG_RESTORE_MAP.keys.map { |x| Regexp.escape(x) }.join('|')).freeze
9
+
4
10
  include ActiveRecordExtras::Relation
5
11
 
6
12
  self.abstract_class = true
@@ -95,9 +95,7 @@ module CamaleonCms
95
95
  f.custom_field_slug == _key && f.group_number == group_number
96
96
  end.map(&:value)
97
97
  else
98
- custom_field_values.where(
99
- custom_field_slug: _key, group_number: group_number
100
- ).pluck(:value)
98
+ custom_field_values.where(custom_field_slug: _key, group_number: group_number).pluck(:value)
101
99
  end
102
100
  end
103
101
  alias get_fields get_field_values
@@ -304,7 +302,9 @@ module CamaleonCms
304
302
  private
305
303
 
306
304
  def fix_meta_value(value)
307
- value = value.to_json if value.is_a?(Array) || value.is_a?(Hash) || value.is_a?(ActionController::Parameters)
305
+ return value.to_json if value.is_a?(ActionController::Parameters)
306
+ return JSON.fast_generate(value) if value.is_a?(Array) || value.is_a?(Hash)
307
+
308
308
  value
309
309
  end
310
310
 
@@ -19,8 +19,7 @@ module CamaleonCms
19
19
  end
20
20
 
21
21
  # return value of meta with key: key,
22
- # if meta not exist, return default
23
- # return default if meta value == ""
22
+ # if meta not exist, or its value == "", return default
24
23
  def get_meta(key, default = nil)
25
24
  key_str = key.is_a?(Symbol) ? key.to_s : key
26
25
  cama_fetch_cache("meta_#{key_str}") do
@@ -70,8 +69,7 @@ module CamaleonCms
70
69
 
71
70
  # return configuration for current object
72
71
  # key: attribute name
73
- # default: if attribute not exist, return default
74
- # return default if option value == ""
72
+ # default: if the attribute doesn't exist, or its value == "", return default
75
73
  # return value for attribute
76
74
  def get_option(key = nil, default = nil, meta_key = '_default')
77
75
  values = cama_options(meta_key)
@@ -133,8 +131,14 @@ module CamaleonCms
133
131
 
134
132
  # fix to parse value
135
133
  def fix_meta_value(value)
136
- value = value.to_json if value.is_a?(Array) || value.is_a?(Hash) || value.is_a?(ActionController::Parameters)
137
- fix_meta_var(value)
134
+ changed_value = if value.is_a?(ActionController::Parameters)
135
+ value.to_json
136
+ elsif value.is_a?(Array) || value.is_a?(Hash)
137
+ JSON.fast_generate(value)
138
+ else
139
+ value
140
+ end
141
+ fix_meta_var(changed_value)
138
142
  end
139
143
 
140
144
  # fix to detect type of the variable
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CamaleonCms
4
+ module NormalizeAttrs
5
+ def normalize_attrs(*args)
6
+ # TODO: Remove the 1st branch when support will be dropped of Rails < 7.1
7
+ if ::Rails::VERSION::STRING < '7.1.0'
8
+ before_validation(on: %i[create update]) do
9
+ args.each do |attr|
10
+ next unless new_record? || attribute_changed?(attr)
11
+
12
+ self[attr] = ActionController::Base.helpers.sanitize(
13
+ __send__(attr)&.gsub(CamaleonRecord::TRANSLATION_TAG_HIDE_REGEX, CamaleonRecord::TRANSLATION_TAG_HIDE_MAP)
14
+ )&.gsub(CamaleonRecord::TRANSLATION_TAG_RESTORE_REGEX, CamaleonRecord::TRANSLATION_TAG_RESTORE_MAP)
15
+ end
16
+ end
17
+ else
18
+ normalizes(*args, with: lambda { |field|
19
+ ActionController::Base.helpers.sanitize(
20
+ field.gsub(CamaleonRecord::TRANSLATION_TAG_HIDE_REGEX, CamaleonRecord::TRANSLATION_TAG_HIDE_MAP)
21
+ ).gsub(CamaleonRecord::TRANSLATION_TAG_RESTORE_REGEX, CamaleonRecord::TRANSLATION_TAG_RESTORE_MAP)
22
+ })
23
+ end
24
+ end
25
+ end
26
+ end
@@ -6,17 +6,21 @@ module CamaleonCms
6
6
  include CamaleonCms::CustomFieldsRead
7
7
  include CamaleonCms::CommonRelationships
8
8
 
9
+ extend CamaleonCms::NormalizeAttrs
10
+
9
11
  validates_uniqueness_of :username, scope: [:site_id], case_sensitive: false,
10
12
  message: I18n.t('camaleon_cms.admin.users.message.requires_different_username', default: 'Requires different username')
11
13
  validates_uniqueness_of :email, scope: [:site_id], case_sensitive: false,
12
14
  message: I18n.t('camaleon_cms.admin.users.message.requires_different_email', default: 'Requires different email')
13
15
 
16
+ normalize_attrs(:first_name, :last_name, :username)
17
+
14
18
  # callbacks
15
19
  before_validation :cama_before_validation
16
20
  before_destroy :reassign_posts
17
21
  after_destroy :reassign_comments
18
22
  before_create { generate_token(:auth_token) }
19
- # invaliidate sessions when changing password
23
+ # invalidate sessions when changing password
20
24
  before_update { generate_token :auth_token if will_save_change_to_password_digest? }
21
25
 
22
26
  # relations
@@ -117,7 +121,7 @@ module CamaleonCms
117
121
 
118
122
  # reassign all posts of this user to first admin
119
123
  # reassign all comments of this user to first admin
120
- # if doesn't exist any other administrator, this will cancel the user destroy
124
+ # if it doesn't exist any other administrator, this will cancel the user destroy
121
125
  def reassign_posts
122
126
  all_posts.each do |p|
123
127
  s = p.post_type.site
@@ -28,10 +28,11 @@ module CamaleonCms
28
28
  end
29
29
 
30
30
  # avoid recursive page parent
31
- if record.post_parent.present? && ptype.manage_hierarchy? && record.parents.cama_pluck(:id).include?(record.id)
32
- record.errors[:base] << I18n.t('camaleon_cms.admin.post.message.recursive_hierarchy',
33
- default: 'Parent Post Recursive')
34
- end
31
+ return unless record.post_parent.present? && ptype.manage_hierarchy? &&
32
+ record.parents.cama_pluck(:id).include?(record.id)
33
+
34
+ record.errors[:base] << I18n.t('camaleon_cms.admin.post.message.recursive_hierarchy',
35
+ default: 'Parent Post Recursive')
35
36
  end
36
37
  end
37
38
  end
@@ -126,7 +126,11 @@
126
126
  <div class="panel-body padding-0">
127
127
  <% fields = @field_group.new_record? ? [] : @field_group.fields %>
128
128
  <ul id="sortable-fields" class="clear list-unstyled">
129
- <% fields.each do |field| @item_value = field; @item_options_value = field.options; @key = field.options[:field_key] %>
129
+ <% fields.each do |field|
130
+ @item_value = field
131
+ @item_options_value = field.options
132
+ @key = field.options['field_key']
133
+ %>
130
134
  <li class="item">
131
135
  <%= render "get_items" %>
132
136
  </li>
@@ -162,6 +166,3 @@
162
166
  <% end %>
163
167
  </div>
164
168
  </div>
165
-
166
-
167
-
@@ -1,3 +1,3 @@
1
1
  module CamaleonCms
2
- VERSION = '2.9.0'.freeze
2
+ VERSION = '2.9.1'.freeze
3
3
  end
data/lib/plugin_routes.rb CHANGED
@@ -275,7 +275,7 @@ class PluginRoutes
275
275
 
276
276
  def self.cache_variable(var_name, value = nil)
277
277
  @@_vars.push(var_name).uniq!
278
- # if Rails.env != "development" # disable cache plugin routes for develoment mode
278
+ # if Rails.env != "development" # disable cache plugin routes for development mode
279
279
  cache = begin
280
280
  class_variable_get("@@cache_#{var_name}")
281
281
  rescue StandardError
@@ -376,9 +376,9 @@ class PluginRoutes
376
376
  return r unless r.nil? || r == []
377
377
 
378
378
  res = get_gem_themes
379
- entries = ['.', '..']
379
+ entries = %w[. ..]
380
380
  res.each { |theme| entries << theme['key'] }
381
- (Dir["#{apps_dir}/themes/*"]).each do |path|
381
+ Dir["#{apps_dir}/themes/*"].each do |path|
382
382
  entry = path.split('/').last
383
383
  config = File.join(path, 'config', 'config.json')
384
384
  next if entries.include?(entry) || !File.directory?(path) || !File.exist?(config)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camaleon_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen Peredo Diaz
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-01-06 00:00:00.000000000 Z
10
+ date: 2025-03-15 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: addressable
@@ -805,6 +804,7 @@ files:
805
804
  - app/models/concerns/camaleon_cms/common_relationships.rb
806
805
  - app/models/concerns/camaleon_cms/custom_fields_read.rb
807
806
  - app/models/concerns/camaleon_cms/metas.rb
807
+ - app/models/concerns/camaleon_cms/normalize_attrs.rb
808
808
  - app/models/concerns/camaleon_cms/site_default_settings.rb
809
809
  - app/models/concerns/camaleon_cms/user_methods.rb
810
810
  - app/models/plugins.rb
@@ -1134,7 +1134,6 @@ homepage: https://camaleon.website
1134
1134
  licenses:
1135
1135
  - MIT
1136
1136
  metadata: {}
1137
- post_install_message:
1138
1137
  rdoc_options: []
1139
1138
  require_paths:
1140
1139
  - lib
@@ -1152,8 +1151,7 @@ requirements:
1152
1151
  - rails >= 6.1
1153
1152
  - ruby >= 3.0
1154
1153
  - imagemagick
1155
- rubygems_version: 3.5.17
1156
- signing_key:
1154
+ rubygems_version: 3.6.5
1157
1155
  specification_version: 4
1158
1156
  summary: Camaleon is a CMS for Ruby on Rails as an alternative to Wordpress.
1159
1157
  test_files: []