jekyll_picture_tag 2.0.3 → 2.1.0

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: 4f23ec3ce5d5f881be6bae85ef969945881f158c980d2c42bb1765e206ce4fb2
4
- data.tar.gz: f09e7df7586ed7d84e2edbfb1f389542f39b6b44fb21d958a60a795a73392e11
3
+ metadata.gz: 112ac65fbe4fb0b25934864d20de4e840259aa7bac0b43c8d6724d3d0c1ded7d
4
+ data.tar.gz: 8d6d101b1849762e3e955c80b301049a3cab5d7bea6f9ad8469521fb8e7fe60c
5
5
  SHA512:
6
- metadata.gz: 11da88e7d15102e11fa82df0a29622f58efed1d550e127cf5ddfedca12faf9a77451867d303457b96c3f391280b3cfb92cb458408a44855247385e8f1f84ba5b
7
- data.tar.gz: 5e055b1a83dd0be96bca325b5d347315f643fd4f52761452d7544fb036992785760300d2fdee98ef2c95fbdf63298703e54ba8add17d7a7726a8398031e4befb
6
+ metadata.gz: 86c1e2e9f9e8f62fbbc1ae69975ac490f40358649725b6308c9b964ce29571bbdaef22c6f3a0036e8c3d6352bd799d3b05db080914b143283ba97d61282632d6
7
+ data.tar.gz: 17cf9d9e1d397651148191fd2c3d9cde68f2af59c17edabb18b9fb27ebba9ea534a42936f601bb999944d2ff884e09788e6301494896a2ceeae0c2d1b9c23aae
data/.rubocop.yml CHANGED
@@ -24,7 +24,7 @@ AllCops:
24
24
  - '**/vendor/**/*'
25
25
 
26
26
  Layout/LineLength:
27
- Max: 80
27
+ Max: 120
28
28
 
29
29
  # Disabled Cops
30
30
  Style/FrozenStringLiteralComment:
@@ -32,3 +32,6 @@ Style/FrozenStringLiteralComment:
32
32
 
33
33
  Style/StringConcatenation:
34
34
  Enabled: false
35
+
36
+ Metrics/MethodLength:
37
+ Enabled: false
@@ -13,7 +13,7 @@ subdirectories. We're using the [jekyll-rtd-theme](https://jekyll-rtd-theme.rund
13
13
  You can preview as you edit; first the setup:
14
14
 
15
15
  ``` sh
16
- $ git clone git@github.com:rbuchberger/jekyll_picture_tag.git # if you haven't already
16
+ $ git clone https://github.com/rbuchberger/jekyll_picture_tag.git # if you haven't already
17
17
  $ cd jekyll_picture_tag/docs
18
18
  $ direnv allow # (optional)
19
19
  $ bundle install --binstubs # --binstubs is optional.
@@ -11,7 +11,7 @@ required by any means.
11
11
  ### With asdf & direnv:
12
12
 
13
13
  ```sh
14
- $ git clone git@github.com:rbuchberger/jekyll_picture_tag.git
14
+ $ git clone https://github.com/rbuchberger/jekyll_picture_tag.git
15
15
  $ cd jekyll_picture_tag
16
16
  $ direnv allow
17
17
  $ asdf install
@@ -21,7 +21,7 @@ $ bundle install --binstubs
21
21
  ### Without asdf & direnv
22
22
 
23
23
  ```sh
24
- $ git clone git@github.com:rbuchberger/jekyll_picture_tag.git
24
+ $ git clone https://github.com/rbuchberger/jekyll_picture_tag.git
25
25
  $ cd jekyll_picture_tag
26
26
  # Install the correct version of ruby, with the bundler gem.
27
27
  $ bundle install
@@ -2,6 +2,12 @@
2
2
  ---
3
3
  # Release History
4
4
 
5
+ * 2.1.0 29 January, 2024
6
+ * Check whether the vips CLI is installed before trying to use it. Thanks to @philrb for
7
+ [#299](https://github.com/rbuchberger/jekyll_picture_tag/pull/299)
8
+ * Update minimum required mocha version to maintain compatibility with minitest
9
+ * 2.0.4 August 16, 2022
10
+ * Fix backend format support detection for new versions of libvips & imagemagick
5
11
  * 2.0.3 April 1, 2021
6
12
  * Improve backend format support detection
7
13
  * 2.0.2 March 31, 2021
data/docs/index.md CHANGED
@@ -5,10 +5,10 @@
5
5
 
6
6
  _Responsive Images, Done Correctly._
7
7
 
8
- **Warning:** Deploying JPT can be tricky, especially with the new version using libvips. We depend
9
- on system libraries to generate images, whose presence varies greatly between different
10
- environments. Before investing a great deal of time, ensure that your deployment process can handle
11
- all image formats (both input and output) which you will use.
8
+ **Warning:** Deploying JPT can be tricky. We depend on system libraries to generate images, whose
9
+ presence varies greatly between different environments. Before investing a great deal of time,
10
+ ensure that your deployment process can handle all image formats (both input and output) which you
11
+ will use.
12
12
 
13
13
  **Note:** These docs are for versions >= 2.0. Documentation for the last stable 1.x version may be
14
14
  found by browsing the repository,
@@ -14,6 +14,16 @@ work. Anything which pulls down a git repository and builds it in some container
14
14
  extra verification. Often some image formats will be supported, while others will not without
15
15
  installing additional packages.
16
16
 
17
+ I have created a [testing repository](https://github.com/rbuchberger/jpt_tester) for this purpose.
18
+ It's just a barebones jekyll site with JPT, that tries to generate a bunch of image formats. Feel
19
+ free to use it for your own test builds.
20
+
21
+ ```yaml
22
+ presets:
23
+ default:
24
+ formats: [avif, webp, jp2, png, gif, original]
25
+ ```
26
+
17
27
  ## Help Wanted
18
28
 
19
29
  We could really use help improving this page's guidance. I've created
@@ -23,15 +33,29 @@ you're extra motivated and cool, you could make a pull request adding that infor
23
33
 
24
34
  ## Netlify
25
35
 
26
- As of March 26, 2021, with version 2.0.0, Netlify is mostly broken. It only supports jpg. I want to
27
- support netlify as much as reasonably possible, so if a solution isn't found I'll re-add imagemagick
28
- as an alternate backend and offer it as a configurable setting. Until then, stick with version 1.14.
36
+ Ensure you're using version 2.0.2 or later. No support for `jp2` or `avif` files. They have beta
37
+ homebrew support (by setting the build command to `brew install whatever && do_your_build`), but
38
+ attempting to install `libheif` this way runs over the time limit.
39
+
40
+ ```
41
+ Libvips known savers: csv, mat, v, vips, ppm, pgm, pbm, pfm, hdr, png, jpg, jpeg, jpe, webp, tif,
42
+ tiff
43
+
44
+ Imagemagick known savers: bzlib, cairo, djvu, fftw, fontconfig, freetype, jbig, jng, jpeg, lcms,
45
+ lqr, ltdl, lzma, openexr, pangocairo, png, rsvg, tiff, wmf, x, xml, zlib
46
+ ```
47
+
48
+ They run an old version of libvips, so cropping attention may not work the same way as it does
49
+ locally.
29
50
 
30
51
  ## AWS S3
31
52
 
32
53
  This method has a somewhat difficult setup, but once configured it works _very_ well. Since you
33
54
  build the site locally, if your development build works then your production build will work.
34
55
 
56
+ There is one caveat: other than the site root, links need to point to an html file. `/blog` won't
57
+ work, you need `/blog.html` or `/blog/index.html`. If you know a way to fix this, please speak up!
58
+
35
59
  [This](https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-serve-static-website/) is
36
60
  the guide you want; **specifically the second option** (Using a website endpoint as the origin, with
37
61
  anonymous (public) access allowed). This allows you to have https and excellent performance.
@@ -47,3 +71,24 @@ following:
47
71
  * deploy: `build && push && invalidate`
48
72
 
49
73
  (All of these depend on having the aws cli installed, with proper credentials configured.)
74
+
75
+ ## AWS Amplify
76
+
77
+ [This](https://www.bsmth.de/blog/deploying-jekyll-github-actions-aws-amplify) article may be useful;
78
+ I haven't gotten it to work with a full set of image formats. The default build image doesn't
79
+ support jp2 and avif, but Amplify allows you to use a custom build image. If you take the time to
80
+ create one which can generate jpg, png, webp, jp2, and avif files, it would be marvelous of you to
81
+ share it.
82
+
83
+ ## Github Pages
84
+
85
+ GitHub Pages only allows a very short whitelist of plugins, which sadly does not include JPT. You could run it locally, then commit and push the generated site to your Pages branch.
86
+
87
+ Or use GitHub Actions to do this for you automatically. Here’s [an Actions workflow to build a JPT-enabled site and deploy it](https://gist.github.com/elstudio/38bacfe7aab63da082a418fd3a1ddb66). Commit that yaml file to the `.github/workflows` folder of your source repository, and Actions will build and deploy your site whenever you push changes to `main`.
88
+
89
+ See [How to use Jekyll Picture Tag or any Jekyll plugin with GitHub Pages](https://www.elstudio.us/code/use-any-jekyll-plugin-with-github-pages) for details of how it works.
90
+
91
+
92
+ ## Cloudflare pages
93
+
94
+ They have the same restrictions as netlify: jpg, webp, and png work. jp2 and avif are no-go.
@@ -13,11 +13,11 @@ sort: 1
13
13
  ```ruby
14
14
  # Gemfile
15
15
 
16
- gem 'jekyll', ~> '4.0'
16
+ gem 'jekyll', '~> 4.0'
17
17
 
18
18
  group :jekyll_plugins do
19
19
  # (other jekyll plugins)
20
- gem 'jekyll_picture_tag', ~> '2.0'
20
+ gem 'jekyll_picture_tag', '~> 2.0'
21
21
  end
22
22
  ```
23
23
 
@@ -1,5 +1,5 @@
1
1
  # HTML attributes
2
2
 
3
3
  Jekyll Picture Tag has comprehensive attribute support for all generated HTML. You can add
4
- attributes both through the [liquid tag]({{ site.baseurl }}/usage), and the [preset]({{
5
- site.baseurl }}/presets) (scroll down a bit).
4
+ attributes both through the [liquid tag]({{ site.baseurl }}{% link /users/liquid_tag/index.md %}),
5
+ and the [preset]({{ site.baseurl }}{% link /usage/users/presets/html_attributes.md %}) (scroll down a bit).
@@ -13,7 +13,7 @@ to make things outside the scope of JPT.
13
13
  ```yml
14
14
  # _data/picture.yml
15
15
 
16
- markup_presets:
16
+ presets:
17
17
  direct:
18
18
  markup: direct_url
19
19
  fallback_width: 800
@@ -26,18 +26,16 @@ to make things outside the scope of JPT.
26
26
  {% endraw %}
27
27
  ```
28
28
 
29
- - `naked_srcset`: Builds a srcset and nothing else (not even the surrounding quotes). Note that the
30
- (image) `format` setting must still be an array, even if you only give it one
31
- value. (This is on the list of things to improve.)
29
+ - `naked_srcset`: Builds a srcset and nothing else (not even the surrounding quotes).
32
30
 
33
31
  ```yml
34
32
  # _data/picture.yml
35
33
 
36
- markup_presets:
34
+ presets:
37
35
  only_srcset:
38
36
  markup: naked_srcset
39
37
  widths: [800, 1200, 1600]
40
- format: [webp]
38
+ formats: webp
41
39
  ```
42
40
 
43
41
  ```
@@ -7,7 +7,7 @@ sort: 2
7
7
  These are analogous to their plain HTML counterparts, but instead of `src`,
8
8
  `srcset`, and `sizes`, you get `data-src`, `data-srcset`, and `data-sizes`. This
9
9
  allows you to use javascript for things like [lazy
10
- loading](https://github.com/verlok/lazyload).
10
+ loading](https://github.com/verlok/vanilla-lazyload).
11
11
 
12
12
  - `data_picture`
13
13
 
@@ -17,7 +17,7 @@ Example:
17
17
  ```yml
18
18
  # /_data/picture.yml
19
19
 
20
- markup_presets:
20
+ presets:
21
21
  my_preset:
22
22
  markup: data_auto
23
23
  ```
@@ -48,7 +48,7 @@ Gem::Specification.new do |spec|
48
48
  spec.add_development_dependency 'bundler', '~> 2.0'
49
49
  spec.add_development_dependency 'minitest', '~> 5.14'
50
50
  spec.add_development_dependency 'minitest-rg'
51
- spec.add_development_dependency 'mocha', '~> 1.9'
51
+ spec.add_development_dependency 'mocha', '~> 2.1'
52
52
  spec.add_development_dependency 'nokogiri', '~> 1.1'
53
53
  spec.add_development_dependency 'pry'
54
54
  spec.add_development_dependency 'rake', '~> 12.3'
@@ -49,9 +49,9 @@ module PictureTag
49
49
 
50
50
  STOCK_MEDIA_QUERIES = {
51
51
  'jpt-mobile' => 'max-width: 480px',
52
- 'jpt-tablet' => 'max-width: 768',
52
+ 'jpt-tablet' => 'max-width: 768px',
53
53
  'jpt-laptop' => 'max-width: 1024px',
54
- 'jpt-desktop' => 'max-width: 1200',
55
- 'jpt-wide' => 'min-width: 1201'
54
+ 'jpt-desktop' => 'max-width: 1200px',
55
+ 'jpt-wide' => 'min-width: 1201px'
56
56
  }.freeze
57
57
  end
@@ -8,25 +8,35 @@ module PictureTag
8
8
  elsif (magick_formats & all_names(format)).any?
9
9
  :magick
10
10
  else
11
- raise "No support for generating #{format} files in this environment."
11
+ raise error_string(format)
12
12
  end
13
13
  end
14
14
 
15
15
  # Returns array of formats that vips can save to
16
16
  def vips_formats
17
- @vips_formats ||= `vips -l filesave`
18
- .scan(/\.[a-z]{1,5}/)
19
- .uniq
20
- .map { |format| format.strip.delete_prefix('.') }
17
+ if command?('vips')
18
+ @vips_formats ||= `vips -l`
19
+ .split('/n')
20
+ .select { |line| line.include? 'ForeignSave' }
21
+ .flat_map { |line| line.scan(/\.[a-z]{1,5}/) }
22
+ .map { |format| format.strip.delete_prefix('.') }
23
+ .uniq
24
+ else
25
+ @vips_formats = []
26
+ end
21
27
  end
22
28
 
23
29
  # Returns an array of formats that imagemagick can handle.
24
30
  def magick_formats
25
- @magick_formats ||= `convert -version`
26
- .split("\n")
27
- .last
28
- .delete_prefix('Delegates (built-in):')
29
- .split
31
+ if command?('convert')
32
+ @magick_formats ||= `convert -version`
33
+ .scan(/Delegates.*/)
34
+ .first
35
+ .delete_prefix('Delegates (built-in):')
36
+ .split
37
+ else
38
+ @magick_formats = []
39
+ end
30
40
  end
31
41
 
32
42
  # Returns an array of all known names of a format, for the purposes of
@@ -38,9 +48,29 @@ module PictureTag
38
48
 
39
49
  private
40
50
 
51
+ def error_string(format)
52
+ str = []
53
+ str << "No support for generating \"#{format}\" files in this environment!"
54
+ str << if command?('vips')
55
+ "Libvips (installed) supports: \"#{vips_formats.join(', ')}\"."
56
+ else
57
+ 'Libvips is not installed.'
58
+ end
59
+ str << if command?('convert')
60
+ "Imagemagick (installed) supports: \"#{magick_formats.join(', ')}\"."
61
+ else
62
+ 'Imagemagick is not installed.'
63
+ end
64
+ str.join(' ')
65
+ end
66
+
41
67
  def alternates
42
68
  [%w[jpg jpeg], %w[avif heic heif]]
43
69
  end
70
+
71
+ def command?(command)
72
+ system("which #{command} > /dev/null 2>&1")
73
+ end
44
74
  end
45
75
  end
46
76
  end
@@ -1,3 +1,3 @@
1
1
  module PictureTag
2
- VERSION = '2.0.3'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
data/readme.md CHANGED
@@ -1,13 +1,25 @@
1
- ![Logo](docs/logo.svg)
2
-
3
1
  # Jekyll Picture Tag
4
2
 
3
+ ## Help Wanted
4
+
5
+ My life just got a lot busier; I'd really like a maintainer or two to help. I'm not abandoning JPT,
6
+ I just don't have a ton of time to put into hacking on it.
7
+
8
+ If you've been learning Ruby and you want to move beyond tutorials and throwaway projects, I'd love
9
+ to hear from you. I'd be happy to help you gain experience and credibility, if you're willing to
10
+ help me maintain this project!
11
+
12
+ If you're interested, contact me: robert@buchberger.cc
13
+
14
+ ![Logo](docs/logo.svg)
15
+
5
16
  ![Tests & Formatting](https://github.com/rbuchberger/jekyll_picture_tag/workflows/Tests%20&%20Formatting/badge.svg)
6
17
 
7
18
  **Responsive Images done correctly.**
8
19
 
9
20
  It's simple to throw a photo on a page and call it a day, but doing justice to users on all
10
21
  different browsers and devices is tedious and tricky. Tedious, tricky things should be automated.
22
+ [This blog post further elaborates on that theme.](https://robert-buchberger.com/blog/2021/responsive_images.html)
11
23
 
12
24
  Jekyll Picture Tag automatically builds cropped, resized, and reformatted images, builds several
13
25
  kinds of markup, offers extensive configuration while requiring none, and solves both the art
@@ -37,16 +49,22 @@ Tag is your responsive images minion - give it simple instructions and it'll han
37
49
  * Configure it easily, or not at all.
38
50
  * Make Lighthouse happy.
39
51
 
40
- ## Documentation:
52
+ ## Documentation
41
53
 
42
- https://rbuchberger.github.io/jekyll_picture_tag/
54
+ <https://rbuchberger.github.io/jekyll_picture_tag/>
43
55
 
44
- ## Changelog:
56
+ ## Changelog
45
57
 
46
- https://rbuchberger.github.io/jekyll_picture_tag/devs/releases
58
+ <https://rbuchberger.github.io/jekyll_picture_tag/devs/releases>
47
59
 
48
60
  Recent releases:
49
61
 
62
+ * 2.1.0 29 January, 2024
63
+ * Check whether the vips CLI is installed before trying to use it. Thanks to @philrb for
64
+ [#299](https://github.com/rbuchberger/jekyll_picture_tag/pull/299)
65
+ * Update minimum required mocha version to maintain compatibility with minitest
66
+ * 2.0.4 August 16, 2022
67
+ * Fix backend format support detection for new versions of libvips & imagemagick
50
68
  * 2.0.3 April 1, 2021
51
69
  * Improve backend format support detection
52
70
  * 2.0.2 March 31, 2021
@@ -67,11 +85,11 @@ Recent releases:
67
85
  * Require Ruby >= 2.6, support Ruby 3.0
68
86
  * Require Jekyll >= 4.0
69
87
  * Cropping is changing.
70
- * We now use the libvips
88
+ * We now use the libvips
71
89
  [smartcrop function](https://www.rubydoc.info/gems/ruby-vips/Vips/Image#smartcrop-instance_method),
72
90
  which does some magic to keep the most useful part of the image.
73
- * Geometry is renamed to 'crop', and reduced to simple aspect ratios only. (`width:height`)
74
- * Gravity is gone, replaced by 'keep' which is translated to a libvips
91
+ * Geometry is renamed to 'crop', and reduced to simple aspect ratios only. (`width:height`)
92
+ * Gravity is gone, replaced by 'keep' which is translated to a libvips
75
93
  [interestingness](https://www.rubydoc.info/gems/ruby-vips/Vips/Interesting) setting.
76
94
  * Add stock presets and media queries, under the `jpt-` prefix.
77
95
  * Add `format_quality` default settings for webp, avif, and jp2.
@@ -83,14 +101,6 @@ Recent releases:
83
101
  officially and only `presets` and `media_queries`.
84
102
  * Improve docs with an introductory tutorial and 'how-to' flow.
85
103
 
86
- * 1.14.0 January 10, 2021
87
- * Gracefully handle empty tag arguments.
88
- * Re-add metadata stripping. I removed it inadvertently when refactoring; now
89
- there's a test and a setting to turn it off.
90
- * Respect Jekyll's `--disable-disk-cache` argument.
91
- * Add baseurl configuration, allowing increased plugin support (such as I18n via `jekyll-multiple-languages-plugin`)
92
- * Tooling & test suite maintenance and improvements.
93
-
94
104
  ## Help Wanted
95
105
 
96
106
  Writing code is only part of the job; often the harder part is knowing what needs to be changed. Any
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_picture_tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Wierzbowski
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-04-01 00:00:00.000000000 Z
13
+ date: 2024-01-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -144,14 +144,14 @@ dependencies:
144
144
  requirements:
145
145
  - - "~>"
146
146
  - !ruby/object:Gem::Version
147
- version: '1.9'
147
+ version: '2.1'
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - "~>"
153
153
  - !ruby/object:Gem::Version
154
- version: '1.9'
154
+ version: '2.1'
155
155
  - !ruby/object:Gem::Dependency
156
156
  name: nokogiri
157
157
  requirement: !ruby/object:Gem::Requirement
@@ -334,7 +334,6 @@ files:
334
334
  - docs/users/liquid_tag/examples.md
335
335
  - docs/users/liquid_tag/index.md
336
336
  - docs/users/notes/git_lfs.md
337
- - docs/users/notes/github_pages.md
338
337
  - docs/users/notes/html_attributes.md
339
338
  - docs/users/notes/index.md
340
339
  - docs/users/notes/kramdown_bug.md
@@ -431,7 +430,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
431
430
  version: '0'
432
431
  requirements:
433
432
  - libvips
434
- rubygems_version: 3.2.3
433
+ rubygems_version: 3.3.20
435
434
  signing_key:
436
435
  specification_version: 4
437
436
  summary: Easy responsive images for Jekyll.
@@ -1,5 +0,0 @@
1
- # Github Pages?
2
-
3
- Github Pages only allows a very short whitelist of plugins, which sadly does not include JPT. You
4
- can either run it locally, then commit and push the generated files (rather than the source
5
- files), or just host it some other way. I recommend Netlify.