trusty-cms 4.3.5 → 5.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93c5757a5dcb67c36520c6ddb0cd237065fb7030fc7f2cd2f2e07f63a78224c4
4
- data.tar.gz: c44066af31851544cba8ae7ed6d055b59d10a1d84cc3836f1168ebd817853dfb
3
+ metadata.gz: b683c80ebc89ff905a7109aa4836ad1e99a614b551b012992d6f6718d83fac41
4
+ data.tar.gz: 4f635bce370c9b018a5f26049dc7a28663ed64a016d157433af852bcc5f820f0
5
5
  SHA512:
6
- metadata.gz: e37967a7f2db311cf7144e90da17c5c3f0ad4e5ab8bd3eefabbeb3cc86204bbe04975b1e9e6de09daf8f4e0eeb13640982f5205440d6874488f25f365ab97c77
7
- data.tar.gz: cf4e4e7fd6d0a475cd4f704ee607abef8d83b935bdf161b3d0e61c9e66112d40c14d58a92395021b7867ad206061a27497482bb9c0c3cebc4897b5e64d1559ef
6
+ metadata.gz: af1d39761010c6f93929e489063451ec387454c462fd5f772e3d5a4713648bb48170b1125e657f39db3aed76fa470513b8fd49b8e184d2e0e7bb5fcb05908791
7
+ data.tar.gz: e599713e206e28967ff7395a15d22eba36b68375d23a6168e31df56d55af7673a018b472100b4aa60f71197d375507ab17bf1bc5d98ef54f15f781d7dcdf4e7b
data/Gemfile CHANGED
@@ -12,10 +12,11 @@ gem 'trustygems', '~> 0.2.0'
12
12
  gemspec
13
13
 
14
14
  group :development, :test do
15
+ gem 'activestorage-validator'
15
16
  gem 'acts_as_list'
16
17
  gem 'database_cleaner'
17
18
  gem 'factory_bot_rails', '6.2.0'
18
- gem 'kt-paperclip', '~> 7.0.0'
19
+ gem 'file_validators'
19
20
  gem 'launchy', '~> 2.5.0'
20
21
  gem 'mysql2'
21
22
  gem 'poltergeist', '~> 1.18.1'
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trusty-cms (4.3.5)
4
+ trusty-cms (5.0.3)
5
5
  RedCloth (= 4.3.2)
6
+ activestorage-validator
6
7
  acts_as_list (>= 0.9.5, < 1.1.0)
7
8
  acts_as_tree (~> 2.9.1)
8
9
  ckeditor (>= 4.2.2, < 4.4.0)
@@ -12,6 +13,7 @@ PATH
12
13
  haml
13
14
  haml-rails (~> 2.0)
14
15
  highline (>= 1.7.8, < 2.1.0)
16
+ image_processing
15
17
  kraken-io
16
18
  mini_racer
17
19
  mysql2
@@ -86,6 +88,8 @@ GEM
86
88
  activesupport (= 6.1.4.1)
87
89
  marcel (~> 1.0.0)
88
90
  mini_mime (>= 1.1.0)
91
+ activestorage-validator (0.1.4)
92
+ rails (>= 5.2.0)
89
93
  activesupport (6.1.4.1)
90
94
  concurrent-ruby (~> 1.0, >= 1.0.2)
91
95
  i18n (>= 1.6, < 2)
@@ -144,6 +148,9 @@ GEM
144
148
  factory_bot (~> 6.2.0)
145
149
  railties (>= 5.0.0)
146
150
  ffi (1.15.4)
151
+ file_validators (3.0.0)
152
+ activemodel (>= 3.2)
153
+ mime-types (>= 1.0)
147
154
  globalid (0.5.2)
148
155
  activesupport (>= 5.0)
149
156
  haml (5.2.2)
@@ -166,18 +173,15 @@ GEM
166
173
  multi_xml (>= 0.5.2)
167
174
  i18n (1.8.10)
168
175
  concurrent-ruby (~> 1.0)
169
- json (2.5.1)
176
+ image_processing (1.12.1)
177
+ mini_magick (>= 4.9.5, < 5)
178
+ ruby-vips (>= 2.0.17, < 3)
179
+ json (2.6.1)
170
180
  kraken-io (0.1.3)
171
181
  activesupport
172
182
  httparty
173
183
  json
174
184
  multipart-post
175
- kt-paperclip (7.0.0)
176
- activemodel (>= 4.2.0)
177
- activesupport (>= 4.2.0)
178
- marcel (~> 1.0.1)
179
- mime-types
180
- terrapin (~> 0.6.0)
181
185
  launchy (2.5.0)
182
186
  addressable (~> 2.7)
183
187
  libv8-node (15.14.0.1-x86_64-darwin-18)
@@ -188,11 +192,12 @@ GEM
188
192
  nokogiri (>= 1.5.9)
189
193
  mail (2.7.1)
190
194
  mini_mime (>= 0.1.1)
191
- marcel (1.0.1)
195
+ marcel (1.0.2)
192
196
  method_source (1.0.0)
193
197
  mime-types (3.3.1)
194
198
  mime-types-data (~> 3.2015)
195
199
  mime-types-data (3.2021.0225)
200
+ mini_magick (4.11.0)
196
201
  mini_mime (1.1.1)
197
202
  mini_racer (0.4.0)
198
203
  libv8-node (~> 15.14.0.0)
@@ -281,6 +286,8 @@ GEM
281
286
  rspec-mocks (~> 3.10)
282
287
  rspec-support (~> 3.10)
283
288
  rspec-support (3.10.2)
289
+ ruby-vips (2.1.3)
290
+ ffi (~> 1.12)
284
291
  ruby_parser (3.17.0)
285
292
  sexp_processor (~> 4.15, >= 4.15.1)
286
293
  sass-rails (6.0.0)
@@ -336,10 +343,11 @@ PLATFORMS
336
343
  x86_64-linux
337
344
 
338
345
  DEPENDENCIES
346
+ activestorage-validator
339
347
  acts_as_list
340
348
  database_cleaner
341
349
  factory_bot_rails (= 6.2.0)
342
- kt-paperclip (~> 7.0.0)
350
+ file_validators
343
351
  launchy (~> 2.5.0)
344
352
  mysql2
345
353
  poltergeist (~> 1.18.1)
@@ -6,6 +6,7 @@ main {
6
6
 
7
7
  .reversed main {
8
8
  .content {
9
+ line-height: 1.5;
9
10
  padding: 1em;
10
11
  }
11
12
  }
@@ -1,6 +1,9 @@
1
1
  class Admin::AssetsController < Admin::ResourceController
2
2
  paginate_models(per_page: 50)
3
3
  COMPRESS_FILE_TYPE = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'].freeze
4
+ before_action do
5
+ ActiveStorage::Current.host = request.base_url
6
+ end
4
7
 
5
8
  def index
6
9
  assets = Asset.order('created_at DESC')
@@ -67,6 +70,7 @@ class Admin::AssetsController < Admin::ResourceController
67
70
  private
68
71
 
69
72
  def compress(uploaded_asset)
73
+ require 'open-uri'
70
74
  data = $kraken.upload(uploaded_asset.tempfile.path, 'lossy' => true)
71
75
  File.write(uploaded_asset.tempfile, URI.open(data.kraked_url).read, mode: 'wb')
72
76
  uploaded_asset
@@ -81,4 +85,4 @@ class Admin::AssetsController < Admin::ResourceController
81
85
  def asset_params
82
86
  params.permit(:id, :for_attachment, asset: [:caption, :for_attachment, asset: []])
83
87
  end
84
- end
88
+ end
data/app/models/asset.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  class Asset < ActiveRecord::Base
2
- include Paperclip::Glue
3
-
4
2
  has_many :page_attachments, dependent: :destroy
5
3
  has_many :pages, through: :page_attachments
6
4
  has_site if respond_to? :has_site
@@ -33,52 +31,43 @@ class Asset < ActiveRecord::Base
33
31
  end
34
32
  }
35
33
 
36
- has_attached_file :asset,
37
- styles: lambda { |attachment|
38
- AssetType.for(attachment).paperclip_styles
39
- },
40
- processors: lambda { |asset|
41
- asset.paperclip_processors
42
- },
43
- whiny: false,
44
- storage: TrustyCms.config['paperclip.storage'],
45
- path: TrustyCms.config['paperclip.path'],
46
- url: TrustyCms.config['paperclip.url'],
47
- fog_credentials: TrustyCmsClippedExtension::Cloud.credentials,
48
- fog_directory: TrustyCms.config['paperclip.fog.directory'],
49
- fog_public: TrustyCms.config['paperclip.fog.public?'] || true,
50
- fog_host: TrustyCmsClippedExtension::Cloud.host,
51
- fog_file: {
52
- 'Cache-Control' => 'max-age=31536000',
53
- }
54
-
55
- validates_attachment_content_type :asset, content_type: ['application/zip', 'image/jpg', 'image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/javascript', 'text/javascript', 'text/css']
56
-
34
+ has_one_attached :asset
35
+ validates :asset,
36
+ presence: true,
37
+ blob:
38
+ {
39
+ content_type: %w[application/zip image/jpg image/jpeg image/png image/gif application/pdf text/css],
40
+ size_range: 1..5.megabytes,
41
+ }
57
42
  before_save :assign_title
58
43
  before_save :assign_uuid
59
44
 
60
- after_post_process :read_dimensions
61
-
62
- validates_attachment_presence :asset, message: 'You must choose a file to upload!'
63
- if TrustyCms.config['paperclip.skip_filetype_validation'] != 'true' && TrustyCms.config['paperclip.content_types']
64
- validates_attachment_content_type :asset, content_type: TrustyCms.config['paperclip.content_types'].gsub(' ', '').split(',')
65
- else
66
- validates_attachment_presence :asset, message: 'Your uploaded file must have an extension in its name!'
67
- end
68
- validates_attachment_size :asset, less_than: (TrustyCms.config['assets.max_asset_size'] || 5).to_i.megabytes
69
-
70
45
  def asset_type
71
46
  AssetType.for(asset)
72
47
  end
73
- delegate :paperclip_processors, :paperclip_styles, :style_dimensions, :style_format, to: :asset_type
48
+ delegate :paperclip_processors, :paperclip_styles, :active_storage_styles, :style_dimensions, :style_format,
49
+ to: :asset_type
74
50
 
75
51
  def thumbnail(style_name = 'original')
76
- return asset.url if style_name.to_sym == :original
77
- return asset.url(style_name.to_sym) if style?(style_name)
52
+ return asset.url if style_name == 'original'
53
+ return asset_variant(style_name).processed.url if asset.variable?
78
54
 
79
55
  asset_type.icon(style_name)
80
56
  end
81
57
 
58
+ def asset_variant(style_name)
59
+ case style_name.to_s
60
+ when 'thumbnail'
61
+ asset.variant(gravity: 'Center', resize: '100x100^', crop: '100x100+0+0')
62
+ when 'normal'
63
+ asset.variant(gravity: 'Center', resize: '640x640^')
64
+ when 'small'
65
+ asset.variant(gravity: 'Center', resize: '320x320^')
66
+ when 'icon'
67
+ asset.variant(gravity: 'Center', resize: '50x50^')
68
+ end
69
+ end
70
+
82
71
  def style?(style_name = 'original')
83
72
  style_name == 'original' || paperclip_styles.keys.include?(style_name.to_sym)
84
73
  end
@@ -110,7 +99,10 @@ class Asset < ActiveRecord::Base
110
99
  end
111
100
 
112
101
  def geometry(style_name = 'original')
113
- raise Paperclip::StyleError, "Requested style #{style_name} is not defined for this asset." unless style?(style_name)
102
+ unless style?(style_name)
103
+ raise Paperclip::StyleError,
104
+ "Requested style #{style_name} is not defined for this asset."
105
+ end
114
106
 
115
107
  @geometry ||= {}
116
108
  begin
@@ -118,8 +110,9 @@ class Asset < ActiveRecord::Base
118
110
  original_geometry
119
111
  else
120
112
  style = asset.styles[style_name.to_sym]
121
- original_geometry.transformed_by(style.geometry) # this can return dimensions for fully specified style sizes but not for relative sizes when there are no original dimensions
122
- end
113
+ original_geometry.transformed_by(style.geometry)
114
+ # this can return dimensions for fully specified style sizes but not for relative sizes when there are no original dimensions
115
+ end
123
116
  rescue Paperclip::TransformationError => e
124
117
  Rails.logger.warn "geometry transformation error: #{e}"
125
118
  original_geometry # returns a blank geometry if the real geometry cannot be calculated
@@ -174,19 +167,17 @@ class Asset < ActiveRecord::Base
174
167
  # original file and calculate thumbnail dimensions later, on demand.
175
168
 
176
169
  def read_dimensions
177
- if image?
178
- if file = asset.queued_for_write[:original]
179
- geometry = Paperclip::Geometry.from_file(file)
180
- self.original_width = geometry.width
181
- self.original_height = geometry.height
182
- self.original_extension = File.extname(file.path)
183
- end
170
+ if image? && file = asset.queued_for_write[:original]
171
+ geometry = Paperclip::Geometry.from_file(file)
172
+ self.original_width = geometry.width
173
+ self.original_height = geometry.height
174
+ self.original_extension = File.extname(file.path)
184
175
  end
185
176
  true
186
177
  end
187
178
 
188
179
  def assign_title
189
- self.title = asset_file_name.downcase.sub(original_extension, '').sub('.', '')
180
+ self.title = asset.filename.base
190
181
  end
191
182
 
192
183
  def assign_uuid
@@ -235,7 +226,7 @@ class Asset < ActiveRecord::Base
235
226
 
236
227
  # this is a convenience for image-pickers
237
228
  def self.thumbnail_options
238
- asset_sizes = thumbnail_sizes.collect do |k, v|
229
+ asset_sizes = thumbnail_sizes.map do |k, v|
239
230
  size_id = k
240
231
  size_description = "#{k}: "
241
232
  size_description << (v.is_a?(Array) ? v.join(' as ') : v)
@@ -104,6 +104,10 @@ class AssetType
104
104
  @paperclip_styles
105
105
  end
106
106
 
107
+ def active_storage_styles
108
+ @active_storage_styles ||= normalize_style_rules(configured_styles.merge(styles))
109
+ end
110
+
107
111
  # Takes a motley collection of differently-defined styles and renders them into the standard hash-of-hashes format.
108
112
  # Solitary strings are assumed to be #
109
113
  def normalize_style_rules(styles = {})
@@ -173,8 +177,8 @@ class AssetType
173
177
  # class methods
174
178
 
175
179
  def self.for(attachment)
176
- extension = File.extname(attachment.original_filename).sub(/^\.+/, '')
177
- from_extension(extension) || from_mimetype(attachment.instance_read(:content_type)) || catchall
180
+ extension = attachment.record.original_extension
181
+ from_extension(extension) || from_mimetype(attachment.content_type) || catchall
178
182
  end
179
183
 
180
184
  def self.from_extension(extension)
@@ -16,10 +16,12 @@
16
16
  = "#{t("clipped_extension.filename")}: #{@asset.asset_file_name unless @asset.new_record?}"
17
17
  %br
18
18
  %label.url
19
- = "#{t("clipped_extension.asset_url")}: #{image_path @asset.thumbnail unless @asset.new_record?}"
19
+ = "#{t("clipped_extension.asset_url")}: #{image_path @asset.asset.url unless @asset.new_record?}"
20
+ %br
21
+ %label.id
22
+ = "#{t("clipped_extension.asset_id")}: #{@asset.id unless @asset.new_record?}"
20
23
  %p.asset
21
- - display_size = TrustyCms::config['assets.display_size'] || 'normal'
22
- = image_tag @asset.thumbnail(display_size.to_sym), :class => 'preview'
24
+ = image_tag @asset.thumbnail("normal"), :class => 'preview'
23
25
 
24
26
  = updated_stamp @asset
25
27
 
@@ -66,6 +66,7 @@ en:
66
66
  asset_page_attachment_note: 'Attached assets. These can be inserted with drag and drop or shown with the <code>&lt;r:assets:each /&gt;</code> tag.'
67
67
  asset_note: 'Attached assets. '
68
68
  asset_url: 'Asset URL'
69
+ asset_id: 'Asset ID'
69
70
  assets: 'Assets'
70
71
  assets_explanation: 'Assets and images can be uploaded and then attached or inserted into pages, snippets and layouts. Click on an asset name above to edit it or click <code>Remove</code> to delete it.'
71
72
  assets_title: 'Assets'
data/lib/trusty_cms.rb CHANGED
@@ -2,6 +2,6 @@ TRUSTY_CMS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) unle
2
2
 
3
3
  unless defined? TrustyCms::VERSION
4
4
  module TrustyCms
5
- VERSION = '4.3.5'.freeze
5
+ VERSION = '5.0.3'.freeze
6
6
  end
7
7
  end
data/trusty_cms.gemspec CHANGED
@@ -23,7 +23,7 @@ a general purpose content managment system--not merely a blogging engine.'
23
23
  s.summary = 'A no-fluff content management system designed for small teams.'
24
24
  s.license = 'MIT'
25
25
  s.test_files = Dir['spec/**/*']
26
-
26
+ s.add_dependency 'activestorage-validator'
27
27
  s.add_dependency 'acts_as_list', '>= 0.9.5', '< 1.1.0'
28
28
  s.add_dependency 'acts_as_tree', '~> 2.9.1'
29
29
  s.add_dependency 'ckeditor', '>= 4.2.2', '< 4.4.0'
@@ -33,6 +33,7 @@ a general purpose content managment system--not merely a blogging engine.'
33
33
  s.add_dependency 'haml'
34
34
  s.add_dependency 'haml-rails', '~> 2.0'
35
35
  s.add_dependency 'highline', '>= 1.7.8', '< 2.1.0'
36
+ s.add_dependency 'image_processing'
36
37
  s.add_dependency 'kraken-io'
37
38
  s.add_dependency 'mini_racer'
38
39
  s.add_dependency 'mysql2'
@@ -1,7 +1,7 @@
1
1
  require 'acts_as_list'
2
2
  require 'uuidtools'
3
3
  require 'trusty_cms_clipped_extension/cloud'
4
- require 'paperclip'
4
+ require 'active_storage/engine'
5
5
  require 'will_paginate/array'
6
6
  module Clipped
7
7
  class Engine < Rails::Engine
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trusty-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.5
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TrustyCms CMS dev team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-05 00:00:00.000000000 Z
11
+ date: 2021-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activestorage-validator
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: acts_as_list
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -160,6 +174,20 @@ dependencies:
160
174
  - - "<"
161
175
  - !ruby/object:Gem::Version
162
176
  version: 2.1.0
177
+ - !ruby/object:Gem::Dependency
178
+ name: image_processing
179
+ requirement: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ type: :runtime
185
+ prerelease: false
186
+ version_requirements: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
163
191
  - !ruby/object:Gem::Dependency
164
192
  name: kraken-io
165
193
  requirement: !ruby/object:Gem::Requirement
@@ -793,7 +821,6 @@ files:
793
821
  - config/initializers/active_record_extensions.rb
794
822
  - config/initializers/assets.rb
795
823
  - config/initializers/devise.rb
796
- - config/initializers/interpolation.rb
797
824
  - config/initializers/kraken.rb
798
825
  - config/initializers/response_cache_timeout.rb
799
826
  - config/initializers/secret_token.rb
@@ -8541,7 +8568,6 @@ files:
8541
8568
  - spec/rails_helper.rb
8542
8569
  - spec/spec_helper.rb
8543
8570
  - spec/support/custom_actions.rb
8544
- - trusty-cms-5.0.0.gem
8545
8571
  - trusty_cms.gemspec
8546
8572
  - vendor/extensions/clipped-extension/clipped_extension.rb
8547
8573
  - vendor/extensions/clipped-extension/lib/admin/assets_helper.rb
@@ -1,6 +0,0 @@
1
- require 'paperclip'
2
-
3
- Paperclip.interpolates :no_original_style do |attachment, style|
4
- style ||= :original
5
- style == attachment.default_style ? nil : "_#{style}"
6
- end
data/trusty-cms-5.0.0.gem DELETED
Binary file