thumbor_helpers 0.1.0 → 0.2.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +16 -2
- data/lib/thumbor_helpers/alchemy_overrides/picture.rb +2 -1
- data/lib/thumbor_helpers/config.rb +6 -0
- data/lib/thumbor_helpers/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 533b04f6b3f7d3de9edc5bb11856b933e7c9521dfcdcb83b47419875e39e9b75
|
4
|
+
data.tar.gz: 1132618541911451bead686688c34de94783d9d0f4ac5583aa3c5207f36e18d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9c86f2815ac8abcc32af7507613b27171854634b544a9a507951626b1e4ce859c2e0df72caa0de4f574f1a1d52affbb383796a587068eabeae43489f0a4fcfd
|
7
|
+
data.tar.gz: b052f6ea04554bfae87bd1cf1262843243c4d80206601f7cdbca18d554affe03fa81bad63af2bf057bc880edff579cc45dacf47de660e0271c6a2e44f6f3e888
|
data/Gemfile.lock
CHANGED
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
|
-
|
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=
|
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
|
|
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.
|
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:
|
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.
|
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
|