jekyll-responsive_image 0.16.0 → 0.17.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
  SHA1:
3
- metadata.gz: 534c82ce7326662e632448980f89f6947e4841b9
4
- data.tar.gz: 4921e6287f51d0791971058e5826248d811d5292
3
+ metadata.gz: 7ebfa9c38ff18b9b454d41f8e9256291c3886a4f
4
+ data.tar.gz: 91e32dedd74ab0265cf979dcdb5e58a36577239e
5
5
  SHA512:
6
- metadata.gz: 5e1a5fca6619d532b5c7b00735aa26e3c217cb998551f16aeb2518cfad7633aa7727d7fbb3a243fbb967a25bd1d5dd2983005c407b596c6953cc3249133f2fe3
7
- data.tar.gz: 53f04568bc9e22a72e8369bffabacc3a9ae82f51201e796db97f247f06473471353a837fa1ed5dc401f37cdcb435fc3c27fa3c30b10bdc0018ecbebfc59fe3b7
6
+ metadata.gz: cdb668bce4e395420906a8a7d047afd612fe6221c2b3fd612e385f8d14c1781e1eea01489a7538757cb765d47839ab4de9445e6957ea1f912be069dd5a326238
7
+ data.tar.gz: 07ef7390f147509a3ad1dcf6a747eccf93179f3f6dca33ba155065a0cf69cc7f584956f6a57c7df91439234988739a282f70ae6c689655a487798b2a3f9c4108
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Jekyll Responsive Images is a [Jekyll](http://jekyllrb.com/) plugin and utility for automatically resizing images. Its intended use is for sites which want to display responsive images using something like [`srcset`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img#Specifications) or [Imager.js](https://github.com/BBC-News/Imager.js/).
4
4
 
5
- [![Build Status](https://travis-ci.org/wildlyinaccurate/jekyll-responsive-image.svg?branch=master)](https://travis-ci.org/wildlyinaccurate/jekyll-responsive-image)
6
- [![Coverage Status](https://coveralls.io/repos/wildlyinaccurate/jekyll-responsive-images/badge.svg?branch=master&service=github)](https://coveralls.io/github/wildlyinaccurate/jekyll-responsive-images?branch=master)
7
- [![Dependency Status](https://gemnasium.com/wildlyinaccurate/jekyll-responsive-images.svg)](https://gemnasium.com/wildlyinaccurate/jekyll-responsive-images)
5
+ [![Build Status](https://img.shields.io/travis/wildlyinaccurate/jekyll-responsive-image.svg?style=flat-square)](https://travis-ci.org/wildlyinaccurate/jekyll-responsive-image)
6
+ [![Coverage Status](https://img.shields.io/coveralls/wildlyinaccurate/jekyll-responsive-image.svg?style=flat-square)](https://coveralls.io/repos/github/wildlyinaccurate/jekyll-responsive-image/badge.svg?branch=master)
7
+ [![Dependency Status](https://img.shields.io/gemnasium/wildlyinaccurate/jekyll-responsive-images.svg?style=flat-square)](https://gemnasium.com/wildlyinaccurate/jekyll-responsive-images)
8
8
 
9
9
  ## Installation
10
10
 
@@ -64,6 +64,13 @@ responsive_image:
64
64
  # %{height} Height of the resized image
65
65
  #
66
66
  output_path_format: assets/resized/%{width}/%{basename}
67
+
68
+ # By default, only images referenced by the responsive_image and responsive_image_block
69
+ # tags are resized. Here you can set a list of paths or path globs to resize other
70
+ # images. This is useful for resizing images which will be referenced from stylesheets.
71
+ extra_images:
72
+ - assets/foo/bar.png
73
+ - assets/bgs/*.png
67
74
  ```
68
75
 
69
76
  ## Usage
@@ -0,0 +1,43 @@
1
+ Feature: Extra image generation
2
+ As a Jekyll user
3
+ I want to resize images that aren't used in posts or pages
4
+ In order to use them in my stylesheets
5
+
6
+ Scenario: Resizing a single image
7
+ Given I have a responsive_image configuration with:
8
+ """
9
+ sizes:
10
+ - width: 100
11
+
12
+ extra_images:
13
+ - assets/test.png
14
+ """
15
+
16
+ And I have a file "index.html" with "Hello, world!"
17
+ When I run Jekyll
18
+ Then the image "assets/resized/test-100x50.png" should have the dimensions "100x50"
19
+
20
+ Scenario: Using glob patterns
21
+ Given I have a responsive_image configuration with:
22
+ """
23
+ sizes:
24
+ - width: 100
25
+
26
+ extra_images:
27
+ - assets/*.png
28
+ """
29
+
30
+ And I have a file "index.html" with "Hello, world!"
31
+ When I run Jekyll
32
+ Then the image "assets/resized/test-100x50.png" should have the dimensions "100x50"
33
+
34
+ Scenario: No extra images
35
+ Given I have a responsive_image configuration with:
36
+ """
37
+ sizes:
38
+ - width: 100
39
+ """
40
+
41
+ And I have a file "index.html" with "Hello, world!"
42
+ When I run Jekyll
43
+ Then the file "assets/resized/test-100x50.png" should not exist
@@ -28,6 +28,7 @@ Feature: Responsive image generation
28
28
  """
29
29
  {% responsive_image path: assets/test.png %}
30
30
  {% responsive_image path: assets/subdir/test.png %}
31
+ {% responsive_image path: assets/test.png cache: true %}
31
32
  """
32
33
 
33
34
  When I run Jekyll
@@ -33,7 +33,11 @@ Then /^I should see "(.+)" in "(.*)"$/ do |text, file|
33
33
  end
34
34
 
35
35
  Then /^the file "(.+)" should exist$/ do |path|
36
- assert File.exists?(path)
36
+ assert File.exist?(path)
37
+ end
38
+
39
+ Then /^the file "(.+)" should not exist$/ do |path|
40
+ assert !File.exist?(path)
37
41
  end
38
42
 
39
43
  Then /^the image "(.+)" should have the dimensions "(\d+)x(\d+)"$/ do |path, width, height|
@@ -13,6 +13,7 @@ require 'jekyll/responsive_image/resize_handler'
13
13
  require 'jekyll/responsive_image/common'
14
14
  require 'jekyll/responsive_image/tag'
15
15
  require 'jekyll/responsive_image/block'
16
+ require 'jekyll/responsive_image/extra_image_generator'
16
17
 
17
18
  Liquid::Template.register_tag('responsive_image', Jekyll::ResponsiveImage::Tag)
18
19
  Liquid::Template.register_tag('responsive_image_block', Jekyll::ResponsiveImage::Block)
@@ -5,6 +5,7 @@ module Jekyll
5
5
  'base_path' => 'assets',
6
6
  'output_path_format' => 'assets/resized/%{filename}-%{width}x%{height}.%{extension}',
7
7
  'sizes' => [],
8
+ 'extra_images' => []
8
9
  }.freeze
9
10
 
10
11
  class << self
@@ -0,0 +1,15 @@
1
+ module Jekyll
2
+ class ResponsiveImage
3
+ class ExtraImageGenerator < Jekyll::Generator
4
+ include Jekyll::ResponsiveImage::Common
5
+
6
+ def generate(site)
7
+ config = make_config(site)
8
+
9
+ config['extra_images'].each do |pathspec|
10
+ Dir.glob(pathspec) { |path| ImageProcessor.process(path, config) }
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -4,7 +4,7 @@ module Jekyll
4
4
  include ResponsiveImage::Utils
5
5
 
6
6
  def process(image_path, config)
7
- raise SyntaxError.new("Invalid image path specified: #{image_path}") unless File.exists?(image_path.to_s)
7
+ raise SyntaxError.new("Invalid image path specified: #{image_path}") unless File.exist?(image_path.to_s)
8
8
 
9
9
  resize_handler = ResizeHandler.new
10
10
  img = Magick::Image::read(image_path).first
@@ -17,7 +17,7 @@ module Jekyll
17
17
  resized.push(image_hash(config['base_path'], filepath, width, height))
18
18
 
19
19
  # Don't resize images more than once
20
- next if File.exists?(filepath)
20
+ next if File.exist?(filepath)
21
21
 
22
22
  ensure_output_dir_exists!(File.dirname(filepath))
23
23
 
@@ -35,7 +35,7 @@ module Jekyll
35
35
 
36
36
  i.destroy!
37
37
  end
38
-
38
+
39
39
  img.destroy!
40
40
 
41
41
  resized
@@ -46,7 +46,7 @@ module Jekyll
46
46
  end
47
47
 
48
48
  def ensure_output_dir_exists!(dir)
49
- unless Dir.exists?(dir)
49
+ unless Dir.exist?(dir)
50
50
  Jekyll.logger.info "Creating output directory #{dir}"
51
51
  FileUtils.mkdir_p(dir)
52
52
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  class ResponsiveImage
3
- VERSION = '0.16.0'.freeze
3
+ VERSION = '0.17.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-responsive_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Wynn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2016-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -66,6 +66,7 @@ files:
66
66
  - LICENSE
67
67
  - README.md
68
68
  - Rakefile
69
+ - features/extra-image-generation.feature
69
70
  - features/fixtures/_includes/base-url.html
70
71
  - features/fixtures/_includes/custom-template.html
71
72
  - features/fixtures/_includes/responsive-image.html
@@ -82,6 +83,7 @@ files:
82
83
  - lib/jekyll/responsive_image/block.rb
83
84
  - lib/jekyll/responsive_image/common.rb
84
85
  - lib/jekyll/responsive_image/defaults.rb
86
+ - lib/jekyll/responsive_image/extra_image_generator.rb
85
87
  - lib/jekyll/responsive_image/image_processor.rb
86
88
  - lib/jekyll/responsive_image/render_cache.rb
87
89
  - lib/jekyll/responsive_image/resize_handler.rb
@@ -113,6 +115,7 @@ signing_key:
113
115
  specification_version: 4
114
116
  summary: Responsive images for Jekyll via srcset
115
117
  test_files:
118
+ - features/extra-image-generation.feature
116
119
  - features/fixtures/_includes/base-url.html
117
120
  - features/fixtures/_includes/custom-template.html
118
121
  - features/fixtures/_includes/responsive-image.html