thumbor_helpers 0.1.0 → 0.2.0

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: c43665acba064ebb65e0b6c35c23b0c0c97bd295979d019ae86def6e8df9465f
4
- data.tar.gz: 3b0658e26c608185978ff8cbee7de339c8e8e3b9ac2c741c66ace2b4a62e646a
3
+ metadata.gz: 533b04f6b3f7d3de9edc5bb11856b933e7c9521dfcdcb83b47419875e39e9b75
4
+ data.tar.gz: 1132618541911451bead686688c34de94783d9d0f4ac5583aa3c5207f36e18d2
5
5
  SHA512:
6
- metadata.gz: 0d266f2a3b1122aa899bc3d160cafb38a9e4e75240019cd2bf3ceec8379c96f5538b2248d02e3e7289aaac4420313fd6c0696245a100503e92f42df1c2f11e3a
7
- data.tar.gz: 9c44ef26932a6cc6e4680c6c9851de7988677c5f36d37305328572551242375caa9a909521b51e5c21fd7ae0744a1ae19498fe66171c2d0889f89fe08495181a
6
+ metadata.gz: a9c86f2815ac8abcc32af7507613b27171854634b544a9a507951626b1e4ce859c2e0df72caa0de4f574f1a1d52affbb383796a587068eabeae43489f0a4fcfd
7
+ data.tar.gz: b052f6ea04554bfae87bd1cf1262843243c4d80206601f7cdbca18d554affe03fa81bad63af2bf057bc880edff579cc45dacf47de660e0271c6a2e44f6f3e888
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thumbor_helpers (0.1.0)
4
+ thumbor_helpers (0.2.0)
5
5
  ruby-thumbor (>= 4)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -26,14 +26,28 @@ Now go in config/initializers and configure the thumbors with the server creaden
26
26
 
27
27
  ## Usage
28
28
 
29
- TODO: Write usage instructions here
29
+ When enabled the helpers replace de standard url method of picture and create the absolute url to work with and instance
30
+ of thumbor.
31
+ You can bypass globaly by setting in the configurations to disable thumbor, or you can pass to url an optional parameter
32
+ to single disable thumbor.
33
+ ES:
34
+ ```ruby
35
+ record.picture.url(thumbor_disable:true)
36
+ ```
37
+
38
+ ## Configurations WIP
39
+
40
+ - allowed_image_extensions:
41
+ regexp to filter what type of images let thumbor elaborate.
42
+ Default: `[/(.*\.jpe?g|.*\.png)/`
43
+
30
44
 
31
45
  ## Development
32
46
 
33
47
  Start a thumbor server with the command:
34
48
 
35
49
  ```shell
36
- docker run --network host -e THUMBOR_PORT=8888 -e SECURITY_KEY='1234567890123456' -e ALLOW_UNSAFE_URL=0 minimalcompact/thumbor thumbor
50
+ docker run --network host -e THUMBOR_PORT=8888 -e SECURITY_KEY='1234567890123456' -e AUTO_WEBP='True' -e ALLOW_UNSAFE_URL='False' minimalcompact/thumbor thumbor
37
51
  ```
38
52
 
39
53
  ## Version Release
@@ -5,9 +5,10 @@ module ThumborHelpers
5
5
  module Picture
6
6
 
7
7
  def url(options = {})
8
+ thumbor_disable = options.delete(:thumbor_disable) { false }
8
9
  url = super(options)
9
10
 
10
- if ThumborHelpers.config.enabled?
11
+ if ThumborHelpers.config.enabled? and !thumbor_disable and url.match(ThumborHelpers.config.allowed_image_extensions)
11
12
  escaped = CGI.escape("#{ThumborHelpers.config.image_root_host}#{url}")
12
13
  encrypted_request = ThumborHelpers.config.cripto_generator.generate(image: escaped)
13
14
  "#{ThumborHelpers.config.server_url}#{encrypted_request}"
@@ -27,8 +27,14 @@ module ThumborHelpers
27
27
 
28
28
  attr_reader :cripto_generator
29
29
 
30
+ ##
31
+ # RegExp match to enable thumbor images
32
+ # @return [Regexp] -> default (.*\.jpe?g|.*\.png)
33
+ attr_accessor :allowed_image_extensions
34
+
30
35
  def initialize
31
36
  @enabled = false
37
+ @allowed_image_extensions = /(.*\.jpe?g|.*\.png)/
32
38
  reconfigure_thumbor
33
39
  end
34
40
 
@@ -1,3 +1,3 @@
1
1
  module ThumborHelpers
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thumbor_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marino Bonetti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-19 00:00:00.000000000 Z
11
+ date: 2023-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-thumbor
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.1.4
75
+ rubygems_version: 3.1.6
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: collection of helpers to simplify live for use thumbor with rails and alchemy