jekyll_img 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +37 -37
- data/lib/img_builder.rb +50 -27
- data/lib/img_props.rb +7 -3
- data/lib/jekyll_img/version.rb +1 -1
- data/lib/jekyll_img.rb +6 -8
- data/spec/img_builder_spec.rb +18 -8
- data/spec/img_props_spec.rb +11 -22
- data/spec/jekyll_img_spec.rb +7 -4
- data/spec/status_persistence.txt +10 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18a2afe029ee799d3c0afe05d58592b51aa2c49b2e6e880308963015ed43fe22
|
4
|
+
data.tar.gz: efd819e05b6b0cfebf23f2eede44eb96ba5496b05a29c6dbb5bca748ce5bc9d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca437bd7388b2cd40b0c32ccc507352af61ff136aa3027b03cdecad617c12cde251642b8688356d1df1d41cacb1cb53652bbd2c683a6920606ebcf3cd9628ef9
|
7
|
+
data.tar.gz: 6be7dd74a4281d01d430c67576febe041a8d872ff4068ebce9c8c95c7857974a1b5ec5dc24d43b5c464a48b0c910f99ecb432c9ddd2065ba34cb2254c196cf54
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.2.6 / 2024-08-30
|
4
|
+
|
5
|
+
* Optimized the generated HTML.
|
6
|
+
For example, `srcset` elements are now only generated for images that actually exit locally.
|
7
|
+
For remote images, only an `img` element is generated for the specified filetype.
|
8
|
+
The tests can be found in `demo/img_test.html`.
|
9
|
+
|
10
|
+
|
11
|
+
## 0.2.5 / 2024-07-23
|
12
|
+
|
13
|
+
* Depends on jekyll_plugin_support v1.0.2
|
14
|
+
* Error handling improved
|
15
|
+
* Corrected `README.md#Configuration` and fixed demo `_config.yml`
|
16
|
+
so they correctly specify error handling for this plugin:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
img:
|
20
|
+
die_on_img_error: false
|
21
|
+
pry_on_img_error: false
|
22
|
+
```
|
23
|
+
|
24
|
+
|
3
25
|
## 0.2.4 / 2024-07-23
|
4
26
|
|
5
27
|
* Depends on jekyll_plugin_support v1.0.0
|
data/README.md
CHANGED
@@ -9,10 +9,6 @@ Muliple image formats are supported for each image.
|
|
9
9
|
The user’s web browser determines the formats which it will accept.
|
10
10
|
The most desirable formats that the web browser supports are prioritized.
|
11
11
|
|
12
|
-
I explain why the `webp` image format is important in
|
13
|
-
[Converting All Images in a Website to `webp` Format](https://mslinn.com/blog/2020/08/15/converting-all-images-to-webp-format.html).
|
14
|
-
That article also provides 2 bash scripts for converting existing images to and from <code>webp</code> format.
|
15
|
-
|
16
12
|
For example, if an image is encloded in `webp`, `png` and `gif` filetypes,
|
17
13
|
and the user’s web browser is relatively recent,
|
18
14
|
then `webp` format will give the fastest transmission and look best.
|
@@ -22,56 +18,60 @@ Really old web browsers would only support the `gif` file type.
|
|
22
18
|
|
23
19
|
Please read the next section for details.
|
24
20
|
|
21
|
+
I explain why the `webp` image format is important in
|
22
|
+
[Converting All Images in a Website to `webp` Format](https://mslinn.com/blog/2020/08/15/converting-all-images-to-webp-format.html).
|
23
|
+
That article also provides 2 bash scripts for converting existing images to and from <code>webp</code> format.
|
24
|
+
|
25
25
|
See [demo/index.html](demo/index.html) for examples.
|
26
26
|
|
27
27
|
|
28
|
+
## External Images
|
29
|
+
|
30
|
+
Images whose `src` attribute starts with `http` are not served from the Jekyll website.
|
31
|
+
The `jekyll_img` plugin generates HTML for external images using an `img` element with a `src`
|
32
|
+
attribute as you might expect.
|
33
|
+
|
34
|
+
|
28
35
|
## Image Fallback
|
29
36
|
|
30
|
-
|
31
|
-
|
37
|
+
For local files (files served from the Jekyll website),
|
38
|
+
the `jekyll_img` plugin generates HTML that falls back to successively less performant
|
39
|
+
formats.
|
40
|
+
This is made possible by using a
|
32
41
|
[`picture`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture) element.
|
33
42
|
|
34
|
-
|
43
|
+
At least one version of every image are required.
|
44
|
+
Supported filetypes are:
|
45
|
+
`svg`, `webp`, `apng`, `png`, `jpg`, `jpeg`, `jfif`, `pjpeg`, `pjp`, `gif`, `tif`, `tiff`, `bmp`, `ico` and `cur`.
|
35
46
|
|
36
|
-
|
37
|
-
|
38
|
-
`
|
39
|
-
and
|
40
|
-
|
41
|
-
For example, these two invocations yield the same result:
|
47
|
+
For example, an image file might have the following verions: `blah.webp`, `blah.png` and `blah.jpg`.
|
48
|
+
Given a tag invocation like `{% img src='blah.webp' %}`,
|
49
|
+
the plugin would generate a `picture` element that contains an `img` sub-element with the given `src` attribute,
|
50
|
+
and a `source` element for each related image (`blah.png` and `blah.jpg`).
|
51
|
+
Conceptually, the generated HTML might look something like this:
|
42
52
|
|
43
53
|
```html
|
44
|
-
|
45
|
-
|
54
|
+
<picture>
|
55
|
+
<source srcset="blah.png" />
|
56
|
+
<source srcset="blah.jpg" />
|
57
|
+
<img src="blah.webp" />
|
58
|
+
</picture>
|
46
59
|
```
|
47
60
|
|
48
|
-
|
49
|
-
|
61
|
+
If no filetype is given for the image, `webp` is assumed.
|
62
|
+
For example, these two invocations yield the same result,
|
63
|
+
if `blah.webp` exists on the Jekyll website:
|
50
64
|
|
51
65
|
```html
|
52
|
-
|
53
|
-
|
54
|
-
<source srcset="blah.webp" type="image/webp" />
|
55
|
-
<source srcset="blah.apng" type="image/apng">
|
56
|
-
<source srcset="blah.png" type="image/png">
|
57
|
-
<source srcset="blah.jpg" type="image/jpeg">
|
58
|
-
<source srcset="blah.jpeg" type="image/jpeg">
|
59
|
-
<source srcset="blah.jfif" type="image/jpeg">
|
60
|
-
<source srcset="blah.pjpeg" type="image/jpeg">
|
61
|
-
<source srcset="blah.pjp" type="image/jpeg">
|
62
|
-
<source srcset="blah.gif" type="image/gif">
|
63
|
-
<source srcset="blah.tif" type="image/tiff">
|
64
|
-
<source srcset="blah.tiff" type="image/tiff">
|
65
|
-
<source srcset="blah.bmp" type="image/bmp">
|
66
|
-
<source srcset="blah.ico" type="image/x-icon">
|
67
|
-
<source srcset="blah.cur" type="image/x-icon">
|
68
|
-
<img src="blah.png" />
|
69
|
-
</picture>
|
66
|
+
{% img src="blah" %}
|
67
|
+
{% img src="blah.webp" %}
|
70
68
|
```
|
71
69
|
|
72
70
|
If both `blah.webp` and `blah.png` were available,
|
73
71
|
the above would fetch and display `blah.webp` if the web browser supported `webp` format,
|
74
72
|
otherwise it would fetch and display `blah.png`.
|
73
|
+
If the browser did not support the `picture` element,
|
74
|
+
the `img src` attribute would be used to specify the image.
|
75
75
|
|
76
76
|
|
77
77
|
## Supported Filetypes
|
@@ -103,7 +103,7 @@ Run the demo website by typing:
|
|
103
103
|
$ demo/_bin/debug -r
|
104
104
|
```
|
105
105
|
|
106
|
-
... and point your web browser to http://localhost:
|
106
|
+
... and point your web browser to http://localhost:4011
|
107
107
|
|
108
108
|
|
109
109
|
## Usage
|
@@ -151,7 +151,7 @@ By default, errors cause Jekyll to abort.
|
|
151
151
|
You can allow Jekyll to halt by setting the following in `_config.yml`:
|
152
152
|
|
153
153
|
```yaml
|
154
|
-
|
154
|
+
img:
|
155
155
|
die_on_img_error: true
|
156
156
|
pry_on_img_error: true
|
157
157
|
```
|
data/lib/img_builder.rb
CHANGED
@@ -25,9 +25,9 @@ class ImgBuilder
|
|
25
25
|
<div class='#{classes}' style='#{@props.attr_width_style} #{@props.wrapper_style}'>
|
26
26
|
#{"<figure>\n" if @props.caption}
|
27
27
|
#{ if @props.url
|
28
|
-
"<a href='#{@props.url}'#{@props.attr_target}#{@props.attr_nofollow} class='imgImgUrl'>#{
|
28
|
+
"<a href='#{@props.url}'#{@props.attr_target}#{@props.attr_nofollow} class='imgImgUrl'>#{generate_image}</a>"
|
29
29
|
else
|
30
|
-
|
30
|
+
generate_image
|
31
31
|
end
|
32
32
|
}
|
33
33
|
#{generate_figure_caption}
|
@@ -35,7 +35,7 @@ class ImgBuilder
|
|
35
35
|
#{@props.attribute if @props.attribution}
|
36
36
|
</div>
|
37
37
|
END_HTML
|
38
|
-
result.strip
|
38
|
+
result.strip.gsub(/^\s*$\n/, '')
|
39
39
|
end
|
40
40
|
|
41
41
|
def generate_figure_caption
|
@@ -57,34 +57,57 @@ class ImgBuilder
|
|
57
57
|
END_CAPTION
|
58
58
|
end
|
59
59
|
|
60
|
+
# @return Array[String] containing HTML source elements
|
61
|
+
def generate_sources(filetypes, mimetype)
|
62
|
+
result = filetypes.map do |ftype|
|
63
|
+
filename = @props.src_any ftype
|
64
|
+
next unless filename.start_with?('http') || File.exist?("./#{filename}")
|
65
|
+
|
66
|
+
<<~END_HTML
|
67
|
+
<source srcset="#{filename}" type="#{mimetype}">
|
68
|
+
END_HTML
|
69
|
+
end
|
70
|
+
result&.compact&.map(&:strip)
|
71
|
+
end
|
72
|
+
|
73
|
+
def generate_compact_sources
|
74
|
+
[
|
75
|
+
generate_sources(%w[svg], 'image/svg'),
|
76
|
+
generate_sources(%w[webp], 'image/webp'),
|
77
|
+
generate_sources(%w[png], 'image/png'),
|
78
|
+
generate_sources(%w[apng], 'image/apng'),
|
79
|
+
generate_sources(%w[jpg jpeg jfif pjpeg pjp], 'image/jpeg'),
|
80
|
+
generate_sources(%w[gif], 'image/gif'),
|
81
|
+
generate_sources(%w[tif tiff], 'image/tiff'),
|
82
|
+
generate_sources(%w[bmp], 'image/bmp'),
|
83
|
+
generate_sources(%w[cur ico], 'image/x-icon')
|
84
|
+
].compact.join("\n").strip.gsub(/^$\n/, '')
|
85
|
+
end
|
86
|
+
|
60
87
|
# See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture
|
88
|
+
def generate_image
|
89
|
+
return generate_img if @props.src.start_with? 'http'
|
90
|
+
|
91
|
+
# avif is not well supported yet
|
92
|
+
# <source srcset="#{@props.src_any 'avif'}" type="image/avif">
|
93
|
+
result = <<~END_IMG
|
94
|
+
<picture#{@props.attr_id} class='imgPicture'>
|
95
|
+
#{generate_compact_sources}
|
96
|
+
#{generate_img}
|
97
|
+
</picture>
|
98
|
+
END_IMG
|
99
|
+
result.strip
|
100
|
+
end
|
101
|
+
|
61
102
|
def generate_img
|
62
103
|
img_classes = @props.classes || 'rounded shadow'
|
63
104
|
<<~END_IMG
|
64
|
-
<
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
<source srcset="#{@props.src_any 'jpg'}" type="image/jpeg">
|
71
|
-
<source srcset="#{@props.src_any 'jpeg'}" type="image/jpeg">
|
72
|
-
<source srcset="#{@props.src_any 'jfif'}" type="image/jpeg">
|
73
|
-
<source srcset="#{@props.src_any 'pjpeg'}" type="image/jpeg">
|
74
|
-
<source srcset="#{@props.src_any 'pjp'}" type="image/jpeg">
|
75
|
-
<source srcset="#{@props.src_any 'gif'}" type="image/gif">
|
76
|
-
<source srcset="#{@props.src_any 'tif'}" type="image/tiff">
|
77
|
-
<source srcset="#{@props.src_any 'tiff'}" type="image/tiff">
|
78
|
-
<source srcset="#{@props.src_any 'bmp'}" type="image/bmp">
|
79
|
-
<source srcset="#{@props.src_any 'ico'}" type="image/x-icon">
|
80
|
-
<source srcset="#{@props.src_any 'cur'}" type="image/x-icon">
|
81
|
-
<img #{@props.attr_alt}
|
82
|
-
class="imgImg #{img_classes.squish}"
|
83
|
-
src="#{@props.src_png}"
|
84
|
-
#{@props.attr_style_img}
|
85
|
-
#{@props.attr_title}
|
86
|
-
/>
|
87
|
-
</picture>
|
105
|
+
<img #{@props.attr_alt}
|
106
|
+
class="imgImg #{img_classes.squish}"
|
107
|
+
src="#{@props.src_png}"
|
108
|
+
#{@props.attr_style_img}
|
109
|
+
#{@props.attr_title}
|
110
|
+
/>
|
88
111
|
END_IMG
|
89
112
|
end
|
90
113
|
end
|
data/lib/img_props.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
1
3
|
# Properties from user
|
2
4
|
# All methods are idempotent.
|
3
5
|
# attr_ methods can be called after compute_dependant_properties
|
@@ -67,8 +69,6 @@ class ImgProperties
|
|
67
69
|
end
|
68
70
|
|
69
71
|
def src_any(filetype)
|
70
|
-
raise Jekyll::ImgError, "The 'src' parameter was not specified" if @src.to_s.empty?
|
71
|
-
|
72
72
|
@src.gsub('.webp', ".#{filetype}")
|
73
73
|
end
|
74
74
|
|
@@ -86,8 +86,12 @@ class ImgProperties
|
|
86
86
|
private
|
87
87
|
|
88
88
|
def setup_src
|
89
|
+
raise Jekyll::ImgError, "The 'src' parameter was not specified" if @src.nil?
|
90
|
+
|
91
|
+
raise Jekyll::ImgError, "The 'src' parameter was empty" if @src.empty?
|
92
|
+
|
89
93
|
@src = @src.to_s.strip
|
90
|
-
raise Jekyll::ImgError, "The 'src' parameter
|
94
|
+
raise Jekyll::ImgError, "The 'src' parameter only contained whitespace" if @src.empty?
|
91
95
|
|
92
96
|
filetype = File.extname(URI(@src).path)
|
93
97
|
@src += '.webp' if filetype.empty?
|
data/lib/jekyll_img/version.rb
CHANGED
data/lib/jekyll_img.rb
CHANGED
@@ -9,11 +9,11 @@ require_relative 'jekyll_img/version'
|
|
9
9
|
# @license SPDX-License-Identifier: Apache-2.0
|
10
10
|
|
11
11
|
module ImgModule
|
12
|
-
PLUGIN_NAME = 'img'.freeze
|
12
|
+
PLUGIN_NAME = 'img'.freeze unless const_defined?(:PLUGIN_NAME)
|
13
13
|
end
|
14
14
|
|
15
15
|
module Jekyll
|
16
|
-
ImgError = ::JekyllSupport.define_error
|
16
|
+
ImgError = ::JekyllSupport.define_error unless const_defined?(:ImgError)
|
17
17
|
|
18
18
|
# Plugin implementation
|
19
19
|
class Img < ::JekyllSupport::JekyllTag
|
@@ -47,15 +47,13 @@ module Jekyll
|
|
47
47
|
@builder = ImgBuilder.new(props)
|
48
48
|
@builder.to_s
|
49
49
|
rescue ImgError => e # jekyll_plugin_support handles StandardError
|
50
|
-
e.
|
51
|
-
msg = format_error_message e.message
|
52
|
-
@logger.error { "#{e.class} raised #{msg}" }
|
50
|
+
@logger.error { e.logger_message }
|
53
51
|
binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
|
54
|
-
|
52
|
+
exit! 1 if @die_on_img_error
|
55
53
|
|
56
|
-
|
54
|
+
e.html_message
|
57
55
|
end
|
58
56
|
|
59
|
-
::JekyllSupport::JekyllPluginHelper.register(self, ImgModule::PLUGIN_NAME)
|
57
|
+
::JekyllSupport::JekyllPluginHelper.register(self, ImgModule::PLUGIN_NAME) unless $PROGRAM_NAME.end_with?('/rspec')
|
60
58
|
end
|
61
59
|
end
|
data/spec/img_builder_spec.rb
CHANGED
@@ -5,17 +5,27 @@ require_relative '../lib/img_props'
|
|
5
5
|
# Test ImgProperties
|
6
6
|
class ImgPropertiesTest
|
7
7
|
RSpec.describe ImgBuilder do
|
8
|
+
Dir.chdir("demo")
|
9
|
+
|
10
|
+
it 'generates sources' do
|
11
|
+
props = ImgProperties.new
|
12
|
+
props.src = 'jekyll.webp'
|
13
|
+
builder = described_class.new(props)
|
14
|
+
actual = builder.send(:generate_sources, ['png'], 'image/png')
|
15
|
+
expect(actual).to contain_exactly('<source srcset="/assets/images/jekyll.png" type="image/png">')
|
16
|
+
end
|
17
|
+
|
8
18
|
it 'generates a default img' do
|
9
19
|
props = ImgProperties.new
|
10
|
-
props.src = '
|
20
|
+
props.src = 'jekyll.webp'
|
11
21
|
builder = described_class.new(props)
|
12
22
|
picture = <<~END_IMG
|
13
23
|
<div class='imgWrapper imgFlex' style=' '>
|
14
24
|
<picture class='imgPicture'>
|
15
|
-
<source srcset="/assets/images/
|
16
|
-
<source srcset="/assets/images/
|
25
|
+
<source srcset="/assets/images/jekyll.webp" type="image/webp">
|
26
|
+
<source srcset="/assets/images/jekyll.png" type="image/png">
|
17
27
|
<img class="imgImg rounded shadow"
|
18
|
-
src="/assets/images/
|
28
|
+
src="/assets/images/jekyll.png"
|
19
29
|
style='width: 100%; '
|
20
30
|
/>
|
21
31
|
</picture>
|
@@ -30,7 +40,7 @@ class ImgPropertiesTest
|
|
30
40
|
props = ImgProperties.new
|
31
41
|
props.caption = 'This is a caption'
|
32
42
|
props.size = '123px'
|
33
|
-
props.src = '
|
43
|
+
props.src = 'jekyll.webp'
|
34
44
|
builder = described_class.new(props)
|
35
45
|
|
36
46
|
caption = <<~END_CAPTION
|
@@ -43,11 +53,11 @@ class ImgPropertiesTest
|
|
43
53
|
<div class='imgWrapper imgBlock' style='width: 123px; '>
|
44
54
|
<figure>
|
45
55
|
<picture class='imgPicture'>
|
46
|
-
<source srcset="/assets/images/
|
47
|
-
<source srcset="/assets/images/
|
56
|
+
<source srcset="/assets/images/jekyll.webp" type="image/webp">
|
57
|
+
<source srcset="/assets/images/jekyll.png" type="image/png">
|
48
58
|
<img alt='This is a caption'
|
49
59
|
class="imgImg rounded shadow"
|
50
|
-
src="/assets/images/
|
60
|
+
src="/assets/images/jekyll.png"
|
51
61
|
style='width: 100%; '
|
52
62
|
title='This is a caption'
|
53
63
|
/>
|
data/spec/img_props_spec.rb
CHANGED
@@ -26,15 +26,19 @@ class ImgProperitesTest
|
|
26
26
|
expect(props.attr_target).to eq(" target='_blank'")
|
27
27
|
expect(props.attr_title).to be_nil
|
28
28
|
expect(props.attr_width_style).to be_nil
|
29
|
-
|
30
|
-
props.compute_dependant_properties
|
31
|
-
expect(props.attr_wrapper_align_class).to eq('inline')
|
32
29
|
end
|
33
30
|
|
31
|
+
# it 'defaults to inline alignment' do
|
32
|
+
# props = described_class.new
|
33
|
+
# props.src = 'relative/path.webp'
|
34
|
+
# props.compute_dependant_properties
|
35
|
+
# expect(props.attr_wrapper_align_class).to eq('inline')
|
36
|
+
# end
|
37
|
+
|
34
38
|
it 'raises exception if src was not specified' do
|
35
39
|
props = described_class.new
|
36
|
-
expect { props.src_png }.to raise_error(
|
37
|
-
expect { props.send(:setup_src) }.to raise_error(
|
40
|
+
expect { props.src_png }.to raise_error(Jekyll::ImgError)
|
41
|
+
expect { props.send(:setup_src) }.to raise_error(Jekyll::ImgError)
|
38
42
|
|
39
43
|
props.src = 'relative/path.webp'
|
40
44
|
props.send(:setup_src)
|
@@ -69,21 +73,18 @@ class ImgProperitesTest
|
|
69
73
|
|
70
74
|
props.size = '100px'
|
71
75
|
expect(props.attr_size_class).to be_nil
|
72
|
-
expect(props.attr_style_img).to eq("style='
|
76
|
+
expect(props.attr_style_img).to eq("style='width: 100%; '")
|
73
77
|
expect(props.attr_width_style).to eq('width: 100px;')
|
74
78
|
|
75
79
|
props.size = '10%'
|
76
80
|
expect(props.attr_size_class).to be_nil
|
77
|
-
expect(props.attr_style_img).to eq("style='max-width: 10%;'")
|
78
81
|
expect(props.attr_width_style).to eq('width: 10%;')
|
82
|
+
expect(props.attr_style_img).to eq("style='width: 100%; '")
|
79
83
|
|
80
84
|
props.size = 'fullsize'
|
81
85
|
expect(props.attr_size_class).to eq('fullsize')
|
82
86
|
expect(props.attr_width_style).to be_nil
|
83
87
|
|
84
|
-
props.style = 'width: 30rem;'
|
85
|
-
expect(props.attr_style_img).to eq("style='width: 30rem;'")
|
86
|
-
|
87
88
|
props.target = 'moon'
|
88
89
|
expect(props.attr_target).to eq(" target='moon'")
|
89
90
|
|
@@ -95,17 +96,5 @@ class ImgProperitesTest
|
|
95
96
|
expect(props.attr_size_class).to be_nil
|
96
97
|
expect(props.attr_width_style).to eq('width: 100px;')
|
97
98
|
end
|
98
|
-
|
99
|
-
it 'generates proper alignment attributes' do
|
100
|
-
props = described_class.new
|
101
|
-
|
102
|
-
props.align = 'inline'
|
103
|
-
props.compute_dependant_properties
|
104
|
-
expect(props.attr_wrapper_align_class).to eq('inline')
|
105
|
-
|
106
|
-
props.align = 'center'
|
107
|
-
props.compute_dependant_properties
|
108
|
-
expect(props.attr_wrapper_align_class).to eq('center')
|
109
|
-
end
|
110
99
|
end
|
111
100
|
end
|
data/spec/jekyll_img_spec.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'jekyll'
|
2
2
|
require 'jekyll_plugin_logger'
|
3
|
+
require 'helper/jekyll_plugin_helper'
|
4
|
+
require 'jekyll_plugin_support'
|
3
5
|
require 'rspec/match_ignoring_whitespace'
|
4
6
|
require_relative '../lib/jekyll_img'
|
5
7
|
|
6
|
-
Registers = Struct.new(:page, :site)
|
8
|
+
Registers = Struct.new(:page, :site) unless defined? :Registers
|
7
9
|
|
8
10
|
# Mock for Collections
|
9
11
|
class Collections
|
@@ -46,10 +48,11 @@ class MyTest
|
|
46
48
|
let(:parse_context) { TestParseContext.new }
|
47
49
|
|
48
50
|
let(:helper) do
|
49
|
-
JekyllPluginHelper.new(
|
51
|
+
::JekyllSupport::JekyllPluginHelper.new(
|
50
52
|
'img',
|
51
53
|
'src="./blah.webp"',
|
52
|
-
logger
|
54
|
+
logger,
|
55
|
+
false
|
53
56
|
)
|
54
57
|
end
|
55
58
|
|
@@ -61,7 +64,7 @@ class MyTest
|
|
61
64
|
helper.markup.dup,
|
62
65
|
parse_context
|
63
66
|
)
|
64
|
-
result = img.send(:render_impl
|
67
|
+
result = img.send(:render_impl)
|
65
68
|
expect(result).to match_ignoring_whitespace <<-END_RESULT
|
66
69
|
<img src="./blah.webp">
|
67
70
|
END_RESULT
|
@@ -0,0 +1,10 @@
|
|
1
|
+
example_id | status | run_time |
|
2
|
+
------------------------------- | ------ | --------------- |
|
3
|
+
./spec/img_builder_spec.rb[1:1] | failed | 14.37 seconds |
|
4
|
+
./spec/img_builder_spec.rb[1:2] | failed | 0.01498 seconds |
|
5
|
+
./spec/img_builder_spec.rb[1:3] | failed | 0.00093 seconds |
|
6
|
+
./spec/img_props_spec.rb[1:1] | passed | 0.00407 seconds |
|
7
|
+
./spec/img_props_spec.rb[1:2] | passed | 0.00005 seconds |
|
8
|
+
./spec/img_props_spec.rb[1:3] | passed | 0.00845 seconds |
|
9
|
+
./spec/img_props_spec.rb[1:4] | passed | 0.00135 seconds |
|
10
|
+
./spec/img_props_spec.rb[1:5] | passed | 11.17 seconds |
|
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.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- spec/img_props_spec.rb
|
60
60
|
- spec/jekyll_img_spec.rb
|
61
61
|
- spec/spec_helper.rb
|
62
|
+
- spec/status_persistence.txt
|
62
63
|
homepage: https://www.mslinn.com/jekyll_plugins/jekyll_img.html
|
63
64
|
licenses:
|
64
65
|
- MIT
|
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
87
|
- !ruby/object:Gem::Version
|
87
88
|
version: '0'
|
88
89
|
requirements: []
|
89
|
-
rubygems_version: 3.5.
|
90
|
+
rubygems_version: 3.5.17
|
90
91
|
signing_key:
|
91
92
|
specification_version: 4
|
92
93
|
summary: Provides a Jekyll tag that generates images.
|
@@ -95,4 +96,5 @@ test_files:
|
|
95
96
|
- spec/img_props_spec.rb
|
96
97
|
- spec/jekyll_img_spec.rb
|
97
98
|
- spec/spec_helper.rb
|
99
|
+
- spec/status_persistence.txt
|
98
100
|
...
|