kamifusen 1.10.6 → 1.11.2

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: 93f81ea0cd46f224d042bb77f6610bc4e676ec53e14ad82c617837776fa07e73
4
- data.tar.gz: 28be3a228293b600cdc2e812851e5204a72cd68c3b05c2b456cbc65dce258bfc
3
+ metadata.gz: 65c261931b31f7261f7ecb8eef7c33acefffc4d376277bbf51849a2bef265e72
4
+ data.tar.gz: 2e9a99e1178698daa9e755a3c57255b5b64d9bed7e325abc7fa2c674dbf0d02d
5
5
  SHA512:
6
- metadata.gz: f6e28fa4ac6f70e3e122597da28952f095900993ef84139d13ce54b6678540594cb4ded2afff8451377cdc316f8853af6b84ed851b7599d5071b3683f0eb72f0
7
- data.tar.gz: 62358c3da9d59aa816b8a6d4da3daa899746736365d106f508a97a80e6d7b531f3a3de9ae47282d8dfcd7c1cd121619a1a7d56318308237e8bc004710d615190
6
+ metadata.gz: 1060a04a694115c734ddf368d103094de0eddafdcf3c82a9cfdb13b66f01aa9325dbb097ebcbd065d960c6d408bc75096bb7cdc4ad282ec807cb7d8251910ca4
7
+ data.tar.gz: f5bb7e006824b81be617c50901c61fa93ae871a307fc1a75b948ddefdc8b298ceb263d191083992a1a0c8356d281abf2b4f3f9c8cee85bf9d14c233a23de58e7
data/.gitignore CHANGED
@@ -2,10 +2,7 @@
2
2
  /.yardoc
3
3
  /_yardoc/
4
4
  /coverage/
5
- /doc/
6
- /pkg/
7
5
  /spec/reports/
8
- /tmp/
9
6
  /.bundle/
10
7
  /doc/
11
8
  /log/*.log
@@ -17,3 +14,4 @@
17
14
  /test/dummy/storage/
18
15
  /test/dummy/tmp/
19
16
  .byebug_history
17
+ .DS_Store
data/Gemfile.lock CHANGED
@@ -1,90 +1,98 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kamifusen (1.10.6)
4
+ kamifusen (1.11.2)
5
5
  image_processing
6
6
  rails
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (6.1.4.1)
12
- actionpack (= 6.1.4.1)
13
- activesupport (= 6.1.4.1)
11
+ actioncable (7.0.2.2)
12
+ actionpack (= 7.0.2.2)
13
+ activesupport (= 7.0.2.2)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (6.1.4.1)
17
- actionpack (= 6.1.4.1)
18
- activejob (= 6.1.4.1)
19
- activerecord (= 6.1.4.1)
20
- activestorage (= 6.1.4.1)
21
- activesupport (= 6.1.4.1)
16
+ actionmailbox (7.0.2.2)
17
+ actionpack (= 7.0.2.2)
18
+ activejob (= 7.0.2.2)
19
+ activerecord (= 7.0.2.2)
20
+ activestorage (= 7.0.2.2)
21
+ activesupport (= 7.0.2.2)
22
22
  mail (>= 2.7.1)
23
- actionmailer (6.1.4.1)
24
- actionpack (= 6.1.4.1)
25
- actionview (= 6.1.4.1)
26
- activejob (= 6.1.4.1)
27
- activesupport (= 6.1.4.1)
23
+ net-imap
24
+ net-pop
25
+ net-smtp
26
+ actionmailer (7.0.2.2)
27
+ actionpack (= 7.0.2.2)
28
+ actionview (= 7.0.2.2)
29
+ activejob (= 7.0.2.2)
30
+ activesupport (= 7.0.2.2)
28
31
  mail (~> 2.5, >= 2.5.4)
32
+ net-imap
33
+ net-pop
34
+ net-smtp
29
35
  rails-dom-testing (~> 2.0)
30
- actionpack (6.1.4.1)
31
- actionview (= 6.1.4.1)
32
- activesupport (= 6.1.4.1)
33
- rack (~> 2.0, >= 2.0.9)
36
+ actionpack (7.0.2.2)
37
+ actionview (= 7.0.2.2)
38
+ activesupport (= 7.0.2.2)
39
+ rack (~> 2.0, >= 2.2.0)
34
40
  rack-test (>= 0.6.3)
35
41
  rails-dom-testing (~> 2.0)
36
42
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
- actiontext (6.1.4.1)
38
- actionpack (= 6.1.4.1)
39
- activerecord (= 6.1.4.1)
40
- activestorage (= 6.1.4.1)
41
- activesupport (= 6.1.4.1)
43
+ actiontext (7.0.2.2)
44
+ actionpack (= 7.0.2.2)
45
+ activerecord (= 7.0.2.2)
46
+ activestorage (= 7.0.2.2)
47
+ activesupport (= 7.0.2.2)
48
+ globalid (>= 0.6.0)
42
49
  nokogiri (>= 1.8.5)
43
- actionview (6.1.4.1)
44
- activesupport (= 6.1.4.1)
50
+ actionview (7.0.2.2)
51
+ activesupport (= 7.0.2.2)
45
52
  builder (~> 3.1)
46
53
  erubi (~> 1.4)
47
54
  rails-dom-testing (~> 2.0)
48
55
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
- activejob (6.1.4.1)
50
- activesupport (= 6.1.4.1)
56
+ activejob (7.0.2.2)
57
+ activesupport (= 7.0.2.2)
51
58
  globalid (>= 0.3.6)
52
- activemodel (6.1.4.1)
53
- activesupport (= 6.1.4.1)
54
- activerecord (6.1.4.1)
55
- activemodel (= 6.1.4.1)
56
- activesupport (= 6.1.4.1)
57
- activestorage (6.1.4.1)
58
- actionpack (= 6.1.4.1)
59
- activejob (= 6.1.4.1)
60
- activerecord (= 6.1.4.1)
61
- activesupport (= 6.1.4.1)
62
- marcel (~> 1.0.0)
59
+ activemodel (7.0.2.2)
60
+ activesupport (= 7.0.2.2)
61
+ activerecord (7.0.2.2)
62
+ activemodel (= 7.0.2.2)
63
+ activesupport (= 7.0.2.2)
64
+ activestorage (7.0.2.2)
65
+ actionpack (= 7.0.2.2)
66
+ activejob (= 7.0.2.2)
67
+ activerecord (= 7.0.2.2)
68
+ activesupport (= 7.0.2.2)
69
+ marcel (~> 1.0)
63
70
  mini_mime (>= 1.1.0)
64
- activesupport (6.1.4.1)
71
+ activesupport (7.0.2.2)
65
72
  concurrent-ruby (~> 1.0, >= 1.0.2)
66
73
  i18n (>= 1.6, < 2)
67
74
  minitest (>= 5.1)
68
75
  tzinfo (~> 2.0)
69
- zeitwerk (~> 2.3)
70
76
  ast (2.4.2)
71
77
  builder (3.2.4)
72
78
  byebug (11.1.3)
73
79
  concurrent-ruby (1.1.9)
74
80
  crass (1.0.6)
81
+ digest (3.1.0)
75
82
  erubi (1.10.0)
76
83
  ffi (1.15.4)
77
84
  globalid (1.0.0)
78
85
  activesupport (>= 5.0)
79
- i18n (1.8.11)
86
+ i18n (1.10.0)
80
87
  concurrent-ruby (~> 1.0)
81
88
  image_processing (1.12.1)
82
89
  mini_magick (>= 4.9.5, < 5)
83
90
  ruby-vips (>= 2.0.17, < 3)
91
+ io-wait (0.2.1)
84
92
  listen (3.7.0)
85
93
  rb-fsevent (~> 0.10, >= 0.10.3)
86
94
  rb-inotify (~> 0.9, >= 0.9.10)
87
- loofah (2.12.0)
95
+ loofah (2.14.0)
88
96
  crass (~> 1.0.2)
89
97
  nokogiri (>= 1.5.9)
90
98
  mail (2.7.1)
@@ -93,11 +101,28 @@ GEM
93
101
  method_source (1.0.0)
94
102
  mini_magick (4.11.0)
95
103
  mini_mime (1.1.2)
96
- mini_portile2 (2.6.1)
97
- minitest (5.14.4)
104
+ mini_portile2 (2.8.0)
105
+ minitest (5.15.0)
106
+ net-imap (0.2.3)
107
+ digest
108
+ net-protocol
109
+ strscan
110
+ net-pop (0.1.1)
111
+ digest
112
+ net-protocol
113
+ timeout
114
+ net-protocol (0.1.2)
115
+ io-wait
116
+ timeout
117
+ net-smtp (0.3.1)
118
+ digest
119
+ net-protocol
120
+ timeout
98
121
  nio4r (2.5.8)
99
- nokogiri (1.12.5)
100
- mini_portile2 (~> 2.6.1)
122
+ nokogiri (1.13.3)
123
+ mini_portile2 (~> 2.8.0)
124
+ racc (~> 1.4)
125
+ nokogiri (1.13.3-x86_64-darwin)
101
126
  racc (~> 1.4)
102
127
  parallel (1.21.0)
103
128
  parser (3.0.2.0)
@@ -106,32 +131,32 @@ GEM
106
131
  rack (2.2.3)
107
132
  rack-test (1.1.0)
108
133
  rack (>= 1.0, < 3)
109
- rails (6.1.4.1)
110
- actioncable (= 6.1.4.1)
111
- actionmailbox (= 6.1.4.1)
112
- actionmailer (= 6.1.4.1)
113
- actionpack (= 6.1.4.1)
114
- actiontext (= 6.1.4.1)
115
- actionview (= 6.1.4.1)
116
- activejob (= 6.1.4.1)
117
- activemodel (= 6.1.4.1)
118
- activerecord (= 6.1.4.1)
119
- activestorage (= 6.1.4.1)
120
- activesupport (= 6.1.4.1)
134
+ rails (7.0.2.2)
135
+ actioncable (= 7.0.2.2)
136
+ actionmailbox (= 7.0.2.2)
137
+ actionmailer (= 7.0.2.2)
138
+ actionpack (= 7.0.2.2)
139
+ actiontext (= 7.0.2.2)
140
+ actionview (= 7.0.2.2)
141
+ activejob (= 7.0.2.2)
142
+ activemodel (= 7.0.2.2)
143
+ activerecord (= 7.0.2.2)
144
+ activestorage (= 7.0.2.2)
145
+ activesupport (= 7.0.2.2)
121
146
  bundler (>= 1.15.0)
122
- railties (= 6.1.4.1)
123
- sprockets-rails (>= 2.0.0)
147
+ railties (= 7.0.2.2)
124
148
  rails-dom-testing (2.0.3)
125
149
  activesupport (>= 4.2.0)
126
150
  nokogiri (>= 1.6)
127
151
  rails-html-sanitizer (1.4.2)
128
152
  loofah (~> 2.3)
129
- railties (6.1.4.1)
130
- actionpack (= 6.1.4.1)
131
- activesupport (= 6.1.4.1)
153
+ railties (7.0.2.2)
154
+ actionpack (= 7.0.2.2)
155
+ activesupport (= 7.0.2.2)
132
156
  method_source
133
- rake (>= 0.13)
157
+ rake (>= 12.2)
134
158
  thor (~> 1.0)
159
+ zeitwerk (~> 2.5)
135
160
  rainbow (3.0.0)
136
161
  rake (13.0.6)
137
162
  rb-fsevent (0.11.0)
@@ -153,22 +178,17 @@ GEM
153
178
  ruby-progressbar (1.11.0)
154
179
  ruby-vips (2.1.4)
155
180
  ffi (~> 1.12)
156
- sprockets (4.0.2)
157
- concurrent-ruby (~> 1.0)
158
- rack (> 1, < 3)
159
- sprockets-rails (3.4.1)
160
- actionpack (>= 5.2)
161
- activesupport (>= 5.2)
162
- sprockets (>= 3.0.0)
163
181
  sqlite3 (1.4.2)
164
- thor (1.1.0)
182
+ strscan (3.0.1)
183
+ thor (1.2.1)
184
+ timeout (0.2.0)
165
185
  tzinfo (2.0.4)
166
186
  concurrent-ruby (~> 1.0)
167
187
  unicode-display_width (2.1.0)
168
188
  websocket-driver (0.7.5)
169
189
  websocket-extensions (>= 0.1.0)
170
190
  websocket-extensions (0.1.5)
171
- zeitwerk (2.5.1)
191
+ zeitwerk (2.5.4)
172
192
 
173
193
  PLATFORMS
174
194
  ruby
@@ -183,4 +203,4 @@ DEPENDENCIES
183
203
  sqlite3
184
204
 
185
205
  BUNDLED WITH
186
- 2.2.30
206
+ 2.3.2
@@ -51,22 +51,6 @@ if data
51
51
  parameters += " data-#{entry.first.to_s}=\"#{entry.last}\""
52
52
  end
53
53
  end
54
-
55
-
56
- def kamifusen_process(variant, active_storage_direct_url)
57
- if active_storage_direct_url
58
- begin
59
- # Pour générer la processed url, il faut savoir où sont stockées les images
60
- # https://discuss.rubyonrails.org/t/define-host-so-absolute-urls-work-in-development-and-test/75085
61
- # https://stackoverflow.com/questions/60425407/uriinvalidurierror-bad-uriis-not-uri-nil-active-storage-service-url
62
- url = variant.processed.url
63
- rescue
64
- # Not compatible with DiskService, which returns a URI::InvalidURIError
65
- end
66
- end
67
- url ||= url_for(variant)
68
- url
69
- end
70
54
  %>
71
55
  <% if source.variable? %>
72
56
  <%
@@ -82,26 +66,26 @@ end
82
66
  if Kamifusen.with_webp
83
67
  srcset_webp = variant_sizes.map { |size|
84
68
  variant = source.variant(resize: "#{size}>", format: :webp, quality: quality)
85
- "#{ kamifusen_process(variant, active_storage_direct_url) } #{size}w"
69
+ "#{ Kamifusen.process(variant, active_storage_direct_url) } #{size}w"
86
70
  }.join(', ')
87
71
  end
88
72
  srcset_default = variant_sizes.map { |size|
89
73
  variant = source.variant(resize: "#{size}>", quality: quality)
90
- "#{ kamifusen_process(variant, active_storage_direct_url) } #{size}w"
74
+ "#{ Kamifusen.process(variant, active_storage_direct_url) } #{size}w"
91
75
  }.join(', ')
92
76
  variant = source.variant(resize: "#{default_width}>", quality: quality)
93
- default = kamifusen_process(variant, active_storage_direct_url)
77
+ default = Kamifusen.process(variant, active_storage_direct_url)
94
78
  %>
95
79
  <picture<%= " class=\"#{picture_class}\"".html_safe unless picture_class.blank? %>>
96
80
  <% if Kamifusen.with_webp %>
97
- <source srcset="<%= srcset_webp %>"
81
+ <source srcset="<%= raw srcset_webp %>"
98
82
  <%= " sizes=\"#{sizes_value}\"".html_safe unless sizes.empty? %>
99
83
  type="image/webp">
100
84
  <% end %>
101
- <source srcset="<%= srcset_default %>"
85
+ <source srcset="<%= raw srcset_default %>"
102
86
  <%= " sizes=\"#{sizes_value}\"".html_safe unless sizes.empty? %>
103
87
  type="<%= source.content_type %>">
104
- <img src="<%= default %>" <%= raw parameters %>>
88
+ <img src="<%= raw default %>" <%= raw parameters %>>
105
89
  </picture>
106
90
  <% else %>
107
91
  <picture>
data/image.jpg ADDED
Binary file
@@ -0,0 +1,60 @@
1
+ module Kamifusen
2
+ class Processor
3
+ attr_reader :variant, :active_storage_direct_url
4
+
5
+ def initialize(variant, active_storage_direct_url = false)
6
+ @variant = variant
7
+ @active_storage_direct_url = active_storage_direct_url
8
+ end
9
+
10
+ def url
11
+ Kamifusen.keycdn.present? ? keycdn_url
12
+ : active_storage_url
13
+ end
14
+
15
+ protected
16
+
17
+ def keycdn_url
18
+ url = "#{Kamifusen.keycdn}/#{variant.blob.key}?"
19
+ transformations = variant.variation.transformations
20
+ url += "format=#{transformations[:format]}&" if transformations.has_key? :format
21
+ url += "quality=#{transformations[:quality]}&" if transformations.has_key? :quality
22
+ if transformations.has_key? :resize
23
+ resize = transformations[:resize]
24
+ # 100>
25
+ if '>'.in? resize
26
+ width = resize.split('>').first.to_i
27
+ url += "width=#{width}&"
28
+ end
29
+ end
30
+ url
31
+ end
32
+
33
+ def active_storage_url
34
+ url = nil
35
+ url = processed_url if active_storage_direct_url
36
+ url ||= smart_url
37
+ url ||= explicit_url
38
+ url
39
+ end
40
+
41
+ def processed_url
42
+ # Pour générer la processed url, il faut savoir où sont stockées les images
43
+ # https://discuss.rubyonrails.org/t/define-host-so-absolute-urls-work-in-development-and-test/75085
44
+ # https://stackoverflow.com/questions/60425407/uriinvalidurierror-bad-uriis-not-uri-nil-active-storage-service-url
45
+ variant.processed.url
46
+ rescue
47
+ # Not compatible with DiskService, which returns a URI::InvalidURIError
48
+ end
49
+
50
+ def smart_url
51
+ Rails.application.routes.url_helpers.url_for(variant)
52
+ rescue
53
+ # Host might not be defined
54
+ end
55
+
56
+ def explicit_url
57
+ Rails.application.routes.url_helpers.rails_representation_path(variant, only_path: true)
58
+ end
59
+ end
60
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kamifusen
4
- VERSION = "1.10.6"
4
+ VERSION = "1.11.2"
5
5
  end
data/lib/kamifusen.rb CHANGED
@@ -3,12 +3,24 @@
3
3
  require "kamifusen/version"
4
4
  require "kamifusen/railtie"
5
5
  require "kamifusen/view_helper"
6
+ require "kamifusen/processor"
6
7
 
7
8
  module Kamifusen
8
9
 
10
+ def self.config
11
+ yield self
12
+ end
13
+
14
+ def self.process(variant, active_storage_direct_url = false)
15
+ Processor.new(variant, active_storage_direct_url).url
16
+ end
17
+
9
18
  mattr_accessor :with_webp
10
19
  @@with_webp = true
11
20
 
21
+ mattr_accessor :keycdn
22
+ @@keycdn = nil
23
+
12
24
  mattr_accessor :sizes
13
25
  @@sizes = [
14
26
  100, # small formats
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kamifusen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.6
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Moulène
8
8
  - Arnaud Levy
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-12-09 00:00:00.000000000 Z
12
+ date: 2022-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -89,8 +89,10 @@ files:
89
89
  - bin/setup
90
90
  - docs/index.html
91
91
  - docs/test_01.html
92
+ - image.jpg
92
93
  - kamifusen.gemspec
93
94
  - lib/kamifusen.rb
95
+ - lib/kamifusen/processor.rb
94
96
  - lib/kamifusen/railtie.rb
95
97
  - lib/kamifusen/version.rb
96
98
  - lib/kamifusen/view_helper.rb
@@ -100,7 +102,7 @@ licenses:
100
102
  metadata:
101
103
  homepage_uri: https://github.com/sebousan/kamifusen
102
104
  source_code_uri: https://github.com/sebousan/kamifusen
103
- post_install_message:
105
+ post_install_message:
104
106
  rdoc_options: []
105
107
  require_paths:
106
108
  - lib
@@ -115,8 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
117
  - !ruby/object:Gem::Version
116
118
  version: '0'
117
119
  requirements: []
118
- rubygems_version: 3.1.4
119
- signing_key:
120
+ rubygems_version: 3.1.6
121
+ signing_key:
120
122
  specification_version: 4
121
123
  summary: Images, light as balloons
122
124
  test_files: []