imgproxy-rails 0.2.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a32f1fb8b8e0a6c74771558af38fccbf85f5984e635e7e33bbcfa55803b58aa2
4
- data.tar.gz: 990e9aec461a9542f596f11379c0c9fc9a33bf4019dd92bd0f142f0c78997601
3
+ metadata.gz: b6974de3a0a3e639db48c61d91831744442c8ac5a5d6e9d4525985896e6b2a01
4
+ data.tar.gz: d081d8571ca8a0cd940839cb97016abf74138158dfe4c0135a45368842c8d007
5
5
  SHA512:
6
- metadata.gz: 86cfbf37fbf9108bcb976db31ce1f407378207dc2d687e421e71b5c15dac476acb521d0cdbf704b7492f7591ca23029f88cb9e145a0e72f85d926f276a0709c4
7
- data.tar.gz: 126fbaf3621c59959fa8e9ff0a82ab1597cd1c5fc0f3667ca04e00b13368c1ab9a3bf39aa6c410f9655d132121fe8b38d7fec61fe45da123ac69653360f7e533
6
+ metadata.gz: 7ad05883a46086a42ea605d2f978c9f57ef0da2d412b3c2f0443eddc25e62a93727d975459c69299314522e42176435bcbeed20e7b62ea2ba47c24da2bd9d4c1
7
+ data.tar.gz: 177fe43bf90c218934bd705d155bc10812493c8e427d8eed10e81561849d443eacd90c453d6e294655b2307ce165d8dad0b155baf6c790cd2b43f72abf6b7e85
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.3.0 (2023-12-27)
6
+
7
+ - Added support for `video/*` and `application/pdf` content types. ([@DarthSim][])
8
+
9
+ - `config/routes.rb` added to gemspec files ([@chloerei][])
10
+
5
11
  ## 0.2.0 (2023-10-26)
6
12
 
7
13
  - Improved `resize_and_pad` support. ([@palkan][])
data/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  ---
20
20
 
21
- Integration of [imgproxy.rb](https://github.com/imgproxy/imgproxy.rb) with [ActiveStorage::Variant API](https://edgeapi.rubyonrails.org/classes/ActiveStorage/Variant.htmlasses/ActiveStorage/Variant.html).
21
+ Integration of [imgproxy.rb](https://github.com/imgproxy/imgproxy.rb) with [ActiveStorage::Variant API](https://edgeapi.rubyonrails.org/classes/ActiveStorage/Variant.html).
22
22
 
23
23
  ## Installation
24
24
 
@@ -76,6 +76,17 @@ You can also specify imgproxy-specific parameters in `imgproxy_options` attribut
76
76
  Current.user.avatar.variant(resize: "100x100", imgproxy_options: {height: 50, width: 50})
77
77
  ```
78
78
 
79
+ ### Generating video and PDF previews
80
+
81
+ If you are an imgproxy Pro user and you want to use it to generate previews for your videos and PDFs, just add their content types to the `variable_content_types` list:
82
+
83
+ ```ruby
84
+ config.active_storage.variable_content_types << "application/pdf"
85
+ config.active_storage.variable_content_types << "video/mp4"
86
+ config.active_storage.variable_content_types << "video/mov"
87
+ # ...etc
88
+ ```
89
+
79
90
  ## Contributing
80
91
 
81
92
  Bug reports and pull requests are welcome on GitHub at [https://github.com/imgproxy/imgproxy-rails](https://github.com/imgproxy/imgproxy-rails).
data/config/routes.rb ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ direct :imgproxy_active_storage do |model, options|
5
+ if ImgproxyRails::Helpers.applicable_variation?(model)
6
+ transformations = model.variation.transformations
7
+ Imgproxy.url_for(model.blob, ImgproxyRails::Transformer.call(transformations))
8
+ else
9
+ route_for(:rails_storage_proxy, model, options)
10
+ end
11
+ end
12
+ end
@@ -2,9 +2,13 @@
2
2
 
3
3
  module ImgproxyRails
4
4
  module Helpers
5
- def self.image_variation?(model)
6
- model.respond_to?(:variation) &&
7
- model.try(:blob)&.content_type&.split("/")&.first == "image"
5
+ def self.applicable_variation?(model)
6
+ return false if !model.respond_to?(:variation)
7
+
8
+ content_type = model.try(:blob)&.content_type
9
+ content_type&.start_with?("image/") ||
10
+ content_type&.start_with?("video/") ||
11
+ content_type == "application/pdf"
8
12
  end
9
13
  end
10
14
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ImgproxyRails
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgproxy-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-27 00:00:00.000000000 Z
12
+ date: 2023-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: imgproxy
@@ -148,6 +148,7 @@ files:
148
148
  - CHANGELOG.md
149
149
  - LICENSE.txt
150
150
  - README.md
151
+ - config/routes.rb
151
152
  - lib/imgproxy-rails.rb
152
153
  - lib/imgproxy-rails/engine.rb
153
154
  - lib/imgproxy-rails/helpers.rb
@@ -177,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
178
  - !ruby/object:Gem::Version
178
179
  version: '0'
179
180
  requirements: []
180
- rubygems_version: 3.4.20
181
+ rubygems_version: 3.3.26
181
182
  signing_key:
182
183
  specification_version: 4
183
184
  summary: integration of imgproxy.rb with ActiveStorage::Variant API