jekyll_picture_tag 1.9.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.travis.yml +4 -7
  4. data/Dockerfile +9 -0
  5. data/docs/Gemfile +4 -2
  6. data/docs/Gemfile.lock +186 -89
  7. data/docs/_config.yml +6 -10
  8. data/docs/devs/contributing/code.md +44 -0
  9. data/docs/devs/contributing/docs.md +13 -0
  10. data/docs/devs/contributing/index.md +15 -0
  11. data/docs/devs/contributing/setup.md +13 -0
  12. data/docs/devs/contributing/testing.md +41 -0
  13. data/docs/devs/index.md +7 -0
  14. data/docs/{releases.md → devs/releases.md} +35 -13
  15. data/docs/index.md +58 -36
  16. data/docs/users/configuration/cdn.md +35 -0
  17. data/docs/users/configuration/directories.md +34 -0
  18. data/docs/users/configuration/disable.md +24 -0
  19. data/docs/users/configuration/fast_build.md +28 -0
  20. data/docs/users/configuration/ignore_missing.md +23 -0
  21. data/docs/users/configuration/index.md +29 -0
  22. data/docs/users/configuration/kramdown_fix.md +20 -0
  23. data/docs/users/configuration/relative_urls.md +15 -0
  24. data/docs/users/configuration/suppress_warnings.md +16 -0
  25. data/docs/users/index.md +7 -0
  26. data/docs/users/installation.md +52 -0
  27. data/docs/users/liquid_tag/argument_reference/alternate_images.md +18 -0
  28. data/docs/users/liquid_tag/argument_reference/attributes.md +42 -0
  29. data/docs/users/liquid_tag/argument_reference/base_image.md +12 -0
  30. data/docs/users/liquid_tag/argument_reference/crop.md +48 -0
  31. data/docs/users/liquid_tag/argument_reference/link.md +16 -0
  32. data/docs/users/liquid_tag/argument_reference/preset.md +17 -0
  33. data/docs/users/liquid_tag/argument_reference/readme.md +9 -0
  34. data/docs/users/liquid_tag/examples.md +81 -0
  35. data/docs/users/liquid_tag/index.md +31 -0
  36. data/docs/users/notes/git_lfs.md +7 -0
  37. data/docs/users/notes/github_pages.md +5 -0
  38. data/docs/users/notes/html_attributes.md +5 -0
  39. data/docs/users/notes/index.md +6 -0
  40. data/docs/users/notes/input_checking.md +6 -0
  41. data/docs/users/notes/kramdown_bug.md +41 -0
  42. data/docs/users/notes/managing_images.md +21 -0
  43. data/docs/{migration.md → users/notes/migration.md} +0 -0
  44. data/docs/users/presets/cropping.md +61 -0
  45. data/docs/users/presets/default.md +23 -0
  46. data/docs/users/presets/examples.md +79 -0
  47. data/docs/users/presets/fallback_image.md +28 -0
  48. data/docs/users/presets/html_attributes.md +26 -0
  49. data/docs/users/presets/image_formats.md +21 -0
  50. data/docs/users/presets/image_quality.md +43 -0
  51. data/docs/users/presets/index.md +101 -0
  52. data/docs/users/presets/link_source.md +16 -0
  53. data/docs/users/presets/markup_formats/fragments.md +48 -0
  54. data/docs/users/presets/markup_formats/javascript_friendly.md +57 -0
  55. data/docs/users/presets/markup_formats/readme.md +43 -0
  56. data/docs/users/presets/markup_formats/standard_html.md +25 -0
  57. data/docs/users/presets/media_queries.md +36 -0
  58. data/docs/users/presets/nomarkdown_override.md +17 -0
  59. data/docs/users/presets/pixel_ratio_srcsets.md +32 -0
  60. data/docs/users/presets/width_height_attributes.md +34 -0
  61. data/docs/users/presets/width_srcsets.md +85 -0
  62. data/jekyll_picture_tag.gemspec +1 -1
  63. data/lib/jekyll_picture_tag.rb +1 -0
  64. data/lib/jekyll_picture_tag/cache.rb +3 -0
  65. data/lib/jekyll_picture_tag/cache/base.rb +59 -0
  66. data/lib/jekyll_picture_tag/cache/generated.rb +20 -0
  67. data/lib/jekyll_picture_tag/cache/source.rb +19 -0
  68. data/lib/jekyll_picture_tag/defaults/presets.yml +2 -0
  69. data/lib/jekyll_picture_tag/generated_image.rb +52 -41
  70. data/lib/jekyll_picture_tag/img_uri.rb +1 -0
  71. data/lib/jekyll_picture_tag/instructions.rb +1 -0
  72. data/lib/jekyll_picture_tag/instructions/arg_splitter.rb +69 -0
  73. data/lib/jekyll_picture_tag/instructions/configuration.rb +1 -1
  74. data/lib/jekyll_picture_tag/instructions/preset.rb +40 -15
  75. data/lib/jekyll_picture_tag/instructions/set.rb +23 -9
  76. data/lib/jekyll_picture_tag/instructions/tag_parser.rb +59 -69
  77. data/lib/jekyll_picture_tag/output_formats/basic.rb +34 -15
  78. data/lib/jekyll_picture_tag/output_formats/img.rb +11 -0
  79. data/lib/jekyll_picture_tag/output_formats/picture.rb +22 -0
  80. data/lib/jekyll_picture_tag/router.rb +9 -0
  81. data/lib/jekyll_picture_tag/source_image.rb +60 -44
  82. data/lib/jekyll_picture_tag/srcsets/basic.rb +29 -7
  83. data/lib/jekyll_picture_tag/utils.rb +18 -0
  84. data/lib/jekyll_picture_tag/version.rb +1 -1
  85. data/readme.md +40 -16
  86. metadata +67 -20
  87. data/docs/_layouts/directory.html +0 -32
  88. data/docs/assets/style.css +0 -31
  89. data/docs/contributing.md +0 -75
  90. data/docs/example_presets.md +0 -116
  91. data/docs/global_configuration.md +0 -173
  92. data/docs/installation.md +0 -30
  93. data/docs/notes.md +0 -91
  94. data/docs/output.md +0 -63
  95. data/docs/presets.md +0 -309
  96. data/docs/usage.md +0 -113
@@ -0,0 +1,13 @@
1
+ ---
2
+ sort: 2
3
+ ---
4
+
5
+ # Docs
6
+
7
+ They run on github pages, which is based on jekyll. You can preview as you edit:
8
+
9
+ 0. Follow the [setup instructions](setup)
10
+ 1. `$ cd docs`
11
+ 2. `$ bundle install`
12
+ 3. `$ bundle exec jekyll serve`
13
+ 4. In a web browser, navigate to `localhost:4000/jekyll_picture_tag/`
@@ -0,0 +1,15 @@
1
+ ---
2
+ ---
3
+ # Contributing
4
+
5
+ Bug reports, feature requests, and feedback are very welcome, either through
6
+ github issues or via email: robert@buchberger.cc
7
+
8
+ Pull requests are encouraged! I'm happy to answer questions and provide
9
+ assistance along the way. Don't let any of the recommendations/requests in this
10
+ guide stop you from submitting one.
11
+
12
+ I think one of the biggest opportunities for improvement in this plugin is its
13
+ documentation. I'd really love help here, and all you need to know is markdown.
14
+
15
+ {% include list.liquid %}
@@ -0,0 +1,13 @@
1
+ ---
2
+ sort: 1
3
+ ---
4
+
5
+ ## Setup
6
+
7
+ It's pretty standard:
8
+
9
+ ```
10
+ $ git clone git@github.com:rbuchberger/jekyll_picture_tag.git
11
+ $ cd jekyll_picture_tag
12
+ $ bundle install
13
+ ```
@@ -0,0 +1,41 @@
1
+ ---
2
+ sort: 3
3
+ ---
4
+
5
+ ## How to run the tests
6
+
7
+ You probably only need to use docker if it's inconvenient to install ImageMagick 7.
8
+
9
+ ### Bare Metal
10
+
11
+ ```note
12
+ Depending on your environment, you may need to prefix all rake commands with
13
+ `bundle exec`.
14
+ ```
15
+
16
+ `rake test` runs the test suite (both unit tests and integration tests). Ignore the mini_magick
17
+ `method redefined` warnings (unless you know how to fix them?)
18
+
19
+ `rake unit` runs just the unit tests, while `rake integration` runs the integration tests. The unit
20
+ test coverage isn't stellar, but both unit and integration tests together hit 100%.
21
+
22
+ Speaking of coverage, simplecov is set up -- you'll get a measurement of coverage in the test output
23
+ and a nice report in the `coverage` directory. I'd like to move to mutation based coverage testing,
24
+ but that's a project for another day.
25
+
26
+ The tests do output a few images to the `/tmp/` directory, which I'm pretty sure means it won't work
27
+ on Windows. This is fixable if there is a need, so if that gets in your way just ask.
28
+
29
+ `rake rubocop` checks code formatting, `rake rubocop:auto_correct` will try to fix any rubocop
30
+ issues, if possible.
31
+
32
+ `rake` will run all tests and rubocop.
33
+
34
+ ### Docker
35
+
36
+ The following commands will build and run the tests inside a docker image.
37
+
38
+ ```bash
39
+ $ docker build . -t jpt
40
+ $ docker run -t jpt
41
+ ```
@@ -0,0 +1,7 @@
1
+ ---
2
+ sort: 2
3
+ ---
4
+
5
+ # Development
6
+
7
+ {% include list.liquid %}
@@ -1,27 +1,47 @@
1
1
  ---
2
2
  ---
3
3
  # Release History
4
-
4
+ * 1.12.0 July 30, 2020
5
+ * Documentation overhaul. Now with 87% less scrolling!
6
+ * Rename `markup_presets` and `media_presets` to `presets` and
7
+ `media_queries`. The old names were bad and caused confusion. The old names
8
+ will continue to work until the next major version is released.
9
+ * 1.11.0 July 27, 2020
10
+ * **Width and height attribute support!** Begone, page reflow.
11
+ * Cache image information between builds
12
+ * Change image naming format. This update will trigger all images to be
13
+ regenerated, so you may want to delete your generated images folder
14
+ beforehand.
15
+ * 1.10.2 July 6, 2020
16
+ * Bugfix for fallback image files not actually getting generated
17
+ * 1.10.1 July 2, 2020
18
+ * Bugfix for erroneously regenerated images
19
+ * 1.10.0 May 11, 2020
20
+ * **Image Cropping support!** access the power of ImageMagick's `crop` function.
21
+ * Don't issue a warning when `default` preset is not found.
22
+ * Documentation improvements
5
23
  * 1.9.0 Feb 2, 2020
6
24
  * Add `fast_build` global setting
7
25
  * Add `disabled` global setting
8
- * Reduce unnecessary disk IO; sites with many source images should see build times improve when
9
- no new images need to be generated.
10
- * Add support for empty attributes; specifically so best-practice for decorative images (`alt=""`)
11
- is possible.
26
+ * Reduce unnecessary disk IO; sites with many source images should see build
27
+ times improve when no new images need to be generated.
28
+ * Add support for empty attributes; specifically so best-practice for
29
+ decorative images (`alt=""`) is possible.
12
30
  * 1.8.0 Nov 25, 2019
13
31
  * Add `data_sizes` setting for the `data_` family of output formats.
14
32
  * 1.7.1 Nov 14, 2019
15
33
  * Fix some HTML attribute related bugs
16
34
  * Add a few items to the FAQ
17
35
  * 1.7.0 Aug 12, 2019
18
- * Add support for setting generated image quality, either generally or specific to given
19
- formats.
36
+ * Add support for setting generated image quality, either generally or
37
+ specific to given formats.
20
38
  * Add support for spaces and other url-encoded characters in filenames
21
- * Documentation restructure - Moved it out of the wiki, into the `docs` folder.
39
+ * Documentation restructure - Moved it out of the wiki, into the `docs`
40
+ folder.
22
41
  * Bugfix: Fallback image width will now be checked against source image width.
23
42
  * Bugfix: Minor fix to nomarkdown wrapper output
24
- * link_source will now target the base source image, rather than finding the biggest one.
43
+ * link_source will now target the base source image, rather than finding the
44
+ biggest one.
25
45
  * Remove fastimage dependency, add addressable dependency.
26
46
  * Moderately significant refactoring and code cleanup
27
47
  * Decent set of tests added
@@ -32,14 +52,15 @@
32
52
  * better `{::nomarkdown}` necessity detection
33
53
  * allow user to override `{::nomarkdown}` autodetection
34
54
  * 1.4.0 Jun 26, 2019:
35
- * Rename gem from `jekyll-picture-tag` to `jekyll_picture_tag`, allowing us to use rubygems again.
55
+ * Rename gem from `jekyll-picture-tag` to `jekyll_picture_tag`, allowing us to
56
+ use rubygems again.
36
57
  * Add new output format: `naked_srcset`.
37
58
  * 1.3.1 Jun 21, 2019: Bugfix
38
59
  * 1.3.0 Jun 7, 2019:
39
60
  * Initial compatibility with Jekyll 4.0
40
61
  * bugfixes
41
- * change to generated image naming-- The first build after this update will be longer, and you
42
- might want to clear out your generated images.
62
+ * change to generated image naming-- The first build after this update will be
63
+ longer, and you might want to clear out your generated images.
43
64
  * 1.2.0 Feb 9, 2019:
44
65
  * Add nomarkdown fix
45
66
  * noscript option
@@ -50,7 +71,8 @@
50
71
  * auto-orient images before stripping metadata
51
72
  * 1.0.2 Jan 18, 2019: Fix ruby version specification
52
73
  * 1.0.1 Jan 13, 2019: Added ruby version checking
53
- * **1.0.0** Nov 27, 2018: Rewrite from the ground up. See the [migration guide]({{ site.baseurl }}/migration).
74
+ * **1.0.0** Nov 27, 2018: Rewrite from the ground up. See the
75
+ * [migration guide]({{ site.baseurl }}/users/notes/migration).
54
76
  * 0.2.2 Aug 2, 2013: Bugfixes
55
77
  * 0.2.1 Jul 17, 2013: Refactor again, add Liquid parsing.
56
78
  * 0.2.0 Jul 14, 2013: Rewrite code base, bring in line with Jekyll Image Tag.
@@ -1,12 +1,15 @@
1
1
  ---
2
- id: quickstart
3
2
  ---
4
3
 
5
- # Quick start / Demo
4
+ # Jekyll Picture Tag
5
+
6
+ Responsive Images, Done Correctly.
7
+
8
+ ## Quick start / Demo
6
9
 
7
10
  **All configuration is optional.** Here's the simplest possible use case:
8
11
 
9
- 1. [Install]({{ site.baseurl }}/installation)
12
+ 1. [Install]({{ site.baseurl }}/users/installation)
10
13
 
11
14
  2. Write this: {% raw %} `{% picture test.jpg %}` {% endraw %}
12
15
 
@@ -31,24 +34,31 @@ id: quickstart
31
34
  Create `_data/picture.yml`, add the following:
32
35
 
33
36
  ```yml
34
- markup_presets:
37
+ presets:
35
38
  default:
36
39
  formats: [webp, original]
37
40
  ```
38
41
 
42
+ **Note:** Order matters! `[webp, jpg]` will offer webp-images first. The
43
+ browser will pick the *first* format it can work with. So if the order is
44
+ reversed `[jpg, webp]` it will use the jpg image before the webp.
39
45
 
40
46
  ### Here's a more complete demonstration:
41
47
 
42
- [Presets]({{ site.baseurl }}/presets) are named collections of settings that tell JPT what you want it to give you.
43
- Media presets are just CSS media queries, and markup presets determine the output text and images.
44
- You choose one with the second [tag parameter]({{ site.baseurl }}/usage), or omit for the `default` (as in these
45
- examples). They are located in `_data/picture.yml`. Here's an example:
48
+ [Presets]({{ site.baseurl }}/users/presets) are named collections of settings.
49
+ You choose one with the second [tag
50
+ parameter]({{site.baseurl}}/users/liquid_tag), or omit for the `default` (as in
51
+ these examples). They are located in `_data/picture.yml`. Alongside `presets`,
52
+ we also set named `media_queries` for easy reference. Here's an example:
53
+
46
54
 
47
55
  ```yml
48
- media_presets:
56
+ # _data/picture.yml
57
+
58
+ media_queries:
49
59
  mobile: 'max-width: 600px'
50
60
 
51
- markup_presets:
61
+ presets:
52
62
  default:
53
63
  widths: [600, 900, 1200]
54
64
  formats: [webp, original]
@@ -57,52 +67,64 @@ markup_presets:
57
67
  size: 500px
58
68
  ```
59
69
 
60
- Write this:
70
+ Imagemagick can easily crop images to an aspect ratio, though you should **read
71
+ the whole installation guide before using this feature**. With the above preset,
72
+ if you write this:
61
73
 
62
74
  {% raw %}
63
- `{% picture test.jpg mobile: test2.jpg --alt Alternate Text %}`
75
+ `{% picture test.jpg 3:2 mobile: test2.jpg 1:1 --alt Alternate Text %}`
64
76
  {% endraw %}
65
77
 
66
- Get this:
78
+ You'll get something like this:
67
79
 
68
80
  ```html
69
81
  <!-- Formatted for readability -->
70
82
 
71
83
  <picture>
72
84
  <source
73
- sizes="(max-width: 600px) 80vw, 600px"
85
+ type="image/webp"
74
86
  media="(max-width: 600px)"
87
+ sizes="(max-width: 600px) 80vw, 600px"
75
88
  srcset="
76
- /generated/test2-600-21bb6f.webp 600w,
77
- /generated/test2-900-21bb6f.webp 900w,
78
- /generated/test2-1200-21bb6f.webp 1200w
79
- "
80
- type="image/webp">
89
+ /generated/test2-600-21bb6fGUW.webp 600w,
90
+ /generated/test2-900-21bb6fGUW.webp 900w,
91
+ /generated/test2-1200-21bb6fGUW.webp 1200w
92
+ ">
81
93
  <source
94
+ type="image/webp"
82
95
  sizes="(max-width: 600px) 80vw, 600px"
83
96
  srcset="
84
- /generated/test-600-195f7d.webp 600w,
85
- /generated/test-900-195f7d.webp 900w,
86
- /generated/test-1200-195f7d.webp 1200w
87
- "
88
- type="image/webp">
97
+ /generated/test-600-195f7d192.webp 600w,
98
+ /generated/test-900-195f7d192.webp 900w,
99
+ /generated/test-1200-195f7d192.webp 1200w
100
+ ">
89
101
  <source
90
- sizes="(max-width: 600px) 80vw, 600px"
102
+ type="image/jpeg"
91
103
  media="(max-width: 600px)"
104
+ sizes="(max-width: 600px) 80vw, 600px"
92
105
  srcset="
93
- /generated/test2-600-21bb6f.jpg 600w,
94
- /generated/test2-900-21bb6f.jpg 900w,
95
- /generated/test2-1200-21bb6f.jpg 1200w
96
- "
97
- type="image/jpeg">
106
+ /generated/test2-600-21bb6fGUW.jpg 600w,
107
+ /generated/test2-900-21bb6fGUW.jpg 900w,
108
+ /generated/test2-1200-21bb6fGUW.jpg 1200w
109
+ ">
98
110
  <source
111
+ type="image/jpeg"
99
112
  sizes="(max-width: 600px) 80vw, 600px"
100
113
  srcset="
101
- /generated/test-600-195f7d.jpg 600w,
102
- /generated/test-900-195f7d.jpg 900w,
103
- /generated/test-1200-195f7d.jpg 1200w
104
- "
105
- type="image/jpeg">
106
- <img src="/generated/test-800-195f7d.jpg" alt="Alternate Text">
114
+ /generated/test-600-195f7d192.jpg 600w,
115
+ /generated/test-900-195f7d192.jpg 900w,
116
+ /generated/test-1200-195f7d192.jpg 1200w
117
+ ">
118
+ <img src="/generated/test-800-195f7dGUW.jpg" alt="Alternate Text">
107
119
  </picture>
108
120
  ```
121
+
122
+ In other words, you have the art direction, format switching, and resolution
123
+ switching problems *solved*, with a one-liner and a nicely readable config file
124
+ that is 1/3 as long as the output markup. Lighthouse is happy, and you don't
125
+ even need to crop things yourself.
126
+
127
+ That isn't a complete demonstration of Jekyll Picture Tag's feature set; it can
128
+ (among other things) add width & height attributes to prevent page reflow, add a
129
+ link to the source image (or anywhere else), and adjust image quality. See the
130
+ docs for more.
@@ -0,0 +1,35 @@
1
+ ---
2
+ sort: 5
3
+ ---
4
+
5
+ # CDN
6
+
7
+ Use for images that are hosted at a different domain or subdomain than the
8
+ Jekyll site root. Overrides `relative_url`.
9
+
10
+ ## URL
11
+
12
+ *Format:* `cdn_url: (url)`
13
+
14
+ *Example:* `cdn_url: https://cdn.example.com`
15
+
16
+ *Default*: none
17
+
18
+ ## Environments
19
+
20
+ It's likely that if you're using a CDN, you may not want to use it in your local
21
+ development environment. This allows you to build a site with local images while
22
+ in development, and still push to a CDN when you build for production by
23
+ specifying a different
24
+ [environment](https://jekyllrb.com/docs/configuration/environments/).
25
+
26
+ *Format:* `cdn_environments: (array of strings)`
27
+
28
+ *Example:* `cdn_environments: ['production', 'staging']`
29
+
30
+ *Default*: `['production']`
31
+
32
+ **Note that the default jekyll environment is `development`**, meaning that if
33
+ you only set `cdn_url` and run `jekyll serve` or `jekyll build`, nothing will
34
+ change. Either run `JEKYLL_ENV=production bundle exec jekyll build`, or add
35
+ `development` to this setting.
@@ -0,0 +1,34 @@
1
+ ---
2
+ sort: 1
3
+ ---
4
+
5
+ # Directories
6
+
7
+ Define where JPT should look for source images, and where it should place
8
+ generated images.
9
+
10
+ ## Source
11
+
12
+ *Format:* `source: (directory)`
13
+
14
+ *Example:* `source: images/`
15
+
16
+ *Default:* Jekyll site root.
17
+
18
+ Base directory for your source images, relative to the Jekyll site root. For
19
+ example, if set to `images/_fullsize`:
20
+
21
+ this tag: {% raw %} `{% picture enishte/portrait.jpg %}` {% endraw %}
22
+ will use this path: `images/_fullsize/enishte/portrait.jpg`.
23
+
24
+ ## Output
25
+
26
+ *Format:* `output: (directory)`
27
+
28
+ *Example:* `output: resized_images/`
29
+
30
+ *Default*: `generated/`
31
+
32
+ Save resized, reformatted images to this directory in your compiled site. The
33
+ `source` directory structure is maintained. Relative to your compiled site
34
+ directory, which means `_site/` unless you've changed it.
@@ -0,0 +1,24 @@
1
+ ---
2
+ sort: 7
3
+ ---
4
+
5
+ # Disable Jekyll Picture Tag
6
+
7
+ *Format:* `disabled: (true|false|environment|array of environments)`
8
+
9
+ *Examples:*
10
+
11
+ - `disabled: true`
12
+
13
+ - `disabled: development`
14
+
15
+ - `disabled: [development, staging]`
16
+
17
+ *Default:* `false`
18
+
19
+ Disable image and markup generation entirely. Useful for debugging, or to speed
20
+ up site builds when you're working on something else.
21
+
22
+ Hint: If you're going to toggle this frequently, you might use a Jekyll
23
+ Environment. Set this to something like `nopics`, and then start Jekyll with
24
+ `JEKYLL_ENV=nopics bundle exec jekyll serve`.
@@ -0,0 +1,28 @@
1
+ ---
2
+ sort: 4
3
+ ---
4
+
5
+ # Fast Build
6
+
7
+ *Format:* `fast_build: (boolean|environment|environments)`
8
+
9
+ *Examples:*
10
+
11
+ - `fast_build: true`
12
+
13
+ - `fast_build: development`
14
+
15
+ - `fast_build: [development, staging]`
16
+
17
+ *Default:* `false`
18
+
19
+ *Might* make your builds faster (depending on hardware and how many images you
20
+ have) by making a tradeoff: assuming that the filename alone is enough to
21
+ uniquely identify a source image. This doesn't speed up image generation, just
22
+ detection of whether or not it's necessary.
23
+
24
+ Ordinarily, JPT computes an MD5 hash for every source image, every site build.
25
+ This ensures that if you replace one image with another, but keep the filename
26
+ the same, JPT will correctly generate images for the new file. Enable this
27
+ setting to skip MD5 hash checking and just assume that if the filename, format,
28
+ and width match then it's the right one.