imgproxy 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/lib/imgproxy.rb +2 -2
- data/lib/imgproxy/builder.rb +2 -1
- data/lib/imgproxy/config.rb +1 -6
- data/lib/imgproxy/url_adapters/active_storage_gcs.rb +1 -1
- data/lib/imgproxy/url_adapters/active_storage_s3.rb +1 -1
- data/lib/imgproxy/url_adapters/shrine.rb +5 -1
- data/lib/imgproxy/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da7381a4edd77972d08b45c68b7a923b924d67b63953e009d90188fc24a56f78
|
4
|
+
data.tar.gz: 7d9832c91d0688b462644238766766df4720f8f7f4d8e5b68d6e94d7b5f6587e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f195a449ff6c690aefcc92d776378c7fec811112943e54781f2fd1f1cbf2484f042bf555ca2b62bf6fbe070998fb5df6e83767f571fc52d6533966cea1d0678
|
7
|
+
data.tar.gz: 3affbd94edbb6be46ee1fb3729c3a3ff6002b06344d84fd4c434bc27f47b7a6d2aa374d6023694af866c41691fad8b5286e1ec525c9121fd0503addb707fc1d4
|
data/README.md
CHANGED
@@ -110,14 +110,12 @@ user.avatar.imgproxy_url(width: 250, height: 250)
|
|
110
110
|
|
111
111
|
will give you an URL to your user's avatar, resized to 250x250px on the fly.
|
112
112
|
|
113
|
-
**Note:** If you use `Shrine::Storage::FileSystem` as storage, uploaded file URLs won't include the hostname, so imgproxy server won't be able to access them. To fix this,
|
113
|
+
**Note:** If you use `Shrine::Storage::FileSystem` as storage, uploaded file URLs won't include the hostname, so imgproxy server won't be able to access them. To fix this, use `host` option of `Imgproxy.extend_shrine!`:
|
114
114
|
|
115
115
|
```ruby
|
116
|
-
#
|
116
|
+
# config/initializers/imgproxy.rb
|
117
117
|
|
118
|
-
|
119
|
-
store: Shrine::Storage::FileSystem.new("public", host: "http://your-host.test")
|
120
|
-
}
|
118
|
+
Imgproxy.extend_shrine!(host: "http://your-host.test")
|
121
119
|
```
|
122
120
|
|
123
121
|
Alternatively, you can launch your imgproxy server with the `IMGPROXY_BASE_URL` setting:
|
data/lib/imgproxy.rb
CHANGED
@@ -97,13 +97,13 @@ module Imgproxy
|
|
97
97
|
#
|
98
98
|
# @return [void]
|
99
99
|
# @param use_s3 [Boolean] enable Amazon S3 source URLs
|
100
|
-
def extend_shrine!(use_s3: false)
|
100
|
+
def extend_shrine!(host: nil, use_s3: false)
|
101
101
|
::Shrine::UploadedFile.include Imgproxy::Extensions::Shrine
|
102
102
|
|
103
103
|
url_adapters = Imgproxy.config.url_adapters
|
104
104
|
|
105
105
|
url_adapters.add(Imgproxy::UrlAdapters::ShrineS3.new) if use_s3
|
106
|
-
url_adapters.add(Imgproxy::UrlAdapters::Shrine.new)
|
106
|
+
url_adapters.add(Imgproxy::UrlAdapters::Shrine.new(host: host))
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
data/lib/imgproxy/builder.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "openssl"
|
2
2
|
require "base64"
|
3
|
+
require "uri"
|
3
4
|
|
4
5
|
require "imgproxy/options"
|
5
6
|
|
@@ -37,7 +38,7 @@ module Imgproxy
|
|
37
38
|
|
38
39
|
signature = sign_path(path)
|
39
40
|
|
40
|
-
|
41
|
+
URI.join(Imgproxy.config.endpoint.to_s, "#{signature}/#{path}").to_s
|
41
42
|
end
|
42
43
|
|
43
44
|
private
|
data/lib/imgproxy/config.rb
CHANGED
@@ -5,7 +5,7 @@ module Imgproxy
|
|
5
5
|
# @see Imgproxy.configure
|
6
6
|
class Config
|
7
7
|
# @return [String] imgproxy endpoint
|
8
|
-
|
8
|
+
attr_accessor :endpoint
|
9
9
|
# @return [String] imgproxy signature key
|
10
10
|
attr_accessor :key
|
11
11
|
# @return [String] imgproxy signature salt
|
@@ -36,11 +36,6 @@ module Imgproxy
|
|
36
36
|
self.salt = value.nil? ? nil : [value].pack("H*")
|
37
37
|
end
|
38
38
|
|
39
|
-
def endpoint=(value)
|
40
|
-
value = value.to_s
|
41
|
-
@endpoint = value.end_with?("/") ? value[0..-2] : value
|
42
|
-
end
|
43
|
-
|
44
39
|
# URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc.
|
45
40
|
#
|
46
41
|
# Imgproxy.configure do |config|
|
@@ -12,7 +12,7 @@ module Imgproxy
|
|
12
12
|
class ActiveStorageS3 < Imgproxy::UrlAdapters::ActiveStorage
|
13
13
|
def applicable?(image)
|
14
14
|
super &&
|
15
|
-
|
15
|
+
image.service.is_a?(::ActiveStorage::Service::S3Service)
|
16
16
|
end
|
17
17
|
|
18
18
|
def url(image)
|
@@ -8,12 +8,16 @@ module Imgproxy
|
|
8
8
|
#
|
9
9
|
# Imgproxy.url_for(user.avatar)
|
10
10
|
class Shrine
|
11
|
+
def initialize(host: nil)
|
12
|
+
@host = host
|
13
|
+
end
|
14
|
+
|
11
15
|
def applicable?(image)
|
12
16
|
image.is_a?(::Shrine::UploadedFile)
|
13
17
|
end
|
14
18
|
|
15
19
|
def url(image)
|
16
|
-
image.url
|
20
|
+
image.url(host: @host)
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
data/lib/imgproxy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imgproxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Alexandrovich
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: pry-byebug
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.6.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rspec_junit_formatter
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.4.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.4.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
183
|
requirements:
|
184
184
|
- - ">="
|
185
185
|
- !ruby/object:Gem::Version
|
186
|
-
version: '0'
|
186
|
+
version: '2.0'
|
187
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
188
|
requirements:
|
189
189
|
- - ">="
|