jekyll-responsive_image 0.14.0 → 0.15.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: 26a3868d77490e6edcf5c932cffb129cf05cdab6
4
- data.tar.gz: d3b7bcc0c173b2938cf7486dd45967a5a0978f9a
3
+ metadata.gz: 1743140fd0b42c8ef0b8e05fc9a9e8091faac924
4
+ data.tar.gz: fcf51455cd7b7d5569ade0da764c837449930fb8
5
5
  SHA512:
6
- metadata.gz: 195fda571ae489df9febc69e482b4b7ae4b3d1cc65289d4c97f70c5e2bcfe43c850cc921d94f21e1c2fd4c53d22970820ddba3586ab346e6c0268a14853e2500
7
- data.tar.gz: 6f4ef84402e49e4e0f2b2278aef28d97ccebfb9f7b7e484ea9f522e67c3b49e84385dde8e6c5ce31a804fbd63f1c4afd166aa2517b54f3335bbd81b4f2c5e3d5
6
+ metadata.gz: 1e5205e6fd9fb1c02e46dba59630e8d0562f19cb45f7c470fbc1ce4105524e6284dc6944f149e238ef9760ff33dd2dc2b2418cf35f99ab77dd6c145d2d611060
7
+ data.tar.gz: e1888012ed3d9e3ae74014ffb094b18af8bbfbc80106d43dd421a363e83d33f639f4a4978c5cdb350136b5be5575389f6bb14feefcc09746c8e87a7e8a41d3e0
@@ -4,20 +4,30 @@ module Jekyll
4
4
  include Jekyll::ResponsiveImage::Common
5
5
 
6
6
  def render(context)
7
- site = context.registers[:site]
8
- config = make_config(site)
9
-
10
7
  attributes = YAML.load(super)
11
- image_template = attributes['template'] || config['template']
12
8
 
13
- image = ImageProcessor.process(attributes['path'], config)
14
- attributes['original'] = image[:original]
15
- attributes['resized'] = image[:resized]
9
+ cache_key = attributes.to_s
10
+ result = attributes['cache'] ? RenderCache.get(cache_key) : nil
11
+
12
+ if result.nil?
13
+ site = context.registers[:site]
14
+ config = make_config(site)
15
+
16
+ image_template = attributes['template'] || config['template']
17
+
18
+ image = ImageProcessor.process(attributes['path'], config)
19
+ attributes['original'] = image[:original]
20
+ attributes['resized'] = image[:resized]
21
+
22
+ partial = File.read(image_template)
23
+ template = Liquid::Template.parse(partial)
24
+
25
+ result = template.render!(attributes.merge(site.site_payload))
16
26
 
17
- partial = File.read(image_template)
18
- template = Liquid::Template.parse(partial)
27
+ RenderCache.set(cache_key, result)
28
+ end
19
29
 
20
- template.render!(attributes.merge(site.site_payload))
30
+ result
21
31
  end
22
32
  end
23
33
  end
@@ -0,0 +1,21 @@
1
+ module Jekyll
2
+ class ResponsiveImage
3
+ class RenderCache
4
+ attr_accessor :store
5
+
6
+ class << self
7
+ def store
8
+ @store ||= {}
9
+ end
10
+
11
+ def get(key)
12
+ store[key]
13
+ end
14
+
15
+ def set(key, val)
16
+ store[key] = val
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -15,19 +15,28 @@ module Jekyll
15
15
  end
16
16
 
17
17
  def render(context)
18
- site = context.registers[:site]
19
- config = make_config(site)
18
+ cache_key = @attributes.to_s
19
+ result = @attributes['cache'] ? RenderCache.get(cache_key) : nil
20
20
 
21
- image = ImageProcessor.process(@attributes['path'], config)
22
- @attributes['original'] = image[:original]
23
- @attributes['resized'] = image[:resized]
21
+ if result.nil?
22
+ site = context.registers[:site]
23
+ config = make_config(site)
24
24
 
25
- image_template = @attributes['template'] || config['template']
25
+ image = ImageProcessor.process(@attributes['path'], config)
26
+ @attributes['original'] = image[:original]
27
+ @attributes['resized'] = image[:resized]
26
28
 
27
- partial = File.read(image_template)
28
- template = Liquid::Template.parse(partial)
29
+ image_template = @attributes['template'] || config['template']
29
30
 
30
- template.render!(@attributes.merge(site.site_payload))
31
+ partial = File.read(image_template)
32
+ template = Liquid::Template.parse(partial)
33
+
34
+ result = template.render!(@attributes.merge(site.site_payload))
35
+
36
+ RenderCache.set(cache_key, result)
37
+ end
38
+
39
+ result
31
40
  end
32
41
  end
33
42
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  class ResponsiveImage
3
- VERSION = '0.14.0'.freeze
3
+ VERSION = '0.15.0'.freeze
4
4
  end
5
5
  end
@@ -7,6 +7,7 @@ require 'rmagick'
7
7
  require 'jekyll/responsive_image/version'
8
8
  require 'jekyll/responsive_image/defaults'
9
9
  require 'jekyll/responsive_image/utils'
10
+ require 'jekyll/responsive_image/render_cache'
10
11
  require 'jekyll/responsive_image/image_processor'
11
12
  require 'jekyll/responsive_image/resize_handler'
12
13
  require 'jekyll/responsive_image/common'
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.14.0
4
+ version: 0.15.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-01-12 00:00:00.000000000 Z
11
+ date: 2016-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -83,6 +83,7 @@ files:
83
83
  - lib/jekyll/responsive_image/common.rb
84
84
  - lib/jekyll/responsive_image/defaults.rb
85
85
  - lib/jekyll/responsive_image/image_processor.rb
86
+ - lib/jekyll/responsive_image/render_cache.rb
86
87
  - lib/jekyll/responsive_image/resize_handler.rb
87
88
  - lib/jekyll/responsive_image/tag.rb
88
89
  - lib/jekyll/responsive_image/utils.rb
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  version: '0'
108
109
  requirements: []
109
110
  rubyforge_project:
110
- rubygems_version: 2.4.5.1
111
+ rubygems_version: 2.5.1
111
112
  signing_key:
112
113
  specification_version: 4
113
114
  summary: Responsive images for Jekyll via srcset