kamifusen 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +0 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +181 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +144 -0
- data/Rakefile +8 -0
- data/app/views/kamifusen/_view.html.erb +18 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/docs/index.html +137 -0
- data/docs/test_01.html +130 -0
- data/kamifusen.gemspec +34 -0
- data/lib/kamifusen.rb +12 -0
- data/lib/kamifusen/railtie.rb +7 -0
- data/lib/kamifusen/version.rb +5 -0
- data/lib/kamifusen/view_helper.rb +9 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fba4cc594fa4ab1ae8205a187f84b2815265127fed09c3cc3a46da87808068f1
|
4
|
+
data.tar.gz: d82f0bf97ded7f442deb90c6647918ceb312a5197a2e313bee1adebb40b1e4d2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc71b4eba1b972abf61e8204e69940589e35828d8200b47aff400524402fd071890972988d0c7af978ae602e1b11ef64ecc4229a58ee705509f639de5daa772a
|
7
|
+
data.tar.gz: 2d6bd8e27099ccfe668c1066fbd4b6e5a9456956a54d084e00bef16e3ffd3203c12210b985801d42d843fac6e290c3e263d94a4159f042a0e32839745d2742e0
|
data/.gitignore
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
/.bundle/
|
10
|
+
/doc/
|
11
|
+
/log/*.log
|
12
|
+
/pkg/
|
13
|
+
/tmp/
|
14
|
+
/test/dummy/db/*.sqlite3
|
15
|
+
/test/dummy/db/*.sqlite3-*
|
16
|
+
/test/dummy/log/*.log
|
17
|
+
/test/dummy/storage/
|
18
|
+
/test/dummy/tmp/
|
19
|
+
.byebug_history
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at contact@arnaudlevy.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
Kamifusen (0.1.1)
|
5
|
+
image_processing
|
6
|
+
rails
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actioncable (6.1.3.2)
|
12
|
+
actionpack (= 6.1.3.2)
|
13
|
+
activesupport (= 6.1.3.2)
|
14
|
+
nio4r (~> 2.0)
|
15
|
+
websocket-driver (>= 0.6.1)
|
16
|
+
actionmailbox (6.1.3.2)
|
17
|
+
actionpack (= 6.1.3.2)
|
18
|
+
activejob (= 6.1.3.2)
|
19
|
+
activerecord (= 6.1.3.2)
|
20
|
+
activestorage (= 6.1.3.2)
|
21
|
+
activesupport (= 6.1.3.2)
|
22
|
+
mail (>= 2.7.1)
|
23
|
+
actionmailer (6.1.3.2)
|
24
|
+
actionpack (= 6.1.3.2)
|
25
|
+
actionview (= 6.1.3.2)
|
26
|
+
activejob (= 6.1.3.2)
|
27
|
+
activesupport (= 6.1.3.2)
|
28
|
+
mail (~> 2.5, >= 2.5.4)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
actionpack (6.1.3.2)
|
31
|
+
actionview (= 6.1.3.2)
|
32
|
+
activesupport (= 6.1.3.2)
|
33
|
+
rack (~> 2.0, >= 2.0.9)
|
34
|
+
rack-test (>= 0.6.3)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
+
actiontext (6.1.3.2)
|
38
|
+
actionpack (= 6.1.3.2)
|
39
|
+
activerecord (= 6.1.3.2)
|
40
|
+
activestorage (= 6.1.3.2)
|
41
|
+
activesupport (= 6.1.3.2)
|
42
|
+
nokogiri (>= 1.8.5)
|
43
|
+
actionview (6.1.3.2)
|
44
|
+
activesupport (= 6.1.3.2)
|
45
|
+
builder (~> 3.1)
|
46
|
+
erubi (~> 1.4)
|
47
|
+
rails-dom-testing (~> 2.0)
|
48
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
49
|
+
activejob (6.1.3.2)
|
50
|
+
activesupport (= 6.1.3.2)
|
51
|
+
globalid (>= 0.3.6)
|
52
|
+
activemodel (6.1.3.2)
|
53
|
+
activesupport (= 6.1.3.2)
|
54
|
+
activerecord (6.1.3.2)
|
55
|
+
activemodel (= 6.1.3.2)
|
56
|
+
activesupport (= 6.1.3.2)
|
57
|
+
activestorage (6.1.3.2)
|
58
|
+
actionpack (= 6.1.3.2)
|
59
|
+
activejob (= 6.1.3.2)
|
60
|
+
activerecord (= 6.1.3.2)
|
61
|
+
activesupport (= 6.1.3.2)
|
62
|
+
marcel (~> 1.0.0)
|
63
|
+
mini_mime (~> 1.0.2)
|
64
|
+
activesupport (6.1.3.2)
|
65
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
66
|
+
i18n (>= 1.6, < 2)
|
67
|
+
minitest (>= 5.1)
|
68
|
+
tzinfo (~> 2.0)
|
69
|
+
zeitwerk (~> 2.3)
|
70
|
+
ast (2.4.2)
|
71
|
+
builder (3.2.4)
|
72
|
+
concurrent-ruby (1.1.8)
|
73
|
+
crass (1.0.6)
|
74
|
+
erubi (1.10.0)
|
75
|
+
ffi (1.15.0)
|
76
|
+
globalid (0.4.2)
|
77
|
+
activesupport (>= 4.2.0)
|
78
|
+
i18n (1.8.10)
|
79
|
+
concurrent-ruby (~> 1.0)
|
80
|
+
image_processing (1.12.1)
|
81
|
+
mini_magick (>= 4.9.5, < 5)
|
82
|
+
ruby-vips (>= 2.0.17, < 3)
|
83
|
+
listen (3.5.1)
|
84
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
85
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
86
|
+
loofah (2.9.1)
|
87
|
+
crass (~> 1.0.2)
|
88
|
+
nokogiri (>= 1.5.9)
|
89
|
+
mail (2.7.1)
|
90
|
+
mini_mime (>= 0.1.1)
|
91
|
+
marcel (1.0.1)
|
92
|
+
method_source (1.0.0)
|
93
|
+
mini_magick (4.11.0)
|
94
|
+
mini_mime (1.0.3)
|
95
|
+
minitest (5.14.4)
|
96
|
+
nio4r (2.5.7)
|
97
|
+
nokogiri (1.11.4-x86_64-darwin)
|
98
|
+
racc (~> 1.4)
|
99
|
+
parallel (1.20.1)
|
100
|
+
parser (3.0.1.1)
|
101
|
+
ast (~> 2.4.1)
|
102
|
+
racc (1.5.2)
|
103
|
+
rack (2.2.3)
|
104
|
+
rack-test (1.1.0)
|
105
|
+
rack (>= 1.0, < 3)
|
106
|
+
rails (6.1.3.2)
|
107
|
+
actioncable (= 6.1.3.2)
|
108
|
+
actionmailbox (= 6.1.3.2)
|
109
|
+
actionmailer (= 6.1.3.2)
|
110
|
+
actionpack (= 6.1.3.2)
|
111
|
+
actiontext (= 6.1.3.2)
|
112
|
+
actionview (= 6.1.3.2)
|
113
|
+
activejob (= 6.1.3.2)
|
114
|
+
activemodel (= 6.1.3.2)
|
115
|
+
activerecord (= 6.1.3.2)
|
116
|
+
activestorage (= 6.1.3.2)
|
117
|
+
activesupport (= 6.1.3.2)
|
118
|
+
bundler (>= 1.15.0)
|
119
|
+
railties (= 6.1.3.2)
|
120
|
+
sprockets-rails (>= 2.0.0)
|
121
|
+
rails-dom-testing (2.0.3)
|
122
|
+
activesupport (>= 4.2.0)
|
123
|
+
nokogiri (>= 1.6)
|
124
|
+
rails-html-sanitizer (1.3.0)
|
125
|
+
loofah (~> 2.3)
|
126
|
+
railties (6.1.3.2)
|
127
|
+
actionpack (= 6.1.3.2)
|
128
|
+
activesupport (= 6.1.3.2)
|
129
|
+
method_source
|
130
|
+
rake (>= 0.8.7)
|
131
|
+
thor (~> 1.0)
|
132
|
+
rainbow (3.0.0)
|
133
|
+
rake (13.0.3)
|
134
|
+
rb-fsevent (0.11.0)
|
135
|
+
rb-inotify (0.10.1)
|
136
|
+
ffi (~> 1.0)
|
137
|
+
regexp_parser (2.1.1)
|
138
|
+
rexml (3.2.5)
|
139
|
+
rubocop (1.15.0)
|
140
|
+
parallel (~> 1.10)
|
141
|
+
parser (>= 3.0.0.0)
|
142
|
+
rainbow (>= 2.2.2, < 4.0)
|
143
|
+
regexp_parser (>= 1.8, < 3.0)
|
144
|
+
rexml
|
145
|
+
rubocop-ast (>= 1.5.0, < 2.0)
|
146
|
+
ruby-progressbar (~> 1.7)
|
147
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
148
|
+
rubocop-ast (1.5.0)
|
149
|
+
parser (>= 3.0.1.1)
|
150
|
+
ruby-progressbar (1.11.0)
|
151
|
+
ruby-vips (2.1.2)
|
152
|
+
ffi (~> 1.12)
|
153
|
+
sprockets (4.0.2)
|
154
|
+
concurrent-ruby (~> 1.0)
|
155
|
+
rack (> 1, < 3)
|
156
|
+
sprockets-rails (3.2.2)
|
157
|
+
actionpack (>= 4.0)
|
158
|
+
activesupport (>= 4.0)
|
159
|
+
sprockets (>= 3.0.0)
|
160
|
+
sqlite3 (1.4.2)
|
161
|
+
thor (1.1.0)
|
162
|
+
tzinfo (2.0.4)
|
163
|
+
concurrent-ruby (~> 1.0)
|
164
|
+
unicode-display_width (2.0.0)
|
165
|
+
websocket-driver (0.7.3)
|
166
|
+
websocket-extensions (>= 0.1.0)
|
167
|
+
websocket-extensions (0.1.5)
|
168
|
+
zeitwerk (2.4.2)
|
169
|
+
|
170
|
+
PLATFORMS
|
171
|
+
x86_64-darwin-20
|
172
|
+
|
173
|
+
DEPENDENCIES
|
174
|
+
Kamifusen!
|
175
|
+
listen
|
176
|
+
rake (~> 13.0)
|
177
|
+
rubocop (~> 1.7)
|
178
|
+
sqlite3
|
179
|
+
|
180
|
+
BUNDLED WITH
|
181
|
+
2.2.7
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Sébastien Moulène
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Arnaud Levy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# Kamifūsen
|
2
|
+
|
3
|
+
![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
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Simply use `kamifusen_tag` instead of `image_tag` in your rails views.## What's the problem?
|
8
|
+
|
9
|
+
### The initial situation
|
10
|
+
|
11
|
+
When you use an image in a website, the basic code is:
|
12
|
+
```html
|
13
|
+
<img src="image.jpg" alt="A nice image">
|
14
|
+
```
|
15
|
+
|
16
|
+
which in rails can be generated with (assuming the image is an active storage blob):
|
17
|
+
```erb
|
18
|
+
<%= image_tag object.image, alt: 'A nice image' %>
|
19
|
+
```
|
20
|
+
|
21
|
+
If the image is a 5 mo jpg file, 3500px width by 5000px height, then your page is very heavy, which is bad for the user and bad for the environment.
|
22
|
+
|
23
|
+
There are many things to do to improve the weight and the experience, as we'll now see.
|
24
|
+
|
25
|
+
### Ways to optimize
|
26
|
+
|
27
|
+
#### 1. Resize the image server side
|
28
|
+
|
29
|
+
If the screen you use is a mobile with a 375px wide screen, retina, then the image should be resized server side to a maximum of 750px. Ideally, if the image in the page is shown at 200px wide, then it should be resized to a 400px width. The technology used to manage that is the srcset.
|
30
|
+
|
31
|
+
The sizes are managed like:
|
32
|
+
|
33
|
+
```html
|
34
|
+
<img srcset="image-320w.jpg 320w,
|
35
|
+
image-480w.jpg 480w,
|
36
|
+
image-800w.jpg 800w"
|
37
|
+
sizes="(max-width: 320px) 280px,
|
38
|
+
(max-width: 480px) 440px,
|
39
|
+
800px"
|
40
|
+
src="image-800w.jpg" alt="A nice image">
|
41
|
+
```
|
42
|
+
|
43
|
+
And the retina like:
|
44
|
+
|
45
|
+
```html
|
46
|
+
<img srcset="image-320w.jpg,
|
47
|
+
image-480w.jpg 1.5x,
|
48
|
+
image-640w.jpg 2x"
|
49
|
+
src="image-640w.jpg" alt="A nice image">
|
50
|
+
```
|
51
|
+
|
52
|
+
#### 2. Remove any metadata (EXIF...) and optimize compression (tinyfy)
|
53
|
+
|
54
|
+
Images can contain interesting metadata, which are heavy and useless in a standard web context. The technology used is imagemagick, through active storage.
|
55
|
+
|
56
|
+
#### 3. Provide more efficient formats (webp, AVIF)
|
57
|
+
|
58
|
+
Webp and AVIF are more efficient formats than jpg and png. They allow better compression with lower quality, but are not compatible with all browsers. The technology used is picture, allowing multiple sources to be defined and letting the browser choose the one it can handle.
|
59
|
+
|
60
|
+
```html
|
61
|
+
<picture>
|
62
|
+
<source type="image/avif" srcset="image.avif">
|
63
|
+
<source type="image/webp" srcset="image.webp">
|
64
|
+
<img src="image.jpg" alt="A nice image">
|
65
|
+
</picture>
|
66
|
+
```
|
67
|
+
|
68
|
+
#### 4. Load and decode asynchronously
|
69
|
+
|
70
|
+
```
|
71
|
+
<img decoding="async" … />
|
72
|
+
```
|
73
|
+
|
74
|
+
### The final situation
|
75
|
+
|
76
|
+
https://sebousan.github.io/kamifusen/
|
77
|
+
|
78
|
+
The new helper is:
|
79
|
+
```erb
|
80
|
+
<%= kamifusen_tag object.image, alt: 'A nice image' %>
|
81
|
+
```
|
82
|
+
|
83
|
+
It generates a code like:
|
84
|
+
```html
|
85
|
+
<picture>
|
86
|
+
<source srcset="image-800w.avif, image-1600w.avif 2x" type="image/avif" media="(min-width: 800px)">
|
87
|
+
<source srcset="image-400w.avif, image-800w.avif 2x" type="image/avif" media="(min-width: 400px)">
|
88
|
+
<source srcset="image-800w.webp, image-1600w.webp 2x" type="image/webp" media="(min-width: 800px)">
|
89
|
+
<source srcset="image-400w.webp, image-800w.webp 2x" type="image/webp" media="(min-width: 400px)">
|
90
|
+
<source srcset="image-800w.jpg, image-1600w.jpg 2x" type="image/jpg" media="(min-width: 800px)">
|
91
|
+
<source srcset="image-400w.jpg, image-800w.jpg 2x" type="image/jpg" media="(min-width: 400px)">
|
92
|
+
<img src="image-800.jpg" alt="A nice image" srcset="image-800.jpg, image-1600.jpg 2x">
|
93
|
+
</picture>
|
94
|
+
```
|
95
|
+
|
96
|
+
## Installation
|
97
|
+
|
98
|
+
Add this line to your application's Gemfile:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
gem 'kamifusen'
|
102
|
+
```
|
103
|
+
|
104
|
+
And then execute:
|
105
|
+
|
106
|
+
$ bundle install
|
107
|
+
|
108
|
+
Or install it yourself as:
|
109
|
+
|
110
|
+
$ gem install kamifusen
|
111
|
+
|
112
|
+
## References
|
113
|
+
|
114
|
+
- https://developer.mozilla.org/fr/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images
|
115
|
+
- https://cloudfour.com/thinks/responsive-images-101-definitions/
|
116
|
+
- https://www.industrialempathy.com/posts/image-optimizations/
|
117
|
+
- https://github.com/google/eleventy-high-performance-blog/blob/60902bfdaf764f5b16b2af62cf10f63e0e74efbc/README.md#images
|
118
|
+
- http://rbuchberger.github.io/jekyll_picture_tag/
|
119
|
+
- https://vitobotta.com/2020/09/24/resize-and-optimise-images-on-upload-with-activestorage/
|
120
|
+
- https://www.filamentgroup.com/lab/load-css-simpler/
|
121
|
+
- https://mattwilcox.net/web-development/keeping-srcset-and-sizes-under-control
|
122
|
+
- https://developers.google.com/web/fundamentals/design-and-ux/responsive/images?hl=fr
|
123
|
+
- https://www.smashingmagazine.com/2014/05/responsive-images-done-right-guide-picture-srcset/
|
124
|
+
- https://web.dev/use-srcset-to-automatically-choose-the-right-image/
|
125
|
+
- https://web.dev/use-imagemin-to-compress-images/
|
126
|
+
- https://code.luasoftware.com/tutorials/bootstrap/responsive-image-with-srcset-using-bootstrap-breakpoints/
|
127
|
+
|
128
|
+
## Development
|
129
|
+
|
130
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
131
|
+
|
132
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
133
|
+
|
134
|
+
## Contributing
|
135
|
+
|
136
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kamifusen. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/kamifusen/blob/master/CODE_OF_CONDUCT.md).
|
137
|
+
|
138
|
+
## License
|
139
|
+
|
140
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
141
|
+
|
142
|
+
## Code of Conduct
|
143
|
+
|
144
|
+
Everyone interacting in the Kamifusen project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/kamifusen/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
<%
|
2
|
+
# image_tag options
|
3
|
+
alt = options[:alt]
|
4
|
+
width = options[:width]
|
5
|
+
height = options[:height]
|
6
|
+
# kamifusen settings
|
7
|
+
sizes = [320, 576, 640, 768, 992, 1152, 1200, 1400, 1536, 1984, 2400]
|
8
|
+
quality = 80
|
9
|
+
# Computing
|
10
|
+
sizes.reject! { |size| size > width * 2 } if width
|
11
|
+
webps = sizes.map { |size| "#{ url_for source.variant(resize: "#{size}>", format: :webp, quality: quality) } #{ size } vw" }.join(', ')
|
12
|
+
jpgs = sizes.map { |size| "#{ url_for source.variant(resize: "#{size}>", format: :jpg, quality: quality) } #{ size } vw" }.join(', ')
|
13
|
+
default = url_for source.variant(resize: "#{sizes.max}>", format: :jpg, quality: quality)
|
14
|
+
%>
|
15
|
+
<picture>
|
16
|
+
<source srcset="<%= webps %>">
|
17
|
+
<img src="<%= default %>" srcset="<%= jpgs %>" alt="<%= alt %>" loading="lazy" decoding="async"<%= raw " width=\"#{ width }\"" if width %><%= raw " height=\"#{ height}\"" if height %>>
|
18
|
+
</picture>
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "kamifusen"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/docs/index.html
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
6
|
+
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
7
|
+
<meta name="description" content="Image optimization">
|
8
|
+
<title>Test</title>
|
9
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<div class="container py-4">
|
13
|
+
<h1>Test responsive images</h1>
|
14
|
+
</div>
|
15
|
+
<hr>
|
16
|
+
<div class="container">
|
17
|
+
<h2>B2bylon</h2>
|
18
|
+
<img src="https://picsum.photos/1600/1000.jpg"
|
19
|
+
srcset="https://picsum.photos/320/150.jpg 320w,
|
20
|
+
https://picsum.photos/640/300.jpg 640w,
|
21
|
+
https://picsum.photos/1600/1000.jpg"
|
22
|
+
sizes="100vw"
|
23
|
+
alt="">
|
24
|
+
</div>
|
25
|
+
<hr>
|
26
|
+
<div class="container">
|
27
|
+
<h2>Mattwilcox</h2>
|
28
|
+
<p>https://mattwilcox.net/web-development/keeping-srcset-and-sizes-under-control</p>
|
29
|
+
<img src="https://picsum.photos/1600/1000.jpg"
|
30
|
+
alt=""
|
31
|
+
sizes="(min-width:1420px) 610px,
|
32
|
+
(min-width:1320px) 500px,
|
33
|
+
(min-width:1000px) 430px,
|
34
|
+
(min-width:620px) 580px,
|
35
|
+
280px"
|
36
|
+
srcset="https://picsum.photos/280/150.jpg 280w,
|
37
|
+
https://picsum.photos/430/300.jpg 430w,
|
38
|
+
https://picsum.photos/500/300.jpg 500w,
|
39
|
+
https://picsum.photos/560/400.jpg 560w,
|
40
|
+
https://picsum.photos/580/400.jpg 580w,
|
41
|
+
https://picsum.photos/610/400.jpg 610w,
|
42
|
+
https://picsum.photos/860/600.jpg 860w,
|
43
|
+
https://picsum.photos/1000/600.jpg 1000w,
|
44
|
+
https://picsum.photos/1220/800.jpg 1220w" />
|
45
|
+
</div>
|
46
|
+
<hr>
|
47
|
+
<div class="container-fluid">
|
48
|
+
<h2>Image with full width</h2>
|
49
|
+
</div>
|
50
|
+
<div class="mb-4">
|
51
|
+
<picture>
|
52
|
+
<source media="(max-width: 320px)" srcset="https://picsum.photos/320/180.webp, https://picsum.photos/640/360.webp 2x" type="image/webp">
|
53
|
+
<source media="(max-width: 375px)" srcset="https://picsum.photos/375/210.webp, https://picsum.photos/750/420.webp 2x" type="image/webp">
|
54
|
+
<source media="(max-width: 414px)" srcset="https://picsum.photos/414/232.webp, https://picsum.photos/828/464.webp 2x" type="image/webp">
|
55
|
+
<source media="(max-width: 768px)" srcset="https://picsum.photos/768/432.webp, https://picsum.photos/1536/864.webp 2x" type="image/webp">
|
56
|
+
<source media="(max-width: 1024px)" srcset="https://picsum.photos/1024/576.webp, https://picsum.photos/2048/1152.webp 2x" type="image/webp">
|
57
|
+
<source srcset="https://picsum.photos/1920/1080.webp, https://picsum.photos/3840/2160.webp 2x" type="image/webp">
|
58
|
+
<source media="(max-width: 320px)" srcset="https://picsum.photos/320/180.jpg, https://picsum.photos/640/420.jpg 2x" type="image/jpg">
|
59
|
+
<source media="(max-width: 375px)" srcset="https://picsum.photos/375/210.jpg, https://picsum.photos/750/420.jpg 2x" type="image/jpg">
|
60
|
+
<source media="(max-width: 414px)" srcset="https://picsum.photos/414/232.jpg, https://picsum.photos/828/464.jpg 2x" type="image/jpg">
|
61
|
+
<source media="(max-width: 768px)" srcset="https://picsum.photos/768/432.jpg, https://picsum.photos/1536/864.jpg 2x" type="image/jpg">
|
62
|
+
<source media="(max-width: 1024px)" srcset="https://picsum.photos/1024/576.jpg, https://picsum.photos/2048/1152.jpg 2x" type="image/jpg">
|
63
|
+
<source srcset="https://picsum.photos/1920/1080.jpg, https://picsum.photos/3840/2160.jpg 2x" type="image/jpg">
|
64
|
+
<img src="https://picsum.photos/1920/1080.jpg" alt="A nice image" class="img-fluid" width="1920" height="1080">
|
65
|
+
</picture>
|
66
|
+
</div>
|
67
|
+
<hr>
|
68
|
+
<div class="container">
|
69
|
+
<h2>Image with variable width (eventually in a Bootstrap column)</h2>
|
70
|
+
<ul>
|
71
|
+
<li>container col-md-1 col-6</li>
|
72
|
+
<li>container col-md-2 col-6</li>
|
73
|
+
<li>container col-md-3 col-sm-6</li>
|
74
|
+
<li>container col-md-4 col-sm-6</li>
|
75
|
+
<li>container col-md-6</li>
|
76
|
+
<li>container col-md-8</li>
|
77
|
+
<li>container-fluid col-md-1 col-6</li>
|
78
|
+
<li>container-fluid col-md-2 col-6</li>
|
79
|
+
<li>container-fluid col-md-3 col-sm-6</li>
|
80
|
+
<li>container-fluid col-md-4 col-sm-6</li>
|
81
|
+
<li>container-fluid col-md-6</li>
|
82
|
+
<li>container-fluid col-md-8</li>
|
83
|
+
</ul>
|
84
|
+
<div class="row row-cols-2 row-cols-md-3 row-cols-lg-4 g-4">
|
85
|
+
<div class="col-6">
|
86
|
+
<picture>
|
87
|
+
<source media="(max-width: 320px)" srcset="https://picsum.photos/320/180.webp, https://picsum.photos/640/360.webp 2x" type="image/webp">
|
88
|
+
<source media="(max-width: 375px)" srcset="https://picsum.photos/375/210.webp, https://picsum.photos/750/420.webp 2x" type="image/webp">
|
89
|
+
<source media="(max-width: 414px)" srcset="https://picsum.photos/414/232.webp, https://picsum.photos/828/464.webp 2x" type="image/webp">
|
90
|
+
<source media="(max-width: 768px)" srcset="https://picsum.photos/768/432.webp, https://picsum.photos/1536/864.webp 2x" type="image/webp">
|
91
|
+
<source media="(max-width: 1024px)" srcset="https://picsum.photos/1024/576.webp, https://picsum.photos/2048/1152.webp 2x" type="image/webp">
|
92
|
+
<source srcset="https://picsum.photos/306/172.webp, https://picsum.photos/612/344.webp 2x" type="image/webp">
|
93
|
+
<source media="(max-width: 320px)" srcset="https://picsum.photos/320/180.jpg, https://picsum.photos/640/360.jpg 2x" type="image/jpg">
|
94
|
+
<source media="(max-width: 375px)" srcset="https://picsum.photos/375/210.jpg, https://picsum.photos/750/420.jpg 2x" type="image/jpg">
|
95
|
+
<source media="(max-width: 414px)" srcset="https://picsum.photos/414/232.jpg, https://picsum.photos/828/464.jpg 2x" type="image/jpg">
|
96
|
+
<source media="(max-width: 768px)" srcset="https://picsum.photos/768/432.jpg, https://picsum.photos/1536/864.jpg 2x" type="image/jpg">
|
97
|
+
<source media="(max-width: 1024px)" srcset="https://picsum.photos/1024/576.jpg, https://picsum.photos/2048/1152.jpg 2x" type="image/jpg">
|
98
|
+
<source srcset="https://picsum.photos/306/172.jpg, https://picsum.photos/612/344.jpg 2x" type="image/jpg">
|
99
|
+
<img src="https://picsum.photos/306/172.jpg" alt="A nice image" class="img-fluid" width="306" height="172">
|
100
|
+
</picture>
|
101
|
+
</div>
|
102
|
+
<div class="col">
|
103
|
+
<picture>
|
104
|
+
<source media="(max-width: 320px)" srcset="https://picsum.photos/320/180.webp, https://picsum.photos/640/360.webp 2x" type="image/webp">
|
105
|
+
<source media="(max-width: 375px)" srcset="https://picsum.photos/375/210.webp, https://picsum.photos/750/420.webp 2x" type="image/webp">
|
106
|
+
<source media="(max-width: 414px)" srcset="https://picsum.photos/414/232.webp, https://picsum.photos/828/464.webp 2x" type="image/webp">
|
107
|
+
<source media="(max-width: 768px)" srcset="https://picsum.photos/768/432.webp, https://picsum.photos/1536/864.webp 2x" type="image/webp">
|
108
|
+
<source media="(max-width: 1024px)" srcset="https://picsum.photos/1024/576.webp, https://picsum.photos/2048/1152.webp 2x" type="image/webp">
|
109
|
+
<source srcset="https://picsum.photos/414/232.webp, https://picsum.photos/612/344.webp 2x" type="image/webp">
|
110
|
+
<source media="(max-width: 320px)" srcset="https://picsum.photos/320/180.jpg, https://picsum.photos/640/360.jpg 2x" type="image/jpg">
|
111
|
+
<source media="(max-width: 375px)" srcset="https://picsum.photos/375/210.jpg, https://picsum.photos/750/420.jpg 2x" type="image/jpg">
|
112
|
+
<source media="(max-width: 414px)" srcset="https://picsum.photos/414/232.jpg, https://picsum.photos/828/464.jpg 2x" type="image/jpg">
|
113
|
+
<source media="(max-width: 768px)" srcset="https://picsum.photos/768/432.jpg, https://picsum.photos/1536/864.jpg 2x" type="image/jpg">
|
114
|
+
<source media="(max-width: 1024px)" srcset="https://picsum.photos/1024/576.jpg, https://picsum.photos/2048/1152.jpg 2x" type="image/jpg">
|
115
|
+
<source srcset="https://picsum.photos/306/172.jpg, https://picsum.photos/612/344.jpg 2x" type="image/jpg">
|
116
|
+
<img src="https://picsum.photos/306/172.jpg" alt="A nice image" class="img-fluid" width="306" height="172">
|
117
|
+
</picture>
|
118
|
+
</div>
|
119
|
+
</div>
|
120
|
+
</div>
|
121
|
+
<hr>
|
122
|
+
<div class="container">
|
123
|
+
<h2>Images with fixed width in pixels (600px)</h2>
|
124
|
+
<picture>
|
125
|
+
<source media="(max-width: 320px)" srcset="https://picsum.photos/320/180.webp, https://picsum.photos/640/360.webp 2x" type="image/webp">
|
126
|
+
<source media="(max-width: 375px)" srcset="https://picsum.photos/375/210.webp, https://picsum.photos/750/420.webp 2x" type="image/webp">
|
127
|
+
<source media="(max-width: 414px)" srcset="https://picsum.photos/414/232.webp, https://picsum.photos/828/464.webp 2x" type="image/webp">
|
128
|
+
<source srcset="https://picsum.photos/600/400.webp, https://picsum.photos/1200/800.webp 2x" type="image/webp">
|
129
|
+
<source media="(max-width: 320px)" srcset="https://picsum.photos/320/180.jpg, https://picsum.photos/640/360.jpg 2x" type="image/jpg">
|
130
|
+
<source media="(max-width: 375px)" srcset="https://picsum.photos/375/210.jpg, https://picsum.photos/750/420.jpg 2x" type="image/jpg">
|
131
|
+
<source media="(max-width: 414px)" srcset="https://picsum.photos/414/232.jpg, https://picsum.photos/828/464.jpg 2x" type="image/jpg">
|
132
|
+
<source srcset="https://picsum.photos/600/400.jpg, https://picsum.photos/1200/800.jpg 2x" type="image/jpg">
|
133
|
+
<img src="https://picsum.photos/600/400.jpg" alt="A nice image" class="img-fluid" width="600" height="400">
|
134
|
+
</picture>
|
135
|
+
</div>
|
136
|
+
</body>
|
137
|
+
</html>
|
data/docs/test_01.html
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
|
4
|
+
<head>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
7
|
+
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
8
|
+
<meta name="description" content="Image optimization">
|
9
|
+
<title>Test</title>
|
10
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"
|
11
|
+
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
|
12
|
+
</head>
|
13
|
+
|
14
|
+
<body>
|
15
|
+
<h2>Simple 100%</h2>
|
16
|
+
|
17
|
+
- Retina : gérer par Chrome / FF / SF
|
18
|
+
- Safari : srcset dans source pas supporté
|
19
|
+
|
20
|
+
<picture>
|
21
|
+
<source
|
22
|
+
sizes="
|
23
|
+
(min-width:1400px) 1400px,
|
24
|
+
(min-width:1200px) 1200px,
|
25
|
+
(min-width:992px) 992px,
|
26
|
+
(min-width:768px) 768px,
|
27
|
+
(min-width:576px) 576px,
|
28
|
+
320px"
|
29
|
+
|
30
|
+
srcset="https://picsum.photos/320.webp 320w,
|
31
|
+
https://picsum.photos/576.webp 576w,
|
32
|
+
https://picsum.photos/768.webp 768w,
|
33
|
+
https://picsum.photos/992.webp 992w,
|
34
|
+
https://picsum.photos/1200.webp 1200w,
|
35
|
+
https://picsum.photos/1400.webp 1400w,
|
36
|
+
https://picsum.photos/640.webp 640w,
|
37
|
+
https://picsum.photos/1152.webp 1152w,
|
38
|
+
https://picsum.photos/1536.webp 1536w,
|
39
|
+
https://picsum.photos/1984.webp 1984w,
|
40
|
+
https://picsum.photos/2400.webp 2400w,
|
41
|
+
https://picsum.photos/2800.webp 2800w,
|
42
|
+
"
|
43
|
+
type="image/webp"
|
44
|
+
>
|
45
|
+
<source
|
46
|
+
sizes="
|
47
|
+
(min-width:1400px) 1400px,
|
48
|
+
(min-width:1200px) 1200px,
|
49
|
+
(min-width:992px) 992px,
|
50
|
+
(min-width:768px) 768px,
|
51
|
+
(min-width:576px) 576px,
|
52
|
+
320px"
|
53
|
+
srcset="https://picsum.photos/320.jpg 320w,
|
54
|
+
https://picsum.photos/576.jpg 576w,
|
55
|
+
https://picsum.photos/768.jpg 768w,
|
56
|
+
https://picsum.photos/992.jpg 992w,
|
57
|
+
https://picsum.photos/1200.jpg 1200w,
|
58
|
+
https://picsum.photos/1400.jpg 1400w
|
59
|
+
"
|
60
|
+
type="image/jpg"
|
61
|
+
>
|
62
|
+
<img
|
63
|
+
src="https://picsum.photos/320.jpg"
|
64
|
+
sizes="
|
65
|
+
(min-width:1400px) 1400px,
|
66
|
+
(min-width:1200px) 1200px,
|
67
|
+
(min-width:992px) 992px,
|
68
|
+
(min-width:768px) 768px,
|
69
|
+
(min-width:576px) 576px,
|
70
|
+
320px"
|
71
|
+
srcset="https://picsum.photos/320.jpg 320w,
|
72
|
+
https://picsum.photos/576.jpg 576w,
|
73
|
+
https://picsum.photos/768.jpg 768w,
|
74
|
+
https://picsum.photos/992.jpg 992w,
|
75
|
+
https://picsum.photos/1200.jpg 1200w,
|
76
|
+
https://picsum.photos/1400.jpg 1400w
|
77
|
+
"
|
78
|
+
class="img-fluid">
|
79
|
+
</picture>
|
80
|
+
|
81
|
+
<h2>col-12 col-md-6 col-lg-4</h2>
|
82
|
+
|
83
|
+
<div class="container">
|
84
|
+
<div class="row">
|
85
|
+
<div class="col-12 col-md-6 col-lg-4" style="background-color: pink;">
|
86
|
+
<picture>
|
87
|
+
<source sizes="
|
88
|
+
(min-width:992px) 33vw,
|
89
|
+
(min-width:768px) 50vw,
|
90
|
+
100vw"
|
91
|
+
srcset="https://picsum.photos/320.webp 320w,
|
92
|
+
https://picsum.photos/576.webp 576w,
|
93
|
+
https://picsum.photos/768.webp 768w,
|
94
|
+
https://picsum.photos/992.webp 992w,
|
95
|
+
https://picsum.photos/1200.webp 1200w,
|
96
|
+
https://picsum.photos/1400.webp 1400w,
|
97
|
+
|
98
|
+
https://picsum.photos/640.webp 640w,
|
99
|
+
https://picsum.photos/1152.webp 1152w,
|
100
|
+
https://picsum.photos/1536.webp 1536w,
|
101
|
+
https://picsum.photos/1984.webp 1984w,
|
102
|
+
https://picsum.photos/2400.webp 2400w,
|
103
|
+
https://picsum.photos/2800.webp 2800w
|
104
|
+
"
|
105
|
+
type="image/webp">
|
106
|
+
<source sizes="
|
107
|
+
(min-width:768px) 50vw,
|
108
|
+
100vw" srcset="https://picsum.photos/320.jpg 320w,
|
109
|
+
https://picsum.photos/576.jpg 576w,
|
110
|
+
https://picsum.photos/768.jpg 768w,
|
111
|
+
https://picsum.photos/992.jpg 992w,
|
112
|
+
https://picsum.photos/1200.jpg 1200w,
|
113
|
+
https://picsum.photos/1400.jpg 1400w
|
114
|
+
" type="image/jpg">
|
115
|
+
<img src="https://picsum.photos/320.jpg" sizes="
|
116
|
+
(min-width:768px) 50vw,
|
117
|
+
100vw" srcset="https://picsum.photos/320.jpg 320w,
|
118
|
+
https://picsum.photos/576.jpg 576w,
|
119
|
+
https://picsum.photos/768.jpg 768w,
|
120
|
+
https://picsum.photos/992.jpg 992w,
|
121
|
+
https://picsum.photos/1200.jpg 1200w,
|
122
|
+
https://picsum.photos/1400.jpg 1400w
|
123
|
+
" class="img-fluid">
|
124
|
+
</picture>
|
125
|
+
</div>
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
</body>
|
129
|
+
|
130
|
+
</html>
|
data/kamifusen.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/kamifusen/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "kamifusen"
|
7
|
+
spec.version = Kamifusen::VERSION
|
8
|
+
spec.authors = ["Sébastien Moulène", "Arnaud Levy"]
|
9
|
+
spec.email = ["sebousan@gmail.com", "contact@arnaudlevy.com"]
|
10
|
+
|
11
|
+
spec.summary = "Images, light as balloons"
|
12
|
+
spec.description = "Image multiple optimizing: webp, srcset, server side resize."
|
13
|
+
spec.homepage = "https://github.com/sebousan/kamifusen"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/sebousan/kamifusen"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_dependency "rails"
|
30
|
+
spec.add_dependency "image_processing"
|
31
|
+
|
32
|
+
spec.add_development_dependency "listen"
|
33
|
+
spec.add_development_dependency "sqlite3"
|
34
|
+
end
|
data/lib/kamifusen.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kamifusen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sébastien Moulène
|
8
|
+
- Arnaud Levy
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: image_processing
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: listen
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: sqlite3
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
description: 'Image multiple optimizing: webp, srcset, server side resize.'
|
71
|
+
email:
|
72
|
+
- sebousan@gmail.com
|
73
|
+
- contact@arnaudlevy.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rubocop.yml"
|
80
|
+
- CHANGELOG.md
|
81
|
+
- CODE_OF_CONDUCT.md
|
82
|
+
- Gemfile
|
83
|
+
- Gemfile.lock
|
84
|
+
- LICENSE
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.md
|
87
|
+
- Rakefile
|
88
|
+
- app/views/kamifusen/_view.html.erb
|
89
|
+
- bin/console
|
90
|
+
- bin/setup
|
91
|
+
- docs/index.html
|
92
|
+
- docs/test_01.html
|
93
|
+
- kamifusen.gemspec
|
94
|
+
- lib/kamifusen.rb
|
95
|
+
- lib/kamifusen/railtie.rb
|
96
|
+
- lib/kamifusen/version.rb
|
97
|
+
- lib/kamifusen/view_helper.rb
|
98
|
+
homepage: https://github.com/sebousan/kamifusen
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata:
|
102
|
+
homepage_uri: https://github.com/sebousan/kamifusen
|
103
|
+
source_code_uri: https://github.com/sebousan/kamifusen
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.4.0
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubygems_version: 3.1.4
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Images, light as balloons
|
123
|
+
test_files: []
|