jekyll_picture_tag 1.14.0 → 2.0.0pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc +2 -0
  3. data/.github/workflows/code-checks.yml +2 -12
  4. data/.rubocop.yml +2 -0
  5. data/.ruby-version +1 -1
  6. data/docs/devs/contributing/code.md +11 -3
  7. data/docs/devs/contributing/testing.md +0 -11
  8. data/docs/devs/releases.md +20 -0
  9. data/docs/index.md +32 -17
  10. data/docs/logo.png +0 -0
  11. data/docs/logo.svg +880 -0
  12. data/docs/users/getting_started.md +55 -0
  13. data/docs/users/installation.md +17 -38
  14. data/docs/users/liquid_tag/argument_reference/crop.md +21 -36
  15. data/docs/users/liquid_tag/examples.md +13 -25
  16. data/docs/users/liquid_tag/index.md +1 -1
  17. data/docs/users/notes/{migration.md → migration_1.md} +1 -1
  18. data/docs/users/notes/migration_2.md +99 -0
  19. data/docs/users/presets/cropping.md +21 -22
  20. data/docs/users/presets/default.md +11 -3
  21. data/docs/users/presets/examples.md +77 -45
  22. data/docs/users/presets/fallback_image.md +1 -1
  23. data/docs/users/presets/html_attributes.md +1 -1
  24. data/docs/users/presets/image_formats.md +3 -3
  25. data/docs/users/presets/image_quality.md +70 -55
  26. data/docs/users/presets/index.md +78 -42
  27. data/docs/users/presets/link_source.md +1 -1
  28. data/docs/users/presets/media_queries.md +1 -1
  29. data/docs/users/presets/nomarkdown_override.md +1 -1
  30. data/docs/users/presets/pixel_ratio_srcsets.md +1 -1
  31. data/docs/users/presets/width_height_attributes.md +1 -1
  32. data/docs/users/presets/width_srcsets.md +61 -23
  33. data/docs/users/tutorial.md +97 -0
  34. data/jekyll_picture_tag.gemspec +33 -23
  35. data/lib/jekyll_picture_tag.rb +8 -6
  36. data/lib/jekyll_picture_tag/cache.rb +64 -3
  37. data/lib/jekyll_picture_tag/defaults/global.rb +18 -0
  38. data/lib/jekyll_picture_tag/defaults/presets.rb +57 -0
  39. data/lib/jekyll_picture_tag/images.rb +1 -0
  40. data/lib/jekyll_picture_tag/images/generated_image.rb +25 -63
  41. data/lib/jekyll_picture_tag/images/image_file.rb +90 -0
  42. data/lib/jekyll_picture_tag/images/img_uri.rb +3 -12
  43. data/lib/jekyll_picture_tag/images/source_image.rb +44 -9
  44. data/lib/jekyll_picture_tag/instructions.rb +70 -6
  45. data/lib/jekyll_picture_tag/instructions/children/config.rb +128 -0
  46. data/lib/jekyll_picture_tag/instructions/children/context.rb +24 -0
  47. data/lib/jekyll_picture_tag/instructions/children/params.rb +90 -0
  48. data/lib/jekyll_picture_tag/instructions/children/parsers.rb +41 -0
  49. data/lib/jekyll_picture_tag/instructions/children/preset.rb +182 -0
  50. data/lib/jekyll_picture_tag/instructions/parents/conditional_instruction.rb +69 -0
  51. data/lib/jekyll_picture_tag/instructions/parents/env_instruction.rb +29 -0
  52. data/lib/jekyll_picture_tag/output_formats/basic.rb +5 -17
  53. data/lib/jekyll_picture_tag/parsers.rb +5 -0
  54. data/lib/jekyll_picture_tag/{instructions → parsers}/arg_splitter.rb +1 -1
  55. data/lib/jekyll_picture_tag/parsers/configuration.rb +28 -0
  56. data/lib/jekyll_picture_tag/{instructions → parsers}/html_attributes.rb +1 -1
  57. data/lib/jekyll_picture_tag/parsers/preset.rb +43 -0
  58. data/lib/jekyll_picture_tag/{instructions → parsers}/tag_parser.rb +15 -12
  59. data/lib/jekyll_picture_tag/router.rb +35 -93
  60. data/lib/jekyll_picture_tag/srcsets/basic.rb +4 -10
  61. data/lib/jekyll_picture_tag/utils.rb +10 -20
  62. data/lib/jekyll_picture_tag/version.rb +1 -1
  63. data/readme.md +2 -0
  64. metadata +124 -106
  65. data/Dockerfile +0 -9
  66. data/docs/users/notes/input_checking.md +0 -6
  67. data/docs/users/presets/strip_metadata.md +0 -13
  68. data/install_imagemagick.sh +0 -23
  69. data/jekyll-picture-tag.gemspec +0 -52
  70. data/lib/jekyll-picture-tag.rb +0 -25
  71. data/lib/jekyll_picture_tag/cache/base.rb +0 -61
  72. data/lib/jekyll_picture_tag/cache/generated.rb +0 -20
  73. data/lib/jekyll_picture_tag/cache/source.rb +0 -19
  74. data/lib/jekyll_picture_tag/defaults/global.yml +0 -13
  75. data/lib/jekyll_picture_tag/defaults/presets.yml +0 -12
  76. data/lib/jekyll_picture_tag/instructions/configuration.rb +0 -121
  77. data/lib/jekyll_picture_tag/instructions/preset.rb +0 -122
  78. data/lib/jekyll_picture_tag/instructions/set.rb +0 -75
@@ -53,11 +53,11 @@ module PictureTag
53
53
  end
54
54
 
55
55
  def width_attribute
56
- files.first.source_width.to_s
56
+ source_image.width.to_s
57
57
  end
58
58
 
59
59
  def height_attribute
60
- files.first.source_height.to_s
60
+ source_image.height.to_s
61
61
  end
62
62
 
63
63
  private
@@ -86,11 +86,7 @@ module PictureTag
86
86
  end
87
87
 
88
88
  def source_width
89
- @source_width ||= if PictureTag.crop(@media)
90
- target_files.first.source_width
91
- else
92
- @source_image.width
93
- end
89
+ source_image.width
94
90
  end
95
91
 
96
92
  def target_files
@@ -112,9 +108,7 @@ module PictureTag
112
108
  GeneratedImage.new(
113
109
  source_file: @source_image,
114
110
  width: width,
115
- format: @input_format,
116
- crop: PictureTag.crop(@media),
117
- gravity: PictureTag.gravity(@media)
111
+ format: @input_format
118
112
  )
119
113
  end
120
114
  end
@@ -2,28 +2,10 @@ module PictureTag
2
2
  # This is a little module to hold logic that doesn't fit other places. If it
3
3
  # starts getting big, refactor.
4
4
  module Utils
5
- # These are valid ImageMagick gravity arguments (relevant to our use
6
- # case):
7
- GRAVITIES =
8
- %w[center
9
- north
10
- northeast
11
- east
12
- southeast
13
- south
14
- southwest
15
- west
16
- northwest].freeze
17
-
18
- # This is an attempt to recognize valid imagemagick geometry arguments
19
- # with regex. It only tries to match values which don't preserve aspect
20
- # ratio, as they're the ones people might actually need here.
21
- GEOMETRY_REGEX = /\A\d*%?[x:]?\d*[%!]?([+-]\d+){,2}\Z/i.freeze
22
-
23
5
  class << self
24
6
  # Configure Jekyll to keep our generated files
25
7
  def keep_files
26
- dest_dir = PictureTag.config['picture']['output']
8
+ dest_dir = PictureTag.pconfig['output']
27
9
 
28
10
  # Chop a slash off the end, if it's there. Doesn't work otherwise.
29
11
  dest_dir = dest_dir[0..-2] if dest_dir =~ %r{/\z}
@@ -35,7 +17,7 @@ module PictureTag
35
17
 
36
18
  # Print a warning to the console
37
19
  def warning(message)
38
- return if PictureTag.config['picture']['suppress_warnings']
20
+ return if PictureTag.pconfig['suppress_warnings']
39
21
 
40
22
  warn 'Jekyll Picture Tag Warning: '.yellow + message
41
23
  end
@@ -64,6 +46,10 @@ module PictureTag
64
46
  input.split('_').map(&:capitalize).join
65
47
  end
66
48
 
49
+ def snakeize(input)
50
+ input.scan(/[A-Z][a-z]+/).map(&:downcase).join('_')
51
+ end
52
+
67
53
  # Linear interpolator. Pass it 2 values in the x array, 2 values
68
54
  # in the y array, and an x value, returns a y value.
69
55
  def interpolate(xvals, yvals, xval)
@@ -77,6 +63,10 @@ module PictureTag
77
63
  # y = mx + b
78
64
  (m * xval) + b
79
65
  end
66
+
67
+ def aspect_float(width, height)
68
+ width.to_f / height
69
+ end
80
70
  end
81
71
  end
82
72
  end
@@ -1,3 +1,3 @@
1
1
  module PictureTag
2
- VERSION = '1.14.0'.freeze
2
+ VERSION = '2.0.0pre1'.freeze
3
3
  end
data/readme.md CHANGED
@@ -1,3 +1,5 @@
1
+ ![Logo](docs/logo.svg)
2
+
1
3
  # Jekyll Picture Tag
2
4
 
3
5
  ![Tests & Formatting](https://github.com/rbuchberger/jekyll_picture_tag/workflows/Tests%20&%20Formatting/badge.svg)
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: 1.14.0
4
+ version: 2.0.0pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Wierzbowski
@@ -10,8 +10,92 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-01-10 00:00:00.000000000 Z
13
+ date: 2021-03-24 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: addressable
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.6'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '2.6'
29
+ - !ruby/object:Gem::Dependency
30
+ name: jekyll
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '4.0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '4.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: mime-types
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '3.0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: objective_elements
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.1'
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '1.1'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rainbow
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '3.0'
78
+ type: :runtime
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '3.0'
85
+ - !ruby/object:Gem::Dependency
86
+ name: ruby-vips
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: 2.0.17
92
+ type: :runtime
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: 2.0.17
15
99
  - !ruby/object:Gem::Dependency
16
100
  name: bundler
17
101
  requirement: !ruby/object:Gem::Requirement
@@ -32,14 +116,14 @@ dependencies:
32
116
  requirements:
33
117
  - - "~>"
34
118
  - !ruby/object:Gem::Version
35
- version: '5.11'
119
+ version: '5.14'
36
120
  type: :development
37
121
  prerelease: false
38
122
  version_requirements: !ruby/object:Gem::Requirement
39
123
  requirements:
40
124
  - - "~>"
41
125
  - !ruby/object:Gem::Version
42
- version: '5.11'
126
+ version: '5.14'
43
127
  - !ruby/object:Gem::Dependency
44
128
  name: minitest-rg
45
129
  requirement: !ruby/object:Gem::Requirement
@@ -74,14 +158,14 @@ dependencies:
74
158
  requirements:
75
159
  - - "~>"
76
160
  - !ruby/object:Gem::Version
77
- version: '1.10'
161
+ version: '1.1'
78
162
  type: :development
79
163
  prerelease: false
80
164
  version_requirements: !ruby/object:Gem::Requirement
81
165
  requirements:
82
166
  - - "~>"
83
167
  - !ruby/object:Gem::Version
84
- version: '1.10'
168
+ version: '1.1'
85
169
  - !ruby/object:Gem::Dependency
86
170
  name: pry
87
171
  requirement: !ruby/object:Gem::Requirement
@@ -194,82 +278,11 @@ dependencies:
194
278
  - - ">="
195
279
  - !ruby/object:Gem::Version
196
280
  version: '0'
197
- - !ruby/object:Gem::Dependency
198
- name: addressable
199
- requirement: !ruby/object:Gem::Requirement
200
- requirements:
201
- - - "~>"
202
- - !ruby/object:Gem::Version
203
- version: '2.6'
204
- type: :runtime
205
- prerelease: false
206
- version_requirements: !ruby/object:Gem::Requirement
207
- requirements:
208
- - - "~>"
209
- - !ruby/object:Gem::Version
210
- version: '2.6'
211
- - !ruby/object:Gem::Dependency
212
- name: mime-types
213
- requirement: !ruby/object:Gem::Requirement
214
- requirements:
215
- - - "~>"
216
- - !ruby/object:Gem::Version
217
- version: '3.0'
218
- type: :runtime
219
- prerelease: false
220
- version_requirements: !ruby/object:Gem::Requirement
221
- requirements:
222
- - - "~>"
223
- - !ruby/object:Gem::Version
224
- version: '3.0'
225
- - !ruby/object:Gem::Dependency
226
- name: mini_magick
227
- requirement: !ruby/object:Gem::Requirement
228
- requirements:
229
- - - "~>"
230
- - !ruby/object:Gem::Version
231
- version: '4.0'
232
- type: :runtime
233
- prerelease: false
234
- version_requirements: !ruby/object:Gem::Requirement
235
- requirements:
236
- - - "~>"
237
- - !ruby/object:Gem::Version
238
- version: '4.0'
239
- - !ruby/object:Gem::Dependency
240
- name: objective_elements
241
- requirement: !ruby/object:Gem::Requirement
242
- requirements:
243
- - - "~>"
244
- - !ruby/object:Gem::Version
245
- version: '1.1'
246
- type: :runtime
247
- prerelease: false
248
- version_requirements: !ruby/object:Gem::Requirement
249
- requirements:
250
- - - "~>"
251
- - !ruby/object:Gem::Version
252
- version: '1.1'
253
- - !ruby/object:Gem::Dependency
254
- name: jekyll
255
- requirement: !ruby/object:Gem::Requirement
256
- requirements:
257
- - - "<"
258
- - !ruby/object:Gem::Version
259
- version: '5'
260
- type: :runtime
261
- prerelease: false
262
- version_requirements: !ruby/object:Gem::Requirement
263
- requirements:
264
- - - "<"
265
- - !ruby/object:Gem::Version
266
- version: '5'
267
281
  description: |2
268
- Jekyll Picture Tag is a liquid tag that adds responsive images to your
269
- Jekyll static site.Jekyll Picture Tag automatically creates resized source
270
- images, is fully configurable, and covers all use cases including art
271
- direction and resolution switching — with a little YAML configuration and a
272
- simple template tag.
282
+ Jekyll Picture Tag adds responsive images to your Jekyll static site. It
283
+ automatically creates resized source images, is fully configurable, and
284
+ covers all use cases, including art direction and resolution switching, with
285
+ a little YAML configuration and a simple template tag.
273
286
  email:
274
287
  - robert@buchberger.cc
275
288
  executables: []
@@ -282,7 +295,6 @@ files:
282
295
  - ".rubocop.yml"
283
296
  - ".ruby-version"
284
297
  - ".solargraph.yml"
285
- - Dockerfile
286
298
  - Gemfile
287
299
  - LICENSE.txt
288
300
  - Rakefile
@@ -298,6 +310,8 @@ files:
298
310
  - docs/devs/index.md
299
311
  - docs/devs/releases.md
300
312
  - docs/index.md
313
+ - docs/logo.png
314
+ - docs/logo.svg
301
315
  - docs/users/configuration/directories.md
302
316
  - docs/users/configuration/disable.md
303
317
  - docs/users/configuration/fast_build.md
@@ -306,6 +320,7 @@ files:
306
320
  - docs/users/configuration/kramdown_fix.md
307
321
  - docs/users/configuration/suppress_warnings.md
308
322
  - docs/users/configuration/urls.md
323
+ - docs/users/getting_started.md
309
324
  - docs/users/index.md
310
325
  - docs/users/installation.md
311
326
  - docs/users/liquid_tag/argument_reference/alternate_images.md
@@ -321,10 +336,10 @@ files:
321
336
  - docs/users/notes/github_pages.md
322
337
  - docs/users/notes/html_attributes.md
323
338
  - docs/users/notes/index.md
324
- - docs/users/notes/input_checking.md
325
339
  - docs/users/notes/kramdown_bug.md
326
340
  - docs/users/notes/managing_images.md
327
- - docs/users/notes/migration.md
341
+ - docs/users/notes/migration_1.md
342
+ - docs/users/notes/migration_2.md
328
343
  - docs/users/presets/cropping.md
329
344
  - docs/users/presets/default.md
330
345
  - docs/users/presets/examples.md
@@ -342,31 +357,27 @@ files:
342
357
  - docs/users/presets/nomarkdown_override.md
343
358
  - docs/users/presets/pixel_ratio_srcsets.md
344
359
  - docs/users/presets/quality_width_graph.png
345
- - docs/users/presets/strip_metadata.md
346
360
  - docs/users/presets/width_height_attributes.md
347
361
  - docs/users/presets/width_srcsets.md
348
- - install_imagemagick.sh
349
- - jekyll-picture-tag.gemspec
362
+ - docs/users/tutorial.md
350
363
  - jekyll_picture_tag.gemspec
351
- - lib/jekyll-picture-tag.rb
352
364
  - lib/jekyll_picture_tag.rb
353
365
  - lib/jekyll_picture_tag/cache.rb
354
- - lib/jekyll_picture_tag/cache/base.rb
355
- - lib/jekyll_picture_tag/cache/generated.rb
356
- - lib/jekyll_picture_tag/cache/source.rb
357
- - lib/jekyll_picture_tag/defaults/global.yml
358
- - lib/jekyll_picture_tag/defaults/presets.yml
366
+ - lib/jekyll_picture_tag/defaults/global.rb
367
+ - lib/jekyll_picture_tag/defaults/presets.rb
359
368
  - lib/jekyll_picture_tag/images.rb
360
369
  - lib/jekyll_picture_tag/images/generated_image.rb
370
+ - lib/jekyll_picture_tag/images/image_file.rb
361
371
  - lib/jekyll_picture_tag/images/img_uri.rb
362
372
  - lib/jekyll_picture_tag/images/source_image.rb
363
373
  - lib/jekyll_picture_tag/instructions.rb
364
- - lib/jekyll_picture_tag/instructions/arg_splitter.rb
365
- - lib/jekyll_picture_tag/instructions/configuration.rb
366
- - lib/jekyll_picture_tag/instructions/html_attributes.rb
367
- - lib/jekyll_picture_tag/instructions/preset.rb
368
- - lib/jekyll_picture_tag/instructions/set.rb
369
- - lib/jekyll_picture_tag/instructions/tag_parser.rb
374
+ - lib/jekyll_picture_tag/instructions/children/config.rb
375
+ - lib/jekyll_picture_tag/instructions/children/context.rb
376
+ - lib/jekyll_picture_tag/instructions/children/params.rb
377
+ - lib/jekyll_picture_tag/instructions/children/parsers.rb
378
+ - lib/jekyll_picture_tag/instructions/children/preset.rb
379
+ - lib/jekyll_picture_tag/instructions/parents/conditional_instruction.rb
380
+ - lib/jekyll_picture_tag/instructions/parents/env_instruction.rb
370
381
  - lib/jekyll_picture_tag/output_formats.rb
371
382
  - lib/jekyll_picture_tag/output_formats/auto.rb
372
383
  - lib/jekyll_picture_tag/output_formats/basic.rb
@@ -379,6 +390,12 @@ files:
379
390
  - lib/jekyll_picture_tag/output_formats/naked_srcset.rb
380
391
  - lib/jekyll_picture_tag/output_formats/picture.rb
381
392
  - lib/jekyll_picture_tag/output_formats/readme.md
393
+ - lib/jekyll_picture_tag/parsers.rb
394
+ - lib/jekyll_picture_tag/parsers/arg_splitter.rb
395
+ - lib/jekyll_picture_tag/parsers/configuration.rb
396
+ - lib/jekyll_picture_tag/parsers/html_attributes.rb
397
+ - lib/jekyll_picture_tag/parsers/preset.rb
398
+ - lib/jekyll_picture_tag/parsers/tag_parser.rb
382
399
  - lib/jekyll_picture_tag/router.rb
383
400
  - lib/jekyll_picture_tag/srcsets.rb
384
401
  - lib/jekyll_picture_tag/srcsets/basic.rb
@@ -390,7 +407,8 @@ files:
390
407
  homepage: https://github.com/rbuchberger/jekyll_picture_tag
391
408
  licenses:
392
409
  - BSD-3-Clause
393
- metadata: {}
410
+ metadata:
411
+ documentation_uri: https://rbuchberger.github.io/jekyll_picture_tag/
394
412
  post_install_message:
395
413
  rdoc_options: []
396
414
  require_paths:
@@ -399,18 +417,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
399
417
  requirements:
400
418
  - - ">="
401
419
  - !ruby/object:Gem::Version
402
- version: '2.5'
420
+ version: '2.6'
403
421
  - - "<"
404
422
  - !ruby/object:Gem::Version
405
423
  version: '3'
406
424
  required_rubygems_version: !ruby/object:Gem::Requirement
407
425
  requirements:
408
- - - ">="
426
+ - - ">"
409
427
  - !ruby/object:Gem::Version
410
- version: '0'
411
- requirements: []
412
- rubyforge_project:
413
- rubygems_version: 2.7.6.2
428
+ version: 1.3.1
429
+ requirements:
430
+ - libvips
431
+ rubygems_version: 3.0.3
414
432
  signing_key:
415
433
  specification_version: 4
416
434
  summary: Easy responsive images for Jekyll.