jekyll_img 0.1.4 → 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: 2f9a0ee86751118f5ed309e486751eede3ce4d5c3dad14ecbe7d695aefcc54ee
4
- data.tar.gz: a42e9552fe07aadb4f24882280505f2b55fbeb5b4789e5cb27e7d2f8e9ec7e75
3
+ metadata.gz: 893b2811f139eeae284d17d29a4b9c6b8348aebaf7b5fd54015bda14316bea17
4
+ data.tar.gz: 58f626e32417dfa0790115903453b575cacbab46d312144f741dbec6b05eb458
5
5
  SHA512:
6
- metadata.gz: ad481773b5aabb69f9e8a24c1c3477fa112298f10c9fd21f1f28c008eedb694991107532787c625a0ad736bea7baac2f23220494ad6b2e4b5b56471074bb88fe
7
- data.tar.gz: efef2dd2953194241346f6b354f2429241b0c9d116b5251d97a79d9654d9323acfbb101d1a33ac8481635a365c269224f0bce242aa2e1062661e917a2ba5f0b7
6
+ metadata.gz: d43b8d2c08e13776f29fa59d56750369243909ad74cb4ff66add5050576d49e83cf53a997932f3bf12797fa0fc67ec2e65f9fa782c8a201323a92c0f6c004435
7
+ data.tar.gz: 0ee7e15f89ef2a4f9755b418bd26893edcd77b3cdaa7c3015b6923509d0a0b077b1700161be9aeef227bd8f7b9fd39067e57e527d5ade7787bab577912a77019
data/CHANGELOG.md CHANGED
@@ -1,13 +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
+
19
+ ## 0.1.5 / 2023-05-30
20
+
21
+ * Updated dependencies
22
+
23
+
1
24
  ## 0.1.4 / 2023-04-02
2
- * Added [`attribution` support](https://github.com/mslinn/jekyll_plugin_support#subclass-attribution).
3
- * 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
+
4
29
 
5
30
  ## 0.1.3 / 2023-02-22
6
- * Added `img/continue_on_error` configuration parameter.
31
+
32
+ * Added `img/continue_on_error` configuration parameter.
33
+
7
34
 
8
35
  ## 0.1.2 / 2023-02-14
9
- * 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)`
10
38
 
11
39
 
12
40
  ## 0.1.1 / 2023-02-12
13
- * 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)
4
2
 
5
- `Jekyll_img` is a Jekyll plugin that displays images,
6
- and provides support for captions and URLs.
3
+
4
+ `Jekyll_img` is a Jekyll plugin that embeds images in HTML documents, with alignment options,
5
+ flexible resizing, default styling, overridable styling, an optional caption, and an optional URL.
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).
7
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.
@@ -78,7 +131,7 @@ The wrapper allows for a simple, consistent approach regardless of whether a cap
78
131
  The wrapper width is identical to the displayed image width.
79
132
  Within the wrapper `<div />`, the embedded `<img />` is displayed with `width=100%`.
80
133
  If a caption is required, the generated `<figure />` only makes the space taken by the generated HTML longer;
81
- the image width and height is not affected.
134
+ the image&rsquo;s width and height are not affected.
82
135
 
83
136
  The wrapper will not exceed the width of the tag that encloses it if the `size` parameter has values `eighthsize`, `fullsize`, `halfsize`, `initial` or `quartersize`.
84
137
 
@@ -99,29 +152,28 @@ group :jekyll_plugins do
99
152
  end
100
153
  ```
101
154
 
102
- Also add it to `_config.yml`:
103
- ```yaml
104
- plugins:
105
- - jekyll_img
106
- ```
107
-
108
155
  And then execute:
109
156
 
110
- $ bundle install
157
+ ```shell
158
+ $ bundle
159
+ ```
111
160
 
112
161
 
113
162
  ## Additional Information
163
+
114
164
  More information is available on
115
165
  [Mike Slinn&rsquo;s website](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
116
166
 
117
167
 
118
168
  ## Development
169
+
119
170
  After checking out the repo, run `bin/setup` to install dependencies.
120
171
 
121
172
  You can also run `bin/console` for an interactive prompt that will allow you to experiment.
122
173
 
123
174
 
124
175
  To build and install this gem onto your local machine, run:
176
+
125
177
  ```shell
126
178
  $ bundle exec rake install
127
179
  jekyll_img 0.1.0 built to pkg/jekyll_img-0.1.0.gem.
@@ -129,6 +181,7 @@ jekyll_img (0.1.0) installed.
129
181
  ```
130
182
 
131
183
  Examine the newly built gem:
184
+
132
185
  ```shell
133
186
  $ gem info jekyll_img
134
187
 
@@ -145,28 +198,37 @@ jekyll_img (0.1.0)
145
198
  ```
146
199
 
147
200
  ### Testing
201
+
148
202
  Examine the output by running:
203
+
149
204
  ```shell
150
205
  $ demo/_bin/debug -r
151
206
  ```
207
+
152
208
  ... and pointing your web browser to http://localhost:4444/
153
209
 
154
210
  ### Unit Tests
211
+
155
212
  Either run `rspec` from Visual Studio Code's *Run and Debug* environment
156
213
  (<kbd>Ctrl</kbd>-<kbd>shift</kbd>-<kbd>D</kbd>) and view the *Debug Console* output,
157
214
  or run it from the command line:
215
+
158
216
  ```shell
159
217
  $ rspec
160
218
  ```
161
219
 
162
220
  ### Build and Push to RubyGems
221
+
163
222
  To release a new version,
164
- 1. Update the version number in `version.rb`.
165
- 2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
166
- 3. Run the following:
167
- ```shell
168
- $ bundle exec rake release
169
- ```
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
+
170
232
  The above creates a git tag for the version, commits the created tag,
171
233
  and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
172
234
 
data/jekyll_img.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.authors = ['Mike Slinn']
8
8
  spec.email = ['mslinn@mslinn.com']
9
9
  spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
10
- spec.homepage = 'https://mslinn.com/jekyll/3000-jekyll-plugins.html#jekyll_img'
10
+ spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_img.html'
11
11
  spec.license = 'MIT'
12
12
  spec.metadata = {
13
13
  'allowed_push_host' => 'https://rubygems.org',
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.version = JekyllImgVersion::VERSION
30
30
 
31
31
  spec.add_dependency 'jekyll', '>= 3.5.0'
32
- spec.add_dependency 'jekyll_plugin_support', '~> 0.6.0'
32
+ spec.add_dependency 'jekyll_plugin_support', '>= 0.7.0'
33
33
  end
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.4'.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.4
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-04-06 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
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: jekyll_plugin_support
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.0
33
+ version: 0.7.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.6.0
40
+ version: 0.7.0
41
41
  description:
42
42
  email:
43
43
  - mslinn@mslinn.com
@@ -59,14 +59,14 @@ files:
59
59
  - spec/img_props_spec.rb
60
60
  - spec/jekyll_img_spec.rb
61
61
  - spec/spec_helper.rb
62
- homepage: https://mslinn.com/jekyll/3000-jekyll-plugins.html#jekyll_img
62
+ homepage: https://www.mslinn.com/jekyll_plugins/jekyll_img.html
63
63
  licenses:
64
64
  - MIT
65
65
  metadata:
66
66
  allowed_push_host: https://rubygems.org
67
67
  bug_tracker_uri: https://github.com/mslinn/jekyll_img/issues
68
68
  changelog_uri: https://github.com/mslinn/jekyll_img/CHANGELOG.md
69
- homepage_uri: https://mslinn.com/jekyll/3000-jekyll-plugins.html#jekyll_img
69
+ homepage_uri: https://www.mslinn.com/jekyll_plugins/jekyll_img.html
70
70
  source_code_uri: https://github.com/mslinn/jekyll_img
71
71
  post_install_message: |2+
72
72