kamifusen 1.10.4 → 1.11.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: 12d0c2903826a900723af0aea99336e6aef512e3cae4766909dad2e50093ac9f
4
- data.tar.gz: 5e1218d9d960bed50bc598a7f7242f0535544696ae7e094e232167607bc45a27
3
+ metadata.gz: eed49b577b0d884253f09fab9fb936652ec7a8612a8665b2f25688373a1241e9
4
+ data.tar.gz: '087e3e24d380ae97d311f816a9fbc20c0f7cd243143bcf9d00e7f2e07ebdbd25'
5
5
  SHA512:
6
- metadata.gz: 0cf98152843c87b024b750edee24772bbba61f63045834b3ba631b1eb6cb4c7cccfe603b8c0f054ad118de7ea31ed54b6324f84f24daee5a4fd922ac65521b8b
7
- data.tar.gz: 39887ba0a9fea2680d3d9f469e7498d77743960b56412603f8ee7e9a318d0ccfb83972ec02b7b3988b5c9c513b17c28796d5beb5e571073751b8e8f6e53ac3db
6
+ metadata.gz: f134379269b0ce23c8fe344afc832ae9c31d1eb8d5c8d85bf24a4390e4f3e765b9b51c3f5faa6e77b509b983aa1b0bf4dfbf6362feba06de2eb1adbdd33bb94a
7
+ data.tar.gz: 4eadc2f6cad2659fc12c6cbd37af7abf157e5f8bfba15c99f0436715567b564c578a44bbc901d69a08dbdd50c8e98e58b6fd12c3880f1078aa7626ee49c39e33
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.4)
4
+ kamifusen (1.11.0)
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
- globalid (0.5.2)
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,13 +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)
101
124
  racc (~> 1.4)
102
- nokogiri (1.12.5-x86_64-darwin)
125
+ nokogiri (1.13.3-x86_64-darwin)
103
126
  racc (~> 1.4)
104
127
  parallel (1.21.0)
105
128
  parser (3.0.2.0)
@@ -108,32 +131,32 @@ GEM
108
131
  rack (2.2.3)
109
132
  rack-test (1.1.0)
110
133
  rack (>= 1.0, < 3)
111
- rails (6.1.4.1)
112
- actioncable (= 6.1.4.1)
113
- actionmailbox (= 6.1.4.1)
114
- actionmailer (= 6.1.4.1)
115
- actionpack (= 6.1.4.1)
116
- actiontext (= 6.1.4.1)
117
- actionview (= 6.1.4.1)
118
- activejob (= 6.1.4.1)
119
- activemodel (= 6.1.4.1)
120
- activerecord (= 6.1.4.1)
121
- activestorage (= 6.1.4.1)
122
- 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)
123
146
  bundler (>= 1.15.0)
124
- railties (= 6.1.4.1)
125
- sprockets-rails (>= 2.0.0)
147
+ railties (= 7.0.2.2)
126
148
  rails-dom-testing (2.0.3)
127
149
  activesupport (>= 4.2.0)
128
150
  nokogiri (>= 1.6)
129
151
  rails-html-sanitizer (1.4.2)
130
152
  loofah (~> 2.3)
131
- railties (6.1.4.1)
132
- actionpack (= 6.1.4.1)
133
- activesupport (= 6.1.4.1)
153
+ railties (7.0.2.2)
154
+ actionpack (= 7.0.2.2)
155
+ activesupport (= 7.0.2.2)
134
156
  method_source
135
- rake (>= 0.13)
157
+ rake (>= 12.2)
136
158
  thor (~> 1.0)
159
+ zeitwerk (~> 2.5)
137
160
  rainbow (3.0.0)
138
161
  rake (13.0.6)
139
162
  rb-fsevent (0.11.0)
@@ -153,24 +176,19 @@ GEM
153
176
  rubocop-ast (1.13.0)
154
177
  parser (>= 3.0.1.1)
155
178
  ruby-progressbar (1.11.0)
156
- ruby-vips (2.1.3)
179
+ ruby-vips (2.1.4)
157
180
  ffi (~> 1.12)
158
- sprockets (4.0.2)
159
- concurrent-ruby (~> 1.0)
160
- rack (> 1, < 3)
161
- sprockets-rails (3.4.0)
162
- actionpack (>= 5.2)
163
- activesupport (>= 5.2)
164
- sprockets (>= 3.0.0)
165
181
  sqlite3 (1.4.2)
166
- thor (1.1.0)
182
+ strscan (3.0.1)
183
+ thor (1.2.1)
184
+ timeout (0.2.0)
167
185
  tzinfo (2.0.4)
168
186
  concurrent-ruby (~> 1.0)
169
187
  unicode-display_width (2.1.0)
170
188
  websocket-driver (0.7.5)
171
189
  websocket-extensions (>= 0.1.0)
172
190
  websocket-extensions (0.1.5)
173
- zeitwerk (2.5.1)
191
+ zeitwerk (2.5.4)
174
192
 
175
193
  PLATFORMS
176
194
  ruby
@@ -185,4 +203,4 @@ DEPENDENCIES
185
203
  sqlite3
186
204
 
187
205
  BUNDLED WITH
188
- 2.2.30
206
+ 2.3.2
@@ -1,6 +1,8 @@
1
1
  <%
2
2
  options ||= {}
3
+ title = options[:title]
3
4
  alt = options[:alt]
5
+ data = options[:data]
4
6
  async = options.has_key?(:async) ? options[:async] : true
5
7
  active_storage_direct_url = options.has_key?(:active_storage_direct_url) ? options[:active_storage_direct_url] : false
6
8
  klass = options[:class]
@@ -40,23 +42,14 @@ end
40
42
  parameters = ""
41
43
  parameters += " loading=\"lazy\" decoding=\"async\"" if async
42
44
  parameters += " alt=\"#{alt}\"" if alt
45
+ parameters += " title=\"#{title}\"" if title
43
46
  parameters += " width=\"#{width}\"" if width
44
47
  parameters += " height=\"#{height}\"" if height
45
48
  parameters += " class=\"#{klass}\"" if klass
46
-
47
- def kamifusen_process(variant, active_storage_direct_url)
48
- if active_storage_direct_url
49
- begin
50
- # Pour générer la processed url, il faut savoir où sont stockées les images
51
- # https://discuss.rubyonrails.org/t/define-host-so-absolute-urls-work-in-development-and-test/75085
52
- # https://stackoverflow.com/questions/60425407/uriinvalidurierror-bad-uriis-not-uri-nil-active-storage-service-url
53
- url = variant.processed.url
54
- rescue
55
- # Not compatible with DiskService, which returns a URI::InvalidURIError
56
- end
49
+ if data
50
+ data.each do |entry|
51
+ parameters += " data-#{entry.first.to_s}=\"#{entry.last}\""
57
52
  end
58
- url ||= url_for(variant)
59
- url
60
53
  end
61
54
  %>
62
55
  <% if source.variable? %>
@@ -73,15 +66,15 @@ end
73
66
  if Kamifusen.with_webp
74
67
  srcset_webp = variant_sizes.map { |size|
75
68
  variant = source.variant(resize: "#{size}>", format: :webp, quality: quality)
76
- "#{ kamifusen_process(variant, active_storage_direct_url) } #{size}w"
69
+ "#{ Kamifusen.process(variant, active_storage_direct_url) } #{size}w"
77
70
  }.join(', ')
78
71
  end
79
72
  srcset_default = variant_sizes.map { |size|
80
73
  variant = source.variant(resize: "#{size}>", quality: quality)
81
- "#{ kamifusen_process(variant, active_storage_direct_url) } #{size}w"
74
+ "#{ Kamifusen.process(variant, active_storage_direct_url) } #{size}w"
82
75
  }.join(', ')
83
76
  variant = source.variant(resize: "#{default_width}>", quality: quality)
84
- default = kamifusen_process(variant, active_storage_direct_url)
77
+ default = Kamifusen.process(variant, active_storage_direct_url)
85
78
  %>
86
79
  <picture<%= " class=\"#{picture_class}\"".html_safe unless picture_class.blank? %>>
87
80
  <% if Kamifusen.with_webp %>
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)
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.4"
4
+ VERSION = "1.11.0"
5
5
  end
data/lib/kamifusen.rb CHANGED
@@ -3,14 +3,29 @@
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)
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 = [
26
+ 100, # small formats
27
+ 200, # small formats
28
+ 300, # small formats
14
29
  # 360, # Old android
15
30
  375, # Old iPhone
16
31
  # 414, # ?
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.4
4
+ version: 1.11.0
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-11-18 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
@@ -116,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
118
  version: '0'
117
119
  requirements: []
118
120
  rubygems_version: 3.1.6
119
- signing_key:
121
+ signing_key:
120
122
  specification_version: 4
121
123
  summary: Images, light as balloons
122
124
  test_files: []