jekyll-avatar 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +10 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/Rakefile +6 -0
- data/jekyll-avatar.gemspec +27 -0
- data/lib/jekyll/avatar.rb +61 -0
- data/lib/jekyll/avatar/version.rb +6 -0
- data/script/bootstrap +5 -0
- data/script/cibuild +6 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b1ffaa6227e8d8af1956bd5fa211db46c0c9e18b
|
4
|
+
data.tar.gz: 6a27c7b962f4c7b9ab42020f74c7c2cb28bc13e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e6b4b4b1b792cd6f0652531769e075d66f7aa281e155812f125260d7afff0e3521babd17ffe67dc986d3630784bce13e75cb08aebe1a2998c08d9460f299d2cf
|
7
|
+
data.tar.gz: ce5472feed3584cc3df9041728c1d9f9ea911ed8d14cec2deadf89f8bf3319d132838ba0946b6a8d1734af63cc22a1834008de2fc1a36a188b35360cd3c011fc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Ben Balter
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Jekyll Avatar
|
2
|
+
|
3
|
+
*A Jekyll plugin for rendering GitHub avatars*
|
4
|
+
|
5
|
+
Jekyll Avatar makes it easy to add GitHub avatars to your Jekyll site by specifying a username. If performance is a concern, Jekyll Avatar is deeply integrated with the GitHub avatar API, ensuring avatars are cached and load in parallel.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add the following to your site's `Gemfile`:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'jekyll-avatar'
|
13
|
+
```
|
14
|
+
|
15
|
+
And add the following to your site's `_config.yml` file:
|
16
|
+
|
17
|
+
```yaml
|
18
|
+
gems:
|
19
|
+
- jekyll-avatar
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Simply add the following, anywhere you'd like a user's avatar to appear:
|
25
|
+
|
26
|
+
```
|
27
|
+
{% avatar [USERNAME] %}
|
28
|
+
```
|
29
|
+
|
30
|
+
With `[USERNAME]` being the user's GitHub username:
|
31
|
+
|
32
|
+
```
|
33
|
+
{% avatar hubot %}
|
34
|
+
```
|
35
|
+
|
36
|
+
That will output:
|
37
|
+
|
38
|
+
```html
|
39
|
+
<img class="avatar avatar-small" src="https://avatars3.githubusercontent.com/hubot?v=3&s=40" alt="hubot" width="40" height="40" />
|
40
|
+
```
|
41
|
+
|
42
|
+
### Customizing
|
43
|
+
|
44
|
+
You can customize the size of the resulting avatar by passing the size arugment:
|
45
|
+
|
46
|
+
```
|
47
|
+
{% avatar hubot size=25 %}
|
48
|
+
```
|
49
|
+
|
50
|
+
That will output:
|
51
|
+
|
52
|
+
```html
|
53
|
+
<img class="avatar avatar-small" src="https://avatars3.githubusercontent.com/hubot?v=3&s=25" alt="hubot" width="25" height="25" />
|
54
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll/avatar/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'jekyll-avatar'
|
8
|
+
spec.version = Jekyll::Avatar::VERSION
|
9
|
+
spec.authors = ['Ben Balter']
|
10
|
+
spec.email = ['ben.balter@github.com']
|
11
|
+
|
12
|
+
spec.summary = 'A Jekyll plugin for rendering GitHub avatars'
|
13
|
+
spec.homepage = 'https://github.com/benbalter/jekyll-avatar'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |file|
|
17
|
+
file.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'jekyll', '>= 2.4'
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
spec.add_development_dependency 'rubocop'
|
27
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'jekyll/avatar/version'
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class Avatar < Liquid::Tag
|
5
|
+
SERVERS = 4
|
6
|
+
DEFAULT_SIZE = 40
|
7
|
+
VERSION = 3
|
8
|
+
|
9
|
+
def initialize(tag_name, text, tokens)
|
10
|
+
super
|
11
|
+
@text = text
|
12
|
+
end
|
13
|
+
|
14
|
+
def render(_context)
|
15
|
+
tag = '<img '
|
16
|
+
|
17
|
+
# See http://primercss.io/avatars/#small-avatars
|
18
|
+
if size < 48
|
19
|
+
tag << 'class="avatar avatar-small" '
|
20
|
+
else
|
21
|
+
tag << 'class="avatar" '
|
22
|
+
end
|
23
|
+
|
24
|
+
tag << "src=\"#{url}\" alt=\"#{username}\" "
|
25
|
+
tag << "width=\"#{size}\" height=\"#{size}\" "
|
26
|
+
tag << '/>'
|
27
|
+
tag
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def username
|
33
|
+
@username ||= @text.split(' ').first.sub('@', '')
|
34
|
+
end
|
35
|
+
|
36
|
+
def size
|
37
|
+
@size ||= begin
|
38
|
+
matches = @text.match(/\bsize=(\d+)\b/i)
|
39
|
+
matches ? matches[1].to_i : DEFAULT_SIZE
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def path
|
44
|
+
@path ||= "#{username}?v=#{VERSION}&s=#{size}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def server_number
|
48
|
+
@server_number ||= Zlib.crc32(path) % SERVERS
|
49
|
+
end
|
50
|
+
|
51
|
+
def host
|
52
|
+
@host ||= "avatars#{server_number}.githubusercontent.com"
|
53
|
+
end
|
54
|
+
|
55
|
+
def url
|
56
|
+
@url ||= "https://#{host}/#{path}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
Liquid::Template.register_tag('avatar', Jekyll::Avatar)
|
data/script/cibuild
ADDED
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-avatar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Balter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- ben.balter@github.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".rubocop.yml"
|
93
|
+
- ".ruby-version"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- jekyll-avatar.gemspec
|
100
|
+
- lib/jekyll/avatar.rb
|
101
|
+
- lib/jekyll/avatar/version.rb
|
102
|
+
- script/bootstrap
|
103
|
+
- script/cibuild
|
104
|
+
homepage: https://github.com/benbalter/jekyll-avatar
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.5.1
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: A Jekyll plugin for rendering GitHub avatars
|
128
|
+
test_files: []
|