jekyll-bits 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.0pdd.yml +5 -3
- data/README.md +13 -0
- data/jekyll-bits.gemspec +1 -1
- data/lib/jekyll-bits/picture.rb +24 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f53a53276bcd63614b03be6fdc26d8c3391849c0
|
4
|
+
data.tar.gz: 5a1d1c7944e8c534fd5cd07f8fb27def67ca0088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b61d7c6a2e35535ecef635dea76a14488f687a13f7743fd02e0aef8512def0dcd40ed222ddeaf92b479fe6022dfd762cf73d748b48ef636fd43749ba1c172f6
|
7
|
+
data.tar.gz: 6b9aa1b7cebe2c799dbe7ca63a8e0e2dbbec8460ca63d2d7e2b887d6ba2f2049a03d7c3edffa8e041873660c51a42a28997180c8b85827fd2f541b8844dc4a60
|
data/.0pdd.yml
CHANGED
data/README.md
CHANGED
@@ -76,6 +76,19 @@ Something like that will be rendered:
|
|
76
76
|
</figure>
|
77
77
|
```
|
78
78
|
|
79
|
+
You can also define your picture URL in `image`, for example:
|
80
|
+
|
81
|
+
```yaml
|
82
|
+
---
|
83
|
+
image: /images/2017/01/hello-world.jpg
|
84
|
+
jb_picture:
|
85
|
+
alt: Hello, world!
|
86
|
+
caption: This is my hello world picture for you
|
87
|
+
width: 1280
|
88
|
+
height: 800
|
89
|
+
---
|
90
|
+
```
|
91
|
+
|
79
92
|
# License
|
80
93
|
|
81
94
|
(The MIT License)
|
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.
|
11
|
+
s.version = '0.7'
|
12
12
|
s.license = 'MIT'
|
13
13
|
s.summary = 'Jekyll Bits'
|
14
14
|
s.description = 'Useful and very simple Jekyll plugins'
|
data/lib/jekyll-bits/picture.rb
CHANGED
@@ -30,37 +30,23 @@ module Jekyll
|
|
30
30
|
# All our custom filters
|
31
31
|
module JbFilters
|
32
32
|
def jb_picture_head(page)
|
33
|
-
|
34
|
-
return
|
35
|
-
|
36
|
-
raise "src is absent for jb_picture in #{page.url}" unless yaml['src']
|
37
|
-
src = yaml['src']
|
38
|
-
else
|
39
|
-
src = yaml
|
40
|
-
end
|
41
|
-
"<meta property='og:image' content='#{src}'/>"
|
33
|
+
uri = uri(page)
|
34
|
+
return '' if uri.empty?
|
35
|
+
"<meta property='og:image' content='#{CGI.escapeElement(uri)}'/>"
|
42
36
|
end
|
43
37
|
|
44
38
|
def jb_picture_body(page)
|
39
|
+
uri = uri(page)
|
40
|
+
return '' if uri.empty?
|
45
41
|
yaml = page['jb_picture']
|
46
|
-
return unless yaml
|
47
42
|
html = "<img itemprop='image' alt='"
|
48
|
-
if yaml.is_a?(Hash) && yaml['alt']
|
43
|
+
if yaml && yaml.is_a?(Hash) && yaml['alt']
|
49
44
|
html += CGI.escapeHTML(yaml['alt'])
|
50
45
|
else
|
51
46
|
html += 'front image'
|
52
47
|
end
|
53
|
-
html += "' src='"
|
54
|
-
|
55
|
-
raise "src is absent for jb_picture in #{page.url}" unless yaml['src']
|
56
|
-
html += CGI.escapeElement(yaml['src'])
|
57
|
-
md5 = Digest::MD5.new.hexdigest(yaml['src'])
|
58
|
-
else
|
59
|
-
html += yaml
|
60
|
-
md5 = Digest::MD5.new.hexdigest(yaml)
|
61
|
-
end
|
62
|
-
md5 = md5[0, 8]
|
63
|
-
html += "'"
|
48
|
+
html += "' src='#{CGI.escapeElement(uri)}'"
|
49
|
+
md5 = Digest::MD5.new.hexdigest(uri)[0, 8]
|
64
50
|
html += " longdesc='##{md5}'" \
|
65
51
|
if yaml.is_a?(Hash) && yaml['caption']
|
66
52
|
html += " width='#{yaml['width']}'" \
|
@@ -77,6 +63,22 @@ module Jekyll
|
|
77
63
|
end
|
78
64
|
html + '</figure>'
|
79
65
|
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def uri(page)
|
70
|
+
uri = ''
|
71
|
+
uri = page['image'] if page['image']
|
72
|
+
yaml = page['jb_picture']
|
73
|
+
if yaml
|
74
|
+
if yaml.is_a?(Hash)
|
75
|
+
uri = yaml['src'] if yaml['src']
|
76
|
+
else
|
77
|
+
uri = yaml
|
78
|
+
end
|
79
|
+
end
|
80
|
+
uri
|
81
|
+
end
|
80
82
|
end
|
81
83
|
|
82
84
|
# Box for testing and calling static methods.
|
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.
|
4
|
+
version: '0.7'
|
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-01-
|
11
|
+
date: 2017-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|