jekyll-picture-tag 0.2.3 → 0.3.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: d5973c7f85a12ce7efb0a109d27a102012fd8d11
4
- data.tar.gz: cab2315e25e0140dcf35aed001b1d6acd8204531
3
+ metadata.gz: f8aa94e4a07e2076e502bb11471d4bed3cb6fd90
4
+ data.tar.gz: d0f17151a2d776a335fa89ecde5b39ad8ad412ef
5
5
  SHA512:
6
- metadata.gz: 9401800983de613fc69419effd1fd0ad44d4c8698b103368e01adb459e9104448ee9fc2acb05d84ccc68b53a2b00b71baed0a2177fb6972ad221fb03695836f1
7
- data.tar.gz: a9f21424491affe44ec6f58ead9aeb4ee1794a28fb2e6b602f8ed1608d63b1ea6af1fc579926909bcac9a1793021acb70ecede32f6706d73047ecb786a20ab70
6
+ metadata.gz: 57583d5abe715eefb55b29da796ae45ec95a3ee97bc6d082f4d00babaefd9f5fdcc043209ce51ba8e0b41384069cfdeccbe01d9f5ed2247185898e271ca0e6ab
7
+ data.tar.gz: cdd134f5929466984007ba9d598ad61e64b07054ea4bd2af7e2230ad1f6e848cc2d81116ec7637ba9bcc15ec1392f552fb5a31c0cb4a73efda2725e14ca8c3fa
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "jekyll-picture-tag"
8
- spec.version = '0.2.3'
8
+ spec.version = '0.3.0'
9
9
  spec.authors = ['Robert Wierzbowski', "Brendan Tobolaski"]
10
10
  spec.email = ['hello@robwierzbowski.com', "brendan@tobolaski.com"]
11
11
 
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency 'mini_magick', '~> 3.8.0'
30
30
  spec.add_dependency 'fastimage', '~> 1.6.4'
31
- spec.add_runtime_dependency 'jekyll', '< 3'
31
+ spec.add_runtime_dependency 'jekyll', '< 4'
32
32
  end
@@ -39,6 +39,7 @@ module Jekyll
39
39
  # Gather settings
40
40
  site = context.registers[:site]
41
41
  settings = site.config['picture']
42
+ url = site.config['url']
42
43
  markup = /^(?:(?<preset>[^\s.:\/]+)\s+)?(?<image_src>[^\s]+\.[a-zA-Z0-9]{3,4})\s*(?<source_src>(?:(source_[^\s.:\/]+:\s+[^\s]+\.[a-zA-Z0-9]{3,4})\s*)+)?(?<html_attr>[\s\S]+)?$/.match(render_markup)
43
44
  preset = settings['presets'][ markup[:preset] ] || settings['presets']['default']
44
45
 
@@ -150,17 +151,26 @@ module Jekyll
150
151
  if settings['markup'] == 'picture'
151
152
 
152
153
  source_tags = ''
153
- source_keys.each { |source|
154
+ source_keys.each do |source|
154
155
  media = " media=\"#{instance[source]['media']}\"" unless source == 'source_default'
155
- source_tags += "#{markdown_escape * 4}<source srcset=\"#{instance[source][:generated_src]}\"#{media}>\n"
156
- }
156
+ source_tags += "#{markdown_escape * 4}<source srcset=\"#{url}#{instance[source][:generated_src]}\"#{media}>\n"
157
+ end
157
158
 
158
159
  # Note: we can't indent html output because markdown parsers will turn 4 spaces into code blocks
159
160
  # Note: Added backslash+space escapes to bypass markdown parsing of indented code below -WD
160
161
  picture_tag = "<picture>\n"\
161
162
  "#{source_tags}"\
162
- "#{markdown_escape * 4}<img srcset=\"#{instance['source_default'][:generated_src]}\" #{html_attr_string}>\n"\
163
+ "#{markdown_escape * 4}<img src=\"#{url}#{instance['source_default'][:generated_src]}\" #{html_attr_string}>\n"\
163
164
  "#{markdown_escape * 2}</picture>\n"
165
+ elsif settings['markup'] == 'interchange'
166
+
167
+ interchange_data = Array.new
168
+ source_keys.reverse.each do |source|
169
+ interchange_data << "[#{url}#{instance[source][:generated_src]}, #{source == 'source_default' ? '(default)' : instance[source]['media']}]"
170
+ end
171
+
172
+ picture_tag = %Q{<img data-interchange="#{interchange_data.join ', '}" #{html_attr_string} />\n}
173
+ picture_tag += %Q{<noscript><img src="#{url}#{instance['source_default'][:generated_src]}" #{html_attr_string} /></noscript>}
164
174
 
165
175
  elsif settings['markup'] == 'img'
166
176
  # TODO implement <img srcset/sizes>
@@ -171,7 +181,12 @@ module Jekyll
171
181
  end
172
182
 
173
183
  def generate_image(instance, site_source, site_dest, image_source, image_dest, baseurl)
174
- digest = Digest::MD5.hexdigest(File.read(File.join(site_source, image_source, instance[:src]))).slice!(0..5)
184
+ begin
185
+ digest = Digest::MD5.hexdigest(File.read(File.join(site_source, image_source, instance[:src]))).slice!(0..5)
186
+ rescue Errno::ENOENT
187
+ warn "Warning:".yellow + " source image #{instance[:src]} is missing."
188
+ return ""
189
+ end
175
190
 
176
191
  image_dir = File.dirname(instance[:src])
177
192
  ext = File.extname(instance[:src])
data/readme.md CHANGED
@@ -128,6 +128,9 @@ Defaults to `{compiled Jekyll site}/generated`.
128
128
 
129
129
  Choose `picture` to output markup based on the `<picture>` element. Future options may include `srcset` but have not yet been implemented.
130
130
 
131
+ Choose `interchange` to use markup compatible with
132
+ [ZURB Foundation's Interchange](http://foundation.zurb.com/docs/components/interchange.html).
133
+
131
134
  #### presets
132
135
 
133
136
  Presets contain reusable settings for a Jekyll Picture Tag. Each is made up of a list of sources, and an optional attributes list and ppi array.
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: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Wierzbowski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-27 00:00:00.000000000 Z
12
+ date: 2015-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "<"
75
75
  - !ruby/object:Gem::Version
76
- version: '3'
76
+ version: '4'
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "<"
82
82
  - !ruby/object:Gem::Version
83
- version: '3'
83
+ version: '4'
84
84
  description: |2
85
85
  Jekyll Picture Tag is a liquid tag that adds responsive images to your Jekyll static site. It follows the picture
86
86
  element pattern, and polyfills older browsers with Picturefill. Jekyll Picture Tag automatically creates resized