jekyll-avatar 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -13
- data/.ruby-version +1 -1
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/jekyll-avatar.gemspec +1 -0
- data/lib/jekyll-avatar.rb +20 -17
- data/lib/jekyll-avatar/version.rb +2 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcdb74afbda832688a870b5386093d35056c82d7
|
4
|
+
data.tar.gz: '0834bfb48b454e61facd76bec569437fd6aa342f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5719885ef21b0d35e86fd3056e3aaa3d2f8bf0981d79938c9751091cc78471f53276718ef4c4c0915e2995e3cfc106e235f20170236d951d9f82b54fbccf246
|
7
|
+
data.tar.gz: 5d801b1640899d10c8a8beb957776e38833be50be599be75dde5b059c50c0e7d4bbafefde2532307d98281f023bbc023de33f35eec9d8e4d9dff571b91fd30a1
|
data/.rubocop.yml
CHANGED
@@ -1,13 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
EnforcedColonStyle: table
|
4
|
-
|
5
|
-
Style/Documentation:
|
6
|
-
Enabled: false
|
7
|
-
|
8
|
-
Lint/EndAlignment:
|
9
|
-
AlignWith: variable
|
10
|
-
AutoCorrect: true
|
1
|
+
inherit_gem:
|
2
|
+
jekyll: .rubocop.yml
|
11
3
|
|
12
4
|
Style/FileName:
|
13
5
|
Enabled: false
|
@@ -15,6 +7,3 @@ Style/FileName:
|
|
15
7
|
Metrics/LineLength:
|
16
8
|
Exclude:
|
17
9
|
- spec/*/**
|
18
|
-
|
19
|
-
Style/DeprecatedHashMethods:
|
20
|
-
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.1
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/jekyll-avatar.gemspec
CHANGED
data/lib/jekyll-avatar.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "zlib"
|
2
3
|
|
3
4
|
module Jekyll
|
4
5
|
class Avatar < Liquid::Tag
|
6
|
+
include Jekyll::LiquidExtensions
|
7
|
+
|
5
8
|
SERVERS = 4
|
6
9
|
DEFAULT_SIZE = 40
|
7
10
|
API_VERSION = 3
|
@@ -14,7 +17,7 @@ module Jekyll
|
|
14
17
|
def render(context)
|
15
18
|
@context = context
|
16
19
|
@text = Liquid::Template.parse(@text).render(@context)
|
17
|
-
attrs = attributes.map { |k, v| "#{k}=\"#{v}\"" }.join(
|
20
|
+
attrs = attributes.map { |k, v| "#{k}=\"#{v}\"" }.join(" ")
|
18
21
|
"<img #{attrs} />"
|
19
22
|
end
|
20
23
|
|
@@ -22,27 +25,27 @@ module Jekyll
|
|
22
25
|
|
23
26
|
def attributes
|
24
27
|
{
|
25
|
-
:class
|
26
|
-
:src
|
27
|
-
:alt
|
28
|
-
:srcset
|
29
|
-
:width
|
30
|
-
:height
|
31
|
-
|
28
|
+
:class => classes,
|
29
|
+
:src => url,
|
30
|
+
:alt => username,
|
31
|
+
:srcset => srcset,
|
32
|
+
:width => size,
|
33
|
+
:height => size,
|
34
|
+
"data-proofer-ignore" => true
|
32
35
|
}
|
33
36
|
end
|
34
37
|
|
35
38
|
def username
|
36
|
-
matches = @text.match(
|
37
|
-
if matches
|
38
|
-
@context
|
39
|
+
matches = @text.match(%r!\buser=([\w\.]+)\b!)
|
40
|
+
if matches
|
41
|
+
lookup_variable(@context, matches[1])
|
39
42
|
else
|
40
|
-
@text.split(
|
43
|
+
@text.split(" ").first.sub("@", "")
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
44
47
|
def size
|
45
|
-
matches = @text.match(
|
48
|
+
matches = @text.match(%r!\bsize=(\d+)\b!i)
|
46
49
|
matches ? matches[1].to_i : DEFAULT_SIZE
|
47
50
|
end
|
48
51
|
|
@@ -63,14 +66,14 @@ module Jekyll
|
|
63
66
|
end
|
64
67
|
|
65
68
|
def srcset
|
66
|
-
(1..4).map { |scale| "#{url(scale)} #{scale}x" }.join(
|
69
|
+
(1..4).map { |scale| "#{url(scale)} #{scale}x" }.join(", ")
|
67
70
|
end
|
68
71
|
|
69
72
|
# See http://primercss.io/avatars/#small-avatars
|
70
73
|
def classes
|
71
|
-
size < 48 ?
|
74
|
+
size < 48 ? "avatar avatar-small" : "avatar"
|
72
75
|
end
|
73
76
|
end
|
74
77
|
end
|
75
78
|
|
76
|
-
Liquid::Template.register_tag(
|
79
|
+
Liquid::Template.register_tag("avatar", Jekyll::Avatar)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-avatar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -121,9 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.6.
|
124
|
+
rubygems_version: 2.6.8
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: A Jekyll plugin for rendering GitHub avatars
|
128
128
|
test_files: []
|
129
|
-
has_rdoc:
|