jekyll_img 0.1.5 → 0.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: 680dc86da728e4001fcbaf29a400b217690bd0242dd64a85a38e803286e0caa6
4
- data.tar.gz: 53e917f32db474dd507794e8467cd5e1fc6e3036428133e1b27f48fea0be4e4b
3
+ metadata.gz: 893b2811f139eeae284d17d29a4b9c6b8348aebaf7b5fd54015bda14316bea17
4
+ data.tar.gz: 58f626e32417dfa0790115903453b575cacbab46d312144f741dbec6b05eb458
5
5
  SHA512:
6
- metadata.gz: c1792d517f0913bf3ef12a2c116e27f02d35ba56cf783d2bb230f0258c388a58861ad7e212783e4745f9a4ca261193e327d86fb965f2a576525ab54ae607c42b
7
- data.tar.gz: 1c7f2ecc873f7b625bf18e42f50c191ccfeee09dcbc2a4a502b3f02ad8d81f1488730a51b9e9beb5580c13791e5bf1f784810aa4031d3c180db4d4075dd6940a
6
+ metadata.gz: d43b8d2c08e13776f29fa59d56750369243909ad74cb4ff66add5050576d49e83cf53a997932f3bf12797fa0fc67ec2e65f9fa782c8a201323a92c0f6c004435
7
+ data.tar.gz: 0ee7e15f89ef2a4f9755b418bd26893edcd77b3cdaa7c3015b6923509d0a0b077b1700161be9aeef227bd8f7b9fd39067e57e527d5ade7787bab577912a77019
data/CHANGELOG.md CHANGED
@@ -1,16 +1,42 @@
1
+ # Change Log
2
+
3
+ ## 0.1.6 / 2023-08-10
4
+
5
+ * `.webp` file type is assumed and no longer needs to be specified.
6
+ For example, instead of writing this:
7
+
8
+ ```html
9
+ {% img src="blah.webp" %}
10
+ ```
11
+
12
+ You can now write:
13
+
14
+ ```html
15
+ {% img src="blah" %}
16
+ ```
17
+
18
+
1
19
  ## 0.1.5 / 2023-05-30
2
- * Updated dependencies
20
+
21
+ * Updated dependencies
22
+
3
23
 
4
24
  ## 0.1.4 / 2023-04-02
5
- * Added [`attribution` support](https://github.com/mslinn/jekyll_plugin_support#subclass-attribution).
6
- * Fixed `style=' false'` that appeared when the `style` and `wrapper_style` attributes were not provided.
25
+
26
+ * Added [`attribution` support](https://github.com/mslinn/jekyll_plugin_support#subclass-attribution).
27
+ * Fixed `style=' false'` that appeared when the `style` and `wrapper_style` attributes were not provided.
28
+
7
29
 
8
30
  ## 0.1.3 / 2023-02-22
9
- * Added `img/continue_on_error` configuration parameter.
31
+
32
+ * Added `img/continue_on_error` configuration parameter.
33
+
10
34
 
11
35
  ## 0.1.2 / 2023-02-14
12
- * Fixed `img_props.rb:91:in `size_unit_specified?': undefined method `end_with?' for false:FalseClass (NoMethodError)`
36
+
37
+ * Fixed `img_props.rb:91:in `size_unit_specified?': undefined method `end_with?' for false:FalseClass (NoMethodError)`
13
38
 
14
39
 
15
40
  ## 0.1.1 / 2023-02-12
16
- * Initial release
41
+
42
+ * Initial release
data/README.md CHANGED
@@ -1,51 +1,102 @@
1
- `jekyll_img`
2
- [![Gem Version](https://badge.fury.io/rb/jekyll_img.svg)](https://badge.fury.io/rb/jekyll_img)
3
- ===========
1
+ # `jekyll_img` [![Gem Version](https://badge.fury.io/rb/jekyll_img.svg)](https://badge.fury.io/rb/jekyll_img)
2
+
4
3
 
5
4
  `Jekyll_img` is a Jekyll plugin that embeds images in HTML documents, with alignment options,
6
5
  flexible resizing, default styling, overridable styling, an optional caption, and an optional URL.
7
6
 
7
+ If you are not using `webp` images in your Jekyll website, this plugin is not for you.
8
+ Please read the next section for details.
9
+ If you have a use case that would benefit from expanding the supported file types,
10
+ please describe your use case on the [issue tracker](https://github.com/mslinn/jekyll_img/issues/5).
11
+
8
12
  See [demo/index.html](demo/index.html) for examples.
9
13
 
14
+
15
+ ## Image Fallback
16
+
17
+ This plugin provides support for the
18
+ [`webp`](https://developers.google.com/speed/webp) image format,
19
+ with a fallback to `png` format by using the HTML
20
+ [`picture`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture) element.
21
+
22
+ This means that 2 versions of every image are required: a `webp` version, and a `png` version.
23
+
24
+ You specify the desired image with a `webp` filetype (or no filetype),
25
+ and the plugin generates a `picture` element that contains a primary
26
+ `source` sub-element that specifies the given image URL,
27
+ and a secondary `img` sub-element with a [`png`](https://en.wikipedia.org/wiki/PNG) filetype.
28
+
29
+ For example, these two invocations yield the same result:
30
+
31
+ ```html
32
+ {% img src="blah" %}
33
+ {% img src="blah.webp" %}
34
+ ```
35
+
36
+ Would conceptually generate the following
37
+ (to support the other options, the generated HTML can be a lot more complex):
38
+
39
+ ```html
40
+ <picture>
41
+ <source srcset="blah.webp" type="image/webp" />
42
+ <source srcset="blah.png" type="image/png" />
43
+ <img src="blah.png" />
44
+ </picture>
45
+ ```
46
+
47
+ The above would fetch and display `blah.webp` if the web browser supported `webp` format,
48
+ otherwise it would fetch and display `blah.png`.
49
+
50
+
51
+ ## Demo
52
+
10
53
  Run the demo website by typing:
54
+
11
55
  ```shell
12
56
  $ demo/_bin/debug -r
13
57
  ```
58
+
14
59
  ... and point your web browser to http://localhost:4444
15
60
 
16
61
 
17
62
  ## Usage
18
- {% img [Options] src='path' %}
63
+
64
+ ```html
65
+ {% img [Options] src='path' %}
66
+ ```
19
67
 
20
68
  `Options` are:
21
69
 
22
- - `attribution` See [`jekyll_plugin_support`](https://github.com/mslinn/jekyll_plugin_support#subclass-attribution).
23
- - `align="left|inline|right|center"` Default value is `inline`
24
- - `alt="Alt text"` Default value is the `caption` text, if provided
25
- - `caption="A caption"` No default value
26
- - `classes="class1 class2 classN"` Extra &lt;img&gt; classes; default is `rounded shadow`
27
- - `id="someId"` No default value
28
- - `nofollow` Generates `rel='nofollow'`; only applicable when `url` is specified
29
- - `size='eighthsize|fullsize|halfsize|initial|quartersize|XXXYY|XXX%'`
70
+ - `attribution` See [`jekyll_plugin_support`](https://github.com/mslinn/jekyll_plugin_support#subclass-attribution).
71
+ - `align="left|inline|right|center"` Default value is `inline`
72
+ - `alt="Alt text"` Default value is the `caption` text, if provided
73
+ - `caption="A caption"` No default value
74
+ - `classes="class1 class2 classN"` Extra &lt;img&gt; classes; default is `rounded shadow`
75
+ - `id="someId"` No default value
76
+ - `nofollow` Generates `rel='nofollow'`; only applicable when `url` is specified
77
+ - `size='eighthsize|fullsize|halfsize|initial|quartersize|XXXYY|XXX%'`
30
78
  Defines width of image.
31
- - `initial` is the default behavior.
32
- - `eighthsize`, `fullsize`, `halfsize`, and `quartersize` are relative to the enclosing tag's width.
33
- - CSS units can also be used, for those cases `XXX` is a float and `YY` is `unit` (see below)
34
- - `style='css goes here'` CSS style for &lt;img&gt;; no default
35
- - `target='none|whatever'` Only applicable when `url` is specified; default value is `_blank`
36
- - `title="A title"` Default value is `caption` text, if provided
37
- - `url='https://domain.com'` No default value
38
- - `wrapper_class='class1 class2 classN'` Extra CSS classes for wrapper &lt;div&gt;; no default value
39
- - `wrapper_style='background-color: black;'` CSS style for wrapper &lt;div&gt;; no default value
79
+ - `initial` is the default behavior.
80
+ - `eighthsize`, `fullsize`, `halfsize`, and `quartersize` are relative to the enclosing tag's width.
81
+ - CSS units can also be used, for those cases `XXX` is a float and `YY` is `unit` (see below)
82
+ - `style='css goes here'` CSS style for &lt;img&gt;; no default
83
+ - `target='none|whatever'` Only applicable when `url` is specified; default value is `_blank`
84
+ - `title="A title"` Default value is `caption` text, if provided
85
+ - `url='https://domain.com'` No default value
86
+ - `wrapper_class='class1 class2 classN'` Extra CSS classes for wrapper &lt;div&gt;; no default value
87
+ - `wrapper_style='background-color: black;'` CSS style for wrapper &lt;div&gt;; no default value
40
88
 
41
89
  [`unit`](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages) is one of: `Q`, `ch`, `cm`, `em`, `dvh`, `dvw`, `ex`, `in`, `lh`,
42
90
  `lvh`, `lvw`, `mm`, `pc`, `px`, `pt`, `rem`, `rlh`, `svh`, `svw`, `vb`,
43
91
  `vh`, `vi`, `vmax`, `vmin`, or `vw`.
44
92
 
45
- CSS classes referenced by the `jekyll_img` plugin are at the bottom of [demo/assets/css/style.css](demo/assets/css/style.css). CSS marker classes are included, so CSS selectors can be used for additional styling.
93
+ CSS classes referenced by the `jekyll_img` plugin are at the bottom of
94
+ [`demo/assets/css/style.css`](demo/assets/css/style.css).
95
+ CSS marker classes are included, so CSS selectors can be used for additional styling.
46
96
 
47
97
 
48
98
  ## Configuration
99
+
49
100
  By default, any errors cause Jekyll to abort.
50
101
  You can allow Jekyll to continue by setting the following in `_config.yml`:
51
102
 
@@ -56,6 +107,7 @@ img:
56
107
 
57
108
 
58
109
  ## Design
110
+
59
111
  The most significant design issue was the decision that image size and formatting should not change
60
112
  whether it had a caption.
61
113
  HTML captions exist within a `<figure />` element, which also surrounds the image.
@@ -71,6 +123,7 @@ Handling all possible situations of these two scenarios would significantly rais
71
123
 
72
124
 
73
125
  ### Wrapper &lt;div /&gt;
126
+
74
127
  To make the plugin code more manageable,
75
128
  the plugin always encloses the generated HTML & CSS within a wrapper `<div />`.
76
129
  The wrapper allows for a simple, consistent approach regardless of whether a caption is generated or not.
@@ -101,21 +154,26 @@ end
101
154
 
102
155
  And then execute:
103
156
 
104
- $ bundle install
157
+ ```shell
158
+ $ bundle
159
+ ```
105
160
 
106
161
 
107
162
  ## Additional Information
163
+
108
164
  More information is available on
109
165
  [Mike Slinn&rsquo;s website](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
110
166
 
111
167
 
112
168
  ## Development
169
+
113
170
  After checking out the repo, run `bin/setup` to install dependencies.
114
171
 
115
172
  You can also run `bin/console` for an interactive prompt that will allow you to experiment.
116
173
 
117
174
 
118
175
  To build and install this gem onto your local machine, run:
176
+
119
177
  ```shell
120
178
  $ bundle exec rake install
121
179
  jekyll_img 0.1.0 built to pkg/jekyll_img-0.1.0.gem.
@@ -123,6 +181,7 @@ jekyll_img (0.1.0) installed.
123
181
  ```
124
182
 
125
183
  Examine the newly built gem:
184
+
126
185
  ```shell
127
186
  $ gem info jekyll_img
128
187
 
@@ -139,28 +198,37 @@ jekyll_img (0.1.0)
139
198
  ```
140
199
 
141
200
  ### Testing
201
+
142
202
  Examine the output by running:
203
+
143
204
  ```shell
144
205
  $ demo/_bin/debug -r
145
206
  ```
207
+
146
208
  ... and pointing your web browser to http://localhost:4444/
147
209
 
148
210
  ### Unit Tests
211
+
149
212
  Either run `rspec` from Visual Studio Code's *Run and Debug* environment
150
213
  (<kbd>Ctrl</kbd>-<kbd>shift</kbd>-<kbd>D</kbd>) and view the *Debug Console* output,
151
214
  or run it from the command line:
215
+
152
216
  ```shell
153
217
  $ rspec
154
218
  ```
155
219
 
156
220
  ### Build and Push to RubyGems
221
+
157
222
  To release a new version,
158
- 1. Update the version number in `version.rb`.
159
- 2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
160
- 3. Run the following:
161
- ```shell
162
- $ bundle exec rake release
163
- ```
223
+
224
+ 1. Update the version number in `version.rb`.
225
+ 2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
226
+ 3. Run the following:
227
+
228
+ ```shell
229
+ $ bundle exec rake release
230
+ ```
231
+
164
232
  The above creates a git tag for the version, commits the created tag,
165
233
  and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
166
234
 
data/lib/img_props.rb CHANGED
@@ -85,6 +85,9 @@ class ImgProperties
85
85
  @src = @src.to_s.strip
86
86
  raise ImgError, "The 'src' parameter was not specified", [] if @src.empty?
87
87
 
88
+ filetype = File.extname(URI(@src).path)
89
+ @src += '.webp' if filetype.empty?
90
+
88
91
  @src = "/assets/images/#{@src}" unless ImgProperties.local_path?(@src) || url?(@src)
89
92
  end
90
93
 
@@ -1,3 +1,3 @@
1
1
  module JekyllImgVersion
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_img
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-25 00:00:00.000000000 Z
11
+ date: 2023-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll