jekyll-bits 0.9.3 → 0.10

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: 8a7556b6418acd687cf2b7d5ba8bd4f45b56be5e
4
- data.tar.gz: 0d6fc7891b214f4a5adeb3328a8cea7edd99ac31
3
+ metadata.gz: 9d22107988f9c8e070cf89b4c696efba03332646
4
+ data.tar.gz: 73e9695d2d435083409c1ff625d6825e9d237c6b
5
5
  SHA512:
6
- metadata.gz: 820d55a4cab7018cf7750670f7bd96e50245e61eb9af709a6e9fecb1bba47ad2e2876f493cf423c2f30526c615e6ecb6ae5db8fe53465ed6bedac92c2b302bd1
7
- data.tar.gz: 0c226e37fbd7efb18396d251d168138879f34bdf0ba8effce0b0ff4b4a2926b0002ed61309089c6b2b3ba1df7a07e7d7a8c0875333c148b6d22772512df1b533
6
+ metadata.gz: 38d51536086b52e83707a643117d4170e42271dd1a4936a2a1470b1313b182fec13ee481eedeae484c30963bb9eeeaab3e1b8f0a6cc1ac01d8c5ffae2f3b90bb
7
+ data.tar.gz: 45679ad48423d2a70afae00e78c836e13f41d587cad9cc0831a10476f4106ad4773a4ff12d2e0bb24ddf8cb49caa24dc0edecede64d95fe24e60f7492540f6c4
data/jekyll-bits.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.rubygems_version = '2.2.2'
9
9
  s.required_ruby_version = '>= 1.9.3'
10
10
  s.name = 'jekyll-bits'
11
- s.version = '0.9.3'
11
+ s.version = '0.10'
12
12
  s.license = 'MIT'
13
13
  s.summary = 'Jekyll Bits'
14
14
  s.description = 'Useful and very simple Jekyll plugins'
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.rdoc_options = ['--charset=UTF-8']
21
21
  s.extra_rdoc_files = ['README.md']
22
22
  s.add_runtime_dependency('jekyll', '>=1.5.1')
23
+ s.add_runtime_dependency('fastimage')
23
24
  s.add_development_dependency 'bundler', '~> 1.5'
24
25
  s.add_development_dependency 'coveralls', '0.7.0'
25
26
  s.add_development_dependency 'test-unit', '3.0.8'
@@ -25,6 +25,7 @@
25
25
  require 'digest/md5'
26
26
  require 'liquid'
27
27
  require 'uri'
28
+ require 'fastimage'
28
29
 
29
30
  # Jekyll module
30
31
  module Jekyll
@@ -33,8 +34,15 @@ module Jekyll
33
34
  def jb_picture_head(page)
34
35
  uri = uri(page)
35
36
  return '' if uri.empty?
36
- "<meta name='og:image' content='#{CGI.escapeElement(uri)}'/>\
37
- <meta name='twitter:image' content='#{CGI.escapeElement(uri)}'/>"
37
+ html = "<meta name='og:image' content='#{CGI.escapeElement(uri)}'/>"
38
+ html += "<meta name='twitter:image' content='#{CGI.escapeElement(uri)}'/>"
39
+ path = uri
40
+ path = File.join(Dir.pwd, path) unless \
41
+ %w(http https).include?(URI.parse(uri).scheme)
42
+ width, height = FastImage.size(path)
43
+ html += "<meta name='og:image:width' content='#{width}'/>" if width
44
+ html += "<meta name='og:image:height' content='#{height}'/>" if height
45
+ html
38
46
  end
39
47
 
40
48
  def jb_picture_body(page)
data/test/test_picture.rb CHANGED
@@ -47,6 +47,17 @@ module Jekyll
47
47
  assert_match(/img2\.png/, html)
48
48
  end
49
49
 
50
+ def test_calculates_image_size
51
+ html = JbBox.new.jb_picture_head(
52
+ 'jb_picture' => {
53
+ 'src' => 'http://www.yegor256.com/images/2017/02/the-deer-hunter.jpg'
54
+ }
55
+ )
56
+ assert_match(/meta/, html)
57
+ assert_contains("<meta name='og:image:width' content='1280'/>", html)
58
+ assert_contains("<meta name='og:image:height' content='543'/>", html)
59
+ end
60
+
50
61
  def test_generates_html_simple_body
51
62
  html = JbBox.new.jb_picture_body('jb_picture' => '/img1.png')
52
63
  assert_match(/img/, html)
@@ -69,5 +80,11 @@ module Jekyll
69
80
  assert_match(/alt='nothing &#39;to&#39; say'/, html)
70
81
  assert_match(/width='500'/, html)
71
82
  end
83
+
84
+ private
85
+
86
+ def assert_contains(substring, string, *args)
87
+ assert(string.include?(substring), *args)
88
+ end
72
89
  end
73
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-bits
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: '0.10'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-17 00:00:00.000000000 Z
11
+ date: 2017-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.5.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: fastimage
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement