alchemy_cms 5.2.5 → 5.2.6

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: 3a2b93464ba8a1fb5b20e6447d23b908e7fd59e29e028f5c4ab70f536cf87c27
4
- data.tar.gz: 77c91a87955eba711b381ea272e9bc982d3f744869cbfeefc17fb7d9be022e97
3
+ metadata.gz: 97e1ed1598e179337636198e31cf6d94b85bce3376cd1cb704e6a6e3312224b7
4
+ data.tar.gz: 2cfe0ee0fb63eddb1d5de0ac156e9f3abfcc6ac91d6652ebf8aaf80db3da6e61
5
5
  SHA512:
6
- metadata.gz: 5cb3dd94c9170ad15e0ccb1ac780f8503d27b5deb5cab962f1170f1303dc226f492bf8e8cc8e40661847e71c5349fb4bfff373094e3f04c92b43c1db2b12be6a
7
- data.tar.gz: ed77728e349bf1612ca18616e5bdaed478519e83a3d990238b0b227cf4668d3553f2bdd30856a36c490053d94c347c86e7261e309a481bbc676febad5fba4c2f
6
+ metadata.gz: 43f19d474f2e3e153af2b98d3867e7b0151f6ccc3fa4518e88f4b88055fe99cda98a11d53e668e8e5c8485ed17e4a52f0547a8e819f8475ba95c06b6de5f33c1
7
+ data.tar.gz: 641ade4c39110add57ddcf2c5a5968541ebafc953f47b9c3f10d6681cfa6d31357794df4b03d488597bc5f56b0e1696a550d57e29da170aac74946bf8b86d167
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 5.2.6 (2022-02-28)
2
+
3
+ - Add crop_resize Dragonfly processor ([tvdeyen](https://github.com/tvdeyen))
4
+
1
5
  ## 5.2.5 (2021-11-24)
2
6
 
3
7
  - Adjust tinymce skin assets urls again ([tvdeyen](https://github.com/tvdeyen))
data/alchemy_cms.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
23
23
  gem.add_runtime_dependency 'awesome_nested_set', ['~> 3.1']
24
24
  gem.add_runtime_dependency 'cancancan', ['>= 2.1', '< 4.0']
25
25
  gem.add_runtime_dependency 'coffee-rails', ['>= 4.0', '< 6.0']
26
- gem.add_runtime_dependency 'dragonfly', ['~> 1.0', '>= 1.0.7', '< 1.4']
26
+ gem.add_runtime_dependency 'dragonfly', ['~> 1.4']
27
27
  gem.add_runtime_dependency 'dragonfly_svg', ['~> 0.0.4']
28
28
  gem.add_runtime_dependency 'gutentag', ['~> 2.2', '>= 2.2.1']
29
29
  gem.add_runtime_dependency 'handlebars_assets', ['~> 0.23']
@@ -40,9 +40,7 @@ module Alchemy
40
40
  def exception_handler(error)
41
41
  exception_logger(error)
42
42
  show_error_notice(error)
43
- if defined?(Airbrake)
44
- notify_airbrake(error) unless Rails.env.development? || Rails.env.test?
45
- end
43
+ notify_error_tracker(error)
46
44
  end
47
45
 
48
46
  # Displays an error notice in the Alchemy backend.
@@ -148,6 +146,14 @@ module Alchemy
148
146
  site
149
147
  end
150
148
  end
149
+
150
+ def notify_error_tracker(exception)
151
+ if ::Alchemy::ErrorTracking.notification_handler.respond_to?(:call)
152
+ ::Alchemy::ErrorTracking.notification_handler.call(exception)
153
+ else
154
+ Rails.logger.warn("To use the Alchemy::ErrorTracking.notification_handler, it must respond to #call.")
155
+ end
156
+ end
151
157
  end
152
158
  end
153
159
  end
@@ -197,12 +197,12 @@ module Alchemy
197
197
  # Use imagemagick to custom crop an image. Uses -thumbnail for better performance when resizing.
198
198
  #
199
199
  def xy_crop_resize(dimensions, top_left, crop_dimensions, upsample)
200
- crop_argument = "-crop #{dimensions_to_string(crop_dimensions)}"
200
+ crop_argument = dimensions_to_string(crop_dimensions)
201
201
  crop_argument += "+#{top_left[:x]}+#{top_left[:y]}"
202
202
 
203
- resize_argument = "-resize #{dimensions_to_string(dimensions)}"
203
+ resize_argument = dimensions_to_string(dimensions)
204
204
  resize_argument += ">" unless upsample
205
- image_file.convert "#{crop_argument} #{resize_argument}"
205
+ image_file.crop_resize(crop_argument, resize_argument)
206
206
  end
207
207
 
208
208
  # Used when centercropping.
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require "dragonfly_svg"
3
+ require "alchemy/dragonfly/processors/crop_resize"
3
4
 
4
5
  # Logger
5
6
  Dragonfly.logger = Rails.logger
@@ -9,3 +10,10 @@ if defined?(ActiveRecord::Base)
9
10
  ActiveRecord::Base.extend Dragonfly::Model
10
11
  ActiveRecord::Base.extend Dragonfly::Model::Validations
11
12
  end
13
+
14
+ # Dragonfly 1.4.0 only allows `quality` as argument to `encode`
15
+ Dragonfly::ImageMagick::Processors::Encode::WHITELISTED_ARGS << "flatten"
16
+
17
+ Rails.application.config.after_initialize do
18
+ Dragonfly.app(:alchemy_pictures).add_processor(:crop_resize, Alchemy::Dragonfly::Processors::CropResize.new)
19
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dragonfly/image_magick/commands"
4
+
5
+ module Alchemy
6
+ module Dragonfly
7
+ module Processors
8
+ class CropResize
9
+ include ::Dragonfly::ParamValidators
10
+
11
+ IS_CROP_ARGUMENT = ->(args_string) {
12
+ args_string.match?(::Dragonfly::ImageMagick::Processors::Thumb::CROP_GEOMETRY)
13
+ }
14
+
15
+ IS_RESIZE_ARGUMENT = ->(args_string) {
16
+ args_string.match?(::Dragonfly::ImageMagick::Processors::Thumb::RESIZE_GEOMETRY)
17
+ }
18
+
19
+ def call(content, crop_argument, resize_argument)
20
+ validate!(crop_argument, &IS_CROP_ARGUMENT)
21
+ validate!(resize_argument, &IS_RESIZE_ARGUMENT)
22
+ ::Dragonfly::ImageMagick::Commands.convert(
23
+ content,
24
+ "-crop #{crop_argument} -resize #{resize_argument}"
25
+ )
26
+ end
27
+
28
+ def update_url(attrs, _args = "", opts = {})
29
+ format = opts["format"]
30
+ attrs.ext = format if format
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -44,5 +44,12 @@ module Alchemy
44
44
  end
45
45
  end
46
46
  end
47
+
48
+ initializer "alchemy.error_tracking" do
49
+ if defined?(Airbrake)
50
+ require_relative "error_tracking/airbrake_handler"
51
+ Alchemy::ErrorTracking.notification_handler = Alchemy::ErrorTracking::AirbrakeHandler
52
+ end
53
+ end
47
54
  end
48
55
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alchemy
4
+ module ErrorTracking
5
+ class AirbrakeHandler < BaseHandler
6
+ def self.call(exception)
7
+ return if ["development", "test"].include?(Rails.env)
8
+
9
+ notify_airbrake(exception)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alchemy
4
+ module ErrorTracking
5
+ class BaseHandler
6
+ def self.call(exception)
7
+ # implement your own notification method
8
+ end
9
+ end
10
+
11
+ mattr_accessor :notification_handler
12
+ @@notification_handler = BaseHandler
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "5.2.5"
4
+ VERSION = "5.2.6"
5
5
 
6
6
  def self.version
7
7
  VERSION
data/lib/alchemy_cms.rb CHANGED
@@ -37,6 +37,7 @@ require_relative "alchemy/controller_actions"
37
37
  require_relative "alchemy/deprecation"
38
38
  require_relative "alchemy/element_definition"
39
39
  require_relative "alchemy/elements_finder"
40
+ require_relative "alchemy/error_tracking"
40
41
  require_relative "alchemy/errors"
41
42
  require_relative "alchemy/essence"
42
43
  require_relative "alchemy/filetypes"
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy_cms/admin",
3
- "version": "5.2.5",
3
+ "version": "5.2.6",
4
4
  "description": "AlchemyCMS",
5
5
  "browser": "package/admin.js",
6
6
  "files": [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.5
4
+ version: 5.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2021-11-24 00:00:00.000000000 Z
16
+ date: 2022-02-28 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: active_model_serializers
@@ -108,12 +108,6 @@ dependencies:
108
108
  requirement: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - "~>"
111
- - !ruby/object:Gem::Version
112
- version: '1.0'
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- version: 1.0.7
116
- - - "<"
117
111
  - !ruby/object:Gem::Version
118
112
  version: '1.4'
119
113
  type: :runtime
@@ -121,12 +115,6 @@ dependencies:
121
115
  version_requirements: !ruby/object:Gem::Requirement
122
116
  requirements:
123
117
  - - "~>"
124
- - !ruby/object:Gem::Version
125
- version: '1.0'
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- version: 1.0.7
129
- - - "<"
130
118
  - !ruby/object:Gem::Version
131
119
  version: '1.4'
132
120
  - !ruby/object:Gem::Dependency
@@ -1092,9 +1080,12 @@ files:
1092
1080
  - lib/alchemy/configuration_methods.rb
1093
1081
  - lib/alchemy/controller_actions.rb
1094
1082
  - lib/alchemy/deprecation.rb
1083
+ - lib/alchemy/dragonfly/processors/crop_resize.rb
1095
1084
  - lib/alchemy/element_definition.rb
1096
1085
  - lib/alchemy/elements_finder.rb
1097
1086
  - lib/alchemy/engine.rb
1087
+ - lib/alchemy/error_tracking.rb
1088
+ - lib/alchemy/error_tracking/airbrake_handler.rb
1098
1089
  - lib/alchemy/errors.rb
1099
1090
  - lib/alchemy/essence.rb
1100
1091
  - lib/alchemy/filetypes.rb