camaleon_cms 2.4.3.6 → 2.4.3.7

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
  SHA1:
3
- metadata.gz: 6b264403b317f1fc7b159a14442421358ab80d98
4
- data.tar.gz: bd2ddf3797fc12138f8d0080767ae8517af75e36
3
+ metadata.gz: 7211d3c4b0a45a1e8c6e20353c5b4a3e6b20c932
4
+ data.tar.gz: 31360da64495b452335257449ba260957653e490
5
5
  SHA512:
6
- metadata.gz: 7e739c3983fb4c3cb399f1c53ac56505821fb810468af2e014c8e413d0be7f9362a8b0a18c02d73a2691ba8fd75522b1dd45909fb5dda600a1f3e6cfc87d75fc
7
- data.tar.gz: b668dba2056ce6b4daa25b149a876316f0143e8c15a98730ab6b255b966d9488cea61d09629b1436378896e65a317cd4e1c23c071152ed5e6eb3e350fb862479
6
+ metadata.gz: 5c5b33713850f460ceb5b5f21746c824428e9c98077f10d7c7bc9f2e79c192f5de988aaa5b1e51787b8996141cfa59d9aba5a382b22db7cbf50a71d6eedcfabc
7
+ data.tar.gz: 88e17d34d9454683c2e5c2e3e63b37fe0fab01effad9eb8b01499a938333e00b751c1f1dc219a490624e686d4aef6b64d8f7931392f093d0888bd8d7318a9f59
data/README.md CHANGED
@@ -39,7 +39,7 @@
39
39
  * Add the gem in your Gemfile
40
40
 
41
41
  ```
42
- gem "camaleon_cms", '>= 2.4.3.5' # Stable versions 2.4.3.2, 2.3.6, 2.2.1, 2.1.1, 2.1.0
42
+ gem "camaleon_cms", '>= 2.4.3.6' # Stable versions 2.4.3.5, 2.4.3.2, 2.3.6, 2.2.1, 2.1.1, 2.1.0
43
43
  # gem "camaleon_cms", github: 'owen2345/camaleon-cms' # current development version
44
44
  ```
45
45
  * Only Rails 5 support
@@ -40,7 +40,7 @@ module Plugins::Attack::AttackHelper
40
40
  def attack_app_before_load()
41
41
  cache_ban = Rails.cache.read(cama_get_session_id)
42
42
  if cache_ban.present? # render banned message if it was banned
43
- render text: cache_ban, layout: false
43
+ render html: cache_ban.html_safe, layout: false
44
44
  return
45
45
  end
46
46
 
@@ -67,7 +67,7 @@ module Plugins::Attack::AttackHelper
67
67
  if r.count > config[:post][:max].to_i
68
68
  Rails.cache.write(cama_get_session_id, config[:msg], expires_in: config[:ban].to_i.minutes)
69
69
  # send an email to administrator with request info (ip, browser, if logged then send user info
70
- render text: config[:msg]
70
+ render html: config[:msg].html_safe
71
71
  return
72
72
  end
73
73
 
@@ -76,7 +76,7 @@ module Plugins::Attack::AttackHelper
76
76
  r = q.where(created_at: config[:get][:sec].to_i.seconds.ago..Time.now)
77
77
  if r.count > config[:get][:max].to_i
78
78
  Rails.cache.write(cama_get_session_id, config[:msg], expires_in: config[:ban].to_i.minutes)
79
- render text: config[:msg]
79
+ render html: config[:msg].html_safe
80
80
  return
81
81
  end
82
82
  end
@@ -20,7 +20,11 @@ class Plugins::FrontCache::AdminController < CamaleonCms::Apps::PluginsAdminCont
20
20
  def clean_cache
21
21
  flash[:notice] = "#{t('plugin.front_cache.message.cache_destroyed')}"
22
22
  front_cache_clean()
23
- redirect_to :back
23
+ if Rails.version.to_s[0].to_i < 5
24
+ redirect_to :back
25
+ else
26
+ redirect_back(fallback_location: '/admin/plugins')
27
+ end
24
28
  end
25
29
 
26
30
  end
@@ -14,7 +14,7 @@ module Plugins::FrontCache::FrontCacheHelper
14
14
  Rails.logger.info "Camaleon CMS - readed cache: #{front_cache_plugin_get_path(cache_key)}"
15
15
  response.headers['PLUGIN_FRONT_CACHE'] = 'TRUE'
16
16
  args = {data: front_cache_get(cache_key).gsub("{{form_authenticity_token}}", form_authenticity_token)}; hooks_run('front_cache_reading_cache', args)
17
- render text: args[:data]
17
+ render html: args[:data].html_safe
18
18
  return
19
19
  end
20
20
 
@@ -126,4 +126,4 @@ module Plugins::FrontCache::FrontCacheHelper
126
126
  def front_cache_plugin_match_path_patterns?(key, key2)
127
127
  @caches[:paths].any?{|path_pattern| key =~ Regexp.new(path_pattern) || key2 =~ Regexp.new(path_pattern) }
128
128
  end
129
- end
129
+ end
@@ -19,7 +19,7 @@ class CamaleonCms::Admin::MediaController < CamaleonCms::AdminController
19
19
  crop_path = cama_crop_image(path_image, params[:ic_w], params[:ic_h], params[:ic_x], params[:ic_y])
20
20
  res = upload_file(crop_path, {remove_source: true})
21
21
  CamaleonCms::User.find(params[:saved_avatar]).set_meta('avatar', res["url"]) if params[:saved_avatar].present? # save current crop image as avatar
22
- render text: res["url"]
22
+ render html: res["url"].html_safe
23
23
  end
24
24
 
25
25
  # download private files
@@ -264,14 +264,17 @@ module CamaleonCms::UploaderHelper
264
264
  cloud_front: current_site.get_option("filesystem_s3_cloudfront"),
265
265
  aws_file_upload_settings: lambda{|settings| settings }, # permit to add your custom attributes for file_upload http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Object.html#upload_file-instance_method
266
266
  aws_file_read_settings: lambda{|data, s3_file| data } # permit to read custom attributes from aws file and add to file parsed object
267
- }
267
+ },
268
+ custom_uploader: nil # posibility to use custom file uploader
268
269
  }
269
270
  hooks_run("on_uploader", args)
271
+ return args[:custom_uploader] if args[:custom_uploader].present?
272
+
270
273
  case args[:server]
271
274
  when 's3', 'aws'
272
- CamaleonCmsAwsUploader.new({current_site: current_site, thumb: args[:thumb], aws_settings: args[:aws_settings]})
275
+ CamaleonCmsAwsUploader.new({current_site: current_site, thumb: args[:thumb], aws_settings: args[:aws_settings]}, self)
273
276
  else
274
- CamaleonCmsLocalUploader.new({current_site: current_site, thumb: args[:thumb]})
277
+ CamaleonCmsLocalUploader.new({current_site: current_site, thumb: args[:thumb]}, self)
275
278
  end
276
279
  }.call
277
280
  end
@@ -61,6 +61,12 @@ class CamaleonCmsAwsUploader < CamaleonCmsUploader
61
61
  args, res = {same_name: false, is_thumb: false}.merge(args), nil
62
62
  key = "#{@aws_settings["inner_folder"]}/#{key}" if @aws_settings["inner_folder"].present? && !args[:is_thumb]
63
63
  key = search_new_key(key) unless args[:same_name]
64
+
65
+ if @instance # private hook to upload files by different way, add file data into result_data
66
+ _args={result_data: nil, file: uploaded_io_or_file_path, key: key, args: args, klass: self}; @instance.hooks_run('uploader_aws_before_upload', _args)
67
+ return _args[:result_data] if _args[:result_data].present?
68
+ end
69
+
64
70
  s3_file = bucket.object(key.split('/').clean_empty.join('/'))
65
71
  s3_file.upload_file(uploaded_io_or_file_path.is_a?(String) ? uploaded_io_or_file_path : uploaded_io_or_file_path.path, @aws_settings[:aws_file_upload_settings].call({acl: 'public-read'}))
66
72
  res = cache_item(file_parse(s3_file)) unless args[:is_thumb]
@@ -63,6 +63,12 @@ class CamaleonCmsLocalUploader < CamaleonCmsUploader
63
63
  def add_file(uploaded_io_or_file_path, key, args = {})
64
64
  args, res = {same_name: false, is_thumb: false}.merge(args), nil
65
65
  key = search_new_key(key) unless args[:same_name]
66
+
67
+ if @instance # private hook to upload files by different way, add file data into result_data
68
+ _args={result_data: nil, file: uploaded_io_or_file_path, key: key, args: args, klass: self}; @instance.hooks_run('uploader_local_before_upload', _args)
69
+ return _args[:result_data] if _args[:result_data].present?
70
+ end
71
+
66
72
  add_folder(File.dirname(key)) if File.dirname(key).present?
67
73
  upload_io = uploaded_io_or_file_path.is_a?(String) ? File.open(uploaded_io_or_file_path) : uploaded_io_or_file_path
68
74
  File.open(File.join(@root_folder, key), 'wb'){|file| file.write(upload_io.read) }
@@ -2,12 +2,13 @@ class CamaleonCmsUploader
2
2
  attr_accessor :thumb
3
3
  # root_folder= '/var/www/my_public_foler/', current_site= CamaSite.first.decorate, thumb = {w: 100, h: 75},
4
4
  # aws_settings: {region, access_key, secret_key, bucket}
5
- def initialize(args = {})
5
+ def initialize(args = {}, instance = nil)
6
6
  @current_site = args[:current_site]
7
7
  t_w, t_h = @current_site.get_option('filesystem_thumb_size', '100x100').split('x')
8
8
  @thumb = args[:thumb] || {w: t_w, h: t_h}
9
9
  @aws_settings = args[:aws_settings] || {}
10
10
  @args = args
11
+ @instance = instance
11
12
  after_initialize
12
13
  end
13
14
 
@@ -20,9 +21,18 @@ class CamaleonCmsUploader
20
21
  # {files: {'file_name': {'name'=> 'a.jpg', key: '/test/a.jpg', url: '', url: '', size: '', format: '', thumb: 'thumb_url', type: '', created_at: '', dimension: '120x120'}}, folders: {'folder name' => {name: 'folder name', key: '/folder name', ...}}}
21
22
  # sort: (String, default 'created_at'), accept for: created_at | name | size | type | format
22
23
  def objects(prefix = '/', sort = 'created_at')
24
+ prefix = prefix.cama_fix_slash
23
25
  prefix = "/#{prefix}" unless prefix.starts_with?('/')
24
26
  db = @current_site.get_meta(cache_key, nil) || browser_files
25
- res = db[prefix.gsub('//', '/')] || {files: {}, folders: {}}
27
+ res = db[prefix] || {files: {}, folders: {}}
28
+
29
+ # Private hook to recover custom files to include in current list where data can be modified to add custom{files, folders}
30
+ # Note: this hooks doesn't have access to public vars like params. requests, ...
31
+ if @instance
32
+ args={data: res, prefix: prefix}; @instance.hooks_run('uploader_list_objects', args)
33
+ res = args[:data]
34
+ end
35
+
26
36
  res[:files] = res[:files].sort_by{|k, v| v[sort] }.reverse.to_h
27
37
  res[:folders] = res[:folders].sort_by{|k, v| v['name'] }.reverse.to_h
28
38
  res
@@ -54,8 +64,9 @@ class CamaleonCmsUploader
54
64
  # save file_parsed as a cache into DB
55
65
  # file_parsed: (HASH) File parsed object
56
66
  # objects_db: HASH Object where to add the current object (optional)
57
- def cache_item(file_parsed, _objects_db = nil)
58
- objects_db = _objects_db || @current_site.get_meta(cache_key, {}) || {}
67
+ def cache_item(file_parsed, _objects_db = nil, custom_cache_key = nil)
68
+ _cache_key = custom_cache_key || cache_key
69
+ objects_db = _objects_db || @current_site.get_meta(_cache_key, {}) || {}
59
70
  prefix = File.dirname(file_parsed['key'])
60
71
 
61
72
  s = prefix.split('/').clean_empty
@@ -68,7 +79,7 @@ class CamaleonCmsUploader
68
79
  else
69
80
  objects_db[prefix][:files][file_parsed['name']] = file_parsed
70
81
  end
71
- @current_site.set_meta(cache_key, objects_db) if _objects_db.nil?
82
+ @current_site.set_meta(_cache_key, objects_db) if _objects_db.nil?
72
83
  file_parsed
73
84
  end
74
85
 
@@ -1,3 +1,3 @@
1
1
  module CamaleonCms
2
- VERSION = '2.4.3.6'
2
+ VERSION = '2.4.3.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camaleon_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3.6
4
+ version: 2.4.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen Peredo Diaz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-06 00:00:00.000000000 Z
11
+ date: 2017-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt