kamifusen 1.2 → 1.6

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: 851589d8842495c0ec86ca05f50f1d31dc8b2bfd1529f5489ace33d2389c7685
4
- data.tar.gz: bdacde7a5ece34a1e28bf81afe73e2819c810b2cef85644ab8f86ffd1537a030
3
+ metadata.gz: 42e4345e5d359096961d48f2c5477fbcdf6fafec4b84f2ca32dc6e410a2502fa
4
+ data.tar.gz: d2b920f457438f5652c14cffd7d14032637549e10a753f1244cb95da3706e475
5
5
  SHA512:
6
- metadata.gz: 48ee33fa22558e94422fa8238689a3264e5e2f3fbe97b955b0d06b9b0b5bf84c0afa9cf2703b853181fce9c4e7bba63a618def3f7d83bc3422c2f847e3e55a0a
7
- data.tar.gz: ce384764e41270902b94a25bc7de4b0a961fb198b99b099e76b3c148fad146043d82903b08620aa360cc5224cc68a6f3b20bb58aee4257be07e5b41a366e1671
6
+ metadata.gz: e3c68441c27a9e4533d74975f2a57ebb0bffa59bfe66cc32f9ce2846c897d090b24d3ebf338fbc5de180d2368f4b56a84e81258b9866552f691e5f8740b934d2
7
+ data.tar.gz: 3334ffd8b926960203b4586f779130d00ad6d2c0010d02e7f2b419bfd2d2389d11be128f8901970fbff5f8f2705e9dbbb5ace3dda2bd7ec01f4f5dfc1719d20c
data/Gemfile.lock CHANGED
@@ -1,67 +1,67 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kamifusen (1.2)
4
+ kamifusen (1.6)
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)
12
- actionpack (= 6.1.4)
13
- activesupport (= 6.1.4)
11
+ actioncable (6.1.4.1)
12
+ actionpack (= 6.1.4.1)
13
+ activesupport (= 6.1.4.1)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (6.1.4)
17
- actionpack (= 6.1.4)
18
- activejob (= 6.1.4)
19
- activerecord (= 6.1.4)
20
- activestorage (= 6.1.4)
21
- activesupport (= 6.1.4)
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)
22
22
  mail (>= 2.7.1)
23
- actionmailer (6.1.4)
24
- actionpack (= 6.1.4)
25
- actionview (= 6.1.4)
26
- activejob (= 6.1.4)
27
- activesupport (= 6.1.4)
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)
28
28
  mail (~> 2.5, >= 2.5.4)
29
29
  rails-dom-testing (~> 2.0)
30
- actionpack (6.1.4)
31
- actionview (= 6.1.4)
32
- activesupport (= 6.1.4)
30
+ actionpack (6.1.4.1)
31
+ actionview (= 6.1.4.1)
32
+ activesupport (= 6.1.4.1)
33
33
  rack (~> 2.0, >= 2.0.9)
34
34
  rack-test (>= 0.6.3)
35
35
  rails-dom-testing (~> 2.0)
36
36
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
- actiontext (6.1.4)
38
- actionpack (= 6.1.4)
39
- activerecord (= 6.1.4)
40
- activestorage (= 6.1.4)
41
- activesupport (= 6.1.4)
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)
42
42
  nokogiri (>= 1.8.5)
43
- actionview (6.1.4)
44
- activesupport (= 6.1.4)
43
+ actionview (6.1.4.1)
44
+ activesupport (= 6.1.4.1)
45
45
  builder (~> 3.1)
46
46
  erubi (~> 1.4)
47
47
  rails-dom-testing (~> 2.0)
48
48
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
- activejob (6.1.4)
50
- activesupport (= 6.1.4)
49
+ activejob (6.1.4.1)
50
+ activesupport (= 6.1.4.1)
51
51
  globalid (>= 0.3.6)
52
- activemodel (6.1.4)
53
- activesupport (= 6.1.4)
54
- activerecord (6.1.4)
55
- activemodel (= 6.1.4)
56
- activesupport (= 6.1.4)
57
- activestorage (6.1.4)
58
- actionpack (= 6.1.4)
59
- activejob (= 6.1.4)
60
- activerecord (= 6.1.4)
61
- activesupport (= 6.1.4)
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
62
  marcel (~> 1.0.0)
63
63
  mini_mime (>= 1.1.0)
64
- activesupport (6.1.4)
64
+ activesupport (6.1.4.1)
65
65
  concurrent-ruby (~> 1.0, >= 1.0.2)
66
66
  i18n (>= 1.6, < 2)
67
67
  minitest (>= 5.1)
@@ -74,8 +74,8 @@ GEM
74
74
  crass (1.0.6)
75
75
  erubi (1.10.0)
76
76
  ffi (1.15.3)
77
- globalid (0.4.2)
78
- activesupport (>= 4.2.0)
77
+ globalid (0.5.2)
78
+ activesupport (>= 5.0)
79
79
  i18n (1.8.10)
80
80
  concurrent-ruby (~> 1.0)
81
81
  image_processing (1.12.1)
@@ -84,7 +84,7 @@ GEM
84
84
  listen (3.5.1)
85
85
  rb-fsevent (~> 0.10, >= 0.10.3)
86
86
  rb-inotify (~> 0.9, >= 0.9.10)
87
- loofah (2.10.0)
87
+ loofah (2.12.0)
88
88
  crass (~> 1.0.2)
89
89
  nokogiri (>= 1.5.9)
90
90
  mail (2.7.1)
@@ -92,12 +92,12 @@ GEM
92
92
  marcel (1.0.1)
93
93
  method_source (1.0.0)
94
94
  mini_magick (4.11.0)
95
- mini_mime (1.1.0)
96
- mini_portile2 (2.5.3)
95
+ mini_mime (1.1.1)
96
+ mini_portile2 (2.6.1)
97
97
  minitest (5.14.4)
98
- nio4r (2.5.7)
99
- nokogiri (1.11.7)
100
- mini_portile2 (~> 2.5.0)
98
+ nio4r (2.5.8)
99
+ nokogiri (1.12.4)
100
+ mini_portile2 (~> 2.6.1)
101
101
  racc (~> 1.4)
102
102
  parallel (1.20.1)
103
103
  parser (3.0.1.1)
@@ -106,29 +106,29 @@ GEM
106
106
  rack (2.2.3)
107
107
  rack-test (1.1.0)
108
108
  rack (>= 1.0, < 3)
109
- rails (6.1.4)
110
- actioncable (= 6.1.4)
111
- actionmailbox (= 6.1.4)
112
- actionmailer (= 6.1.4)
113
- actionpack (= 6.1.4)
114
- actiontext (= 6.1.4)
115
- actionview (= 6.1.4)
116
- activejob (= 6.1.4)
117
- activemodel (= 6.1.4)
118
- activerecord (= 6.1.4)
119
- activestorage (= 6.1.4)
120
- activesupport (= 6.1.4)
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)
121
121
  bundler (>= 1.15.0)
122
- railties (= 6.1.4)
122
+ railties (= 6.1.4.1)
123
123
  sprockets-rails (>= 2.0.0)
124
124
  rails-dom-testing (2.0.3)
125
125
  activesupport (>= 4.2.0)
126
126
  nokogiri (>= 1.6)
127
- rails-html-sanitizer (1.3.0)
127
+ rails-html-sanitizer (1.4.2)
128
128
  loofah (~> 2.3)
129
- railties (6.1.4)
130
- actionpack (= 6.1.4)
131
- activesupport (= 6.1.4)
129
+ railties (6.1.4.1)
130
+ actionpack (= 6.1.4.1)
131
+ activesupport (= 6.1.4.1)
132
132
  method_source
133
133
  rake (>= 0.13)
134
134
  thor (~> 1.0)
@@ -151,7 +151,7 @@ GEM
151
151
  rubocop-ast (1.7.0)
152
152
  parser (>= 3.0.1.1)
153
153
  ruby-progressbar (1.11.0)
154
- ruby-vips (2.1.2)
154
+ ruby-vips (2.1.3)
155
155
  ffi (~> 1.12)
156
156
  sprockets (4.0.2)
157
157
  concurrent-ruby (~> 1.0)
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Kamifūsen
2
2
 
3
+ Images in Ruby on Rails, as lightweight as possible!
4
+
3
5
  ![Kamifūsen in Yamagata](https://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/%E4%B8%AD%E6%B4%A5%E5%B7%9D%E9%9B%AA%E3%81%BE%E3%81%A4%E3%82%8A.jpg/1024px-%E4%B8%AD%E6%B4%A5%E5%B7%9D%E9%9B%AA%E3%81%BE%E3%81%A4%E3%82%8A.jpg)
4
6
 
5
7
  ## Installation
@@ -2,17 +2,48 @@
2
2
  # image_tag options
3
3
  options ||= {}
4
4
  alt = options[:alt]
5
- width = options[:width]
6
- height = options[:height]
5
+ async = options.has_key?(:async) ? options[:async]
6
+ : true
7
7
  klass = options[:class]
8
8
  picture_class = options[:picture_class]
9
- parameters = " loading=\"lazy\" decoding=\"async\""
10
- parameters += " alt=\"#{ options[:alt] }\"" if alt
11
- parameters += " width=\"#{ options[:width] }\"" if width
12
- parameters += " height=\"#{ options[:height]}\"" if height
13
- parameters += " class=\"#{ options[:class] }\"" if klass
9
+ width = options[:width]
10
+ height = options[:height]
11
+ if source&.metadata &&
12
+ source.metadata['analyzed'] &&
13
+ source.metadata.has_key?('width') &&
14
+ source.metadata.has_key?('height')
15
+ image_width = source.metadata['width']
16
+ image_height = source.metadata['height']
17
+ image_ratio = 1.0 * image_width / image_height
18
+ if width.nil? && height.nil?
19
+ # Prendre width et height réelles de l'image
20
+ width = image_width
21
+ height = image_height
22
+ elsif width.nil?
23
+ # Calculer la height sur ratio
24
+ width = height * image_ratio
25
+ elsif height.nil?
26
+ # Calcule la width sur ratio
27
+ height = width / image_ratio
28
+ else
29
+ # Width et height sont explicites,
30
+ # si le ratio demandé n'est pas celui de l'image,
31
+ # Redéfinir la height
32
+ width = [image_width, width].min
33
+ height = width / image_ratio
34
+ end
35
+ width = width.round
36
+ height = height.round
37
+ end
38
+ parameters = ""
39
+ parameters += " loading=\"lazy\" decoding=\"async\"" if async
40
+ parameters += " alt=\"#{ alt }\"" if alt
41
+ parameters += " width=\"#{ width }\"" if width
42
+ parameters += " height=\"#{ height }\"" if height
43
+ parameters += " class=\"#{ klass }\"" if klass
14
44
  %>
15
45
  <% if source.variable? %>
46
+ <%#= "#{image_width} x #{image_height}, #{image_ratio} ratio => #{width} x #{height}<br>".html_safe %>
16
47
  <%
17
48
  # kamifusen settings
18
49
  sizes = [320, 576, 640, 768, 992, 1152, 1200, 1400, 1536, 1984, 2400]
@@ -36,7 +67,7 @@ parameters += " class=\"#{ options[:class] }\"" if klass
36
67
  }.join(', ')
37
68
  default = url_for source.variant(resize: "#{default_width}>", quality: quality)
38
69
  %>
39
- <picture<%= " class=\"#{picture_class}\"" unless picture_class.blank? %>>
70
+ <picture<%= " class=\"#{picture_class}\"".html_safe unless picture_class.blank? %>>
40
71
  <% if Kamifusen.with_webp %>
41
72
  <source srcset="<%= srcset_webp %>" type="image/webp">
42
73
  <% end %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kamifusen
4
- VERSION = "1.2"
4
+ VERSION = "1.6"
5
5
  end
@@ -2,7 +2,6 @@
2
2
  module Kamifusen
3
3
  module ViewHelper
4
4
  def kamifusen_tag(source, options = {})
5
- image_tag(source, options)
6
5
  render "kamifusen/view", source: source, options: options
7
6
  end
8
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kamifusen
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '1.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Moulène
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-07-02 00:00:00.000000000 Z
12
+ date: 2021-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails