bridgetown-avatar 0.1.0
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 +7 -0
- data/.gitignore +38 -0
- data/.rspec +2 -0
- data/.rubocop.yml +22 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +57 -0
- data/Rakefile +8 -0
- data/bridgetown-avatar.gemspec +28 -0
- data/components/bridgetown_avatar/layout_help.liquid +1 -0
- data/content/bridgetown_avatar/example_page.md +8 -0
- data/content/bridgetown_avatar/train-on-rails.jpeg +0 -0
- data/layouts/bridgetown_avatar/layout.html +9 -0
- data/lib/bridgetown-avatar.rb +11 -0
- data/lib/bridgetown-avatar/builder.rb +67 -0
- data/lib/bridgetown-avatar/version.rb +5 -0
- data/package.json +16 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0b6b01033705ed1fc334ae96ff1532a12ba38e283696eeebc570a0e691d1ec20
|
4
|
+
data.tar.gz: 683cbffcfb5a32b87be632c068d0c7760a0fdf6daadc80154e120b6905e8e3b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fcf015c1a23eb1a6556c4aaa7df803a8bee347b7550e9c8faf2a8f14bae135561d6c04c9bb13f356274b292ad4c155481651c265f151ff1a92380b4438bd7ea3
|
7
|
+
data.tar.gz: e4180b1851ebc08b515e187d77ab8147d40a09888e7aba8c278b72e04862a3a99125de7f15eb6eb04ee401cf53ba39eab2a3dad745bda3b9fad0232b2766bd08
|
data/.gitignore
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
/vendor
|
2
|
+
/.bundle/
|
3
|
+
/.yardoc
|
4
|
+
/Gemfile.lock
|
5
|
+
/_yardoc/
|
6
|
+
/coverage/
|
7
|
+
/doc/
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/tmp/
|
11
|
+
*.bundle
|
12
|
+
*.so
|
13
|
+
*.o
|
14
|
+
*.a
|
15
|
+
mkmf.log
|
16
|
+
*.gem
|
17
|
+
Gemfile.lock
|
18
|
+
.bundle
|
19
|
+
.ruby-version
|
20
|
+
|
21
|
+
# Node
|
22
|
+
node_modules
|
23
|
+
.npm
|
24
|
+
.node_repl_history
|
25
|
+
|
26
|
+
# Yarn
|
27
|
+
yarn-error.log
|
28
|
+
yarn-debug.log*
|
29
|
+
.pnp/
|
30
|
+
.pnp.js
|
31
|
+
|
32
|
+
# Yarn Integrity file
|
33
|
+
.yarn-integrity
|
34
|
+
|
35
|
+
spec/dest
|
36
|
+
.bridgetown-metadata
|
37
|
+
.bridgetown-cache
|
38
|
+
.bridgetown-webpack
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require: rubocop-bridgetown
|
2
|
+
|
3
|
+
inherit_gem:
|
4
|
+
rubocop-bridgetown: .rubocop.yml
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
TargetRubyVersion: 2.5
|
8
|
+
Include:
|
9
|
+
- lib/**/*.rb
|
10
|
+
|
11
|
+
Exclude:
|
12
|
+
- .gitignore
|
13
|
+
- .rspec
|
14
|
+
- .rubocop.yml
|
15
|
+
|
16
|
+
- Gemfile.lock
|
17
|
+
- CHANGELOG.md
|
18
|
+
- LICENSE.txt
|
19
|
+
- README.md
|
20
|
+
|
21
|
+
- script/**/*
|
22
|
+
- vendor/**/*
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020-present
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Bridgetown-Avatar
|
2
|
+
|
3
|
+
very simple port of [Jekyll Avatar](https://github.com/benbalter/jekyll-avatar)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Run this command to add this plugin to your site's Gemfile:
|
8
|
+
|
9
|
+
```shell
|
10
|
+
$ bundle add bridgetown-avatar -g bridgetown_plugins
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```liquid
|
16
|
+
{% avatar github %}
|
17
|
+
```
|
18
|
+
|
19
|
+
or assign the user in a variable:
|
20
|
+
|
21
|
+
```liquid
|
22
|
+
{% assign user=github %}
|
23
|
+
{% avatar %}
|
24
|
+
```
|
25
|
+
|
26
|
+
Specify a size:
|
27
|
+
|
28
|
+
```liquid
|
29
|
+
{% avatar github size=128 %}
|
30
|
+
```
|
31
|
+
|
32
|
+
## Testing
|
33
|
+
|
34
|
+
* Run `bundle exec rspec` to run the test suite
|
35
|
+
* Or run `script/cibuild` to validate with Rubocop and test with rspec together.
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it (https://github.com/username/my-awesome-plugin/fork)
|
40
|
+
2. Clone the fork using `git clone` to your local development machine.
|
41
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
6. Create a new Pull Request
|
45
|
+
|
46
|
+
----
|
47
|
+
|
48
|
+
## Releasing (you can delete this section in your own plugin repo)
|
49
|
+
|
50
|
+
To release a new version of the plugin, simply bump up the version number in both `version.rb` and
|
51
|
+
`package.json`, and then run `script/release`. This will require you to have a registered account
|
52
|
+
with both the [RubyGems.org](https://rubygems.org) and [NPM](https://www.npmjs.com) registries.
|
53
|
+
You can optionally remove the `package.json` and `frontend` folder if you don't need to package frontend
|
54
|
+
assets for Webpack.
|
55
|
+
|
56
|
+
If you run into any problems or need further guidance, please check out our [Bridgetown community resources](https://www.bridgetownrb.com/docs/community)
|
57
|
+
where friendly folks are standing by to help you build and release your plugin or theme.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/bridgetown-avatar/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "bridgetown-avatar"
|
7
|
+
spec.version = BridgetownAvatar::VERSION
|
8
|
+
spec.author = "Julian Rubisch"
|
9
|
+
spec.email = "julian.rubisch@hey.com"
|
10
|
+
spec.summary = "Liquid tag to insert a Github avatar"
|
11
|
+
spec.homepage = "https://github.com/username/bridgetown-avatar"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features|frontend)/!) }
|
15
|
+
spec.test_files = spec.files.grep(%r!^spec/!)
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
spec.metadata = { "yarn-add" => "bridgetown-avatar@#{BridgetownAvatar::VERSION}" }
|
18
|
+
|
19
|
+
spec.required_ruby_version = ">= 2.5.0"
|
20
|
+
|
21
|
+
spec.add_dependency "bridgetown", ">= 0.15", "< 2.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "nokogiri", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
|
28
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>Just use <code>layout: bridgetown_avatar/layout</code> in your page's front matter.</p>
|
Binary file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bridgetown"
|
4
|
+
require "bridgetown-avatar/builder"
|
5
|
+
|
6
|
+
Bridgetown::PluginManager.new_source_manifest(
|
7
|
+
origin: BridgetownAvatar,
|
8
|
+
components: File.expand_path("../components", __dir__),
|
9
|
+
content: File.expand_path("../content", __dir__),
|
10
|
+
layouts: File.expand_path("../layouts", __dir__)
|
11
|
+
)
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "zlib"
|
4
|
+
|
5
|
+
module BridgetownAvatar
|
6
|
+
class Builder < Bridgetown::Builder
|
7
|
+
DEFAULT_SIZE = "40"
|
8
|
+
API_VERSION = "3"
|
9
|
+
SERVERS = 4
|
10
|
+
|
11
|
+
attr_reader :size
|
12
|
+
|
13
|
+
def build
|
14
|
+
liquid_tag "avatar" do |attributes, tag|
|
15
|
+
@attributes = attributes # .split(",").map(&:strip)
|
16
|
+
@size = compute_size
|
17
|
+
@context = tag.context
|
18
|
+
|
19
|
+
"<img src=\"#{url}\" class=\"#{classes}\"/>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def compute_size
|
26
|
+
matches = @attributes.match(%r!\bsize=(\d+)\b!i)
|
27
|
+
matches ? matches[1] : DEFAULT_SIZE
|
28
|
+
end
|
29
|
+
|
30
|
+
def username
|
31
|
+
return @context["user"] if @context["user"]
|
32
|
+
|
33
|
+
result = @attributes.include?(" ") ? @attributes.split(" ")[0] : @attributes
|
34
|
+
result.start_with?("@") ? result.sub("@", "") : result
|
35
|
+
end
|
36
|
+
|
37
|
+
def path(scale = 1)
|
38
|
+
"#{username}?v=#{API_VERSION}&s=#{scale == 1 ? size : (size.to_i * scale)}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def url(scale = 1)
|
42
|
+
"#{host}/#{path(scale)}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def server_number
|
46
|
+
Zlib.crc32(path) % SERVERS
|
47
|
+
end
|
48
|
+
|
49
|
+
def host
|
50
|
+
"https://avatars#{server_number}.githubusercontent.com"
|
51
|
+
end
|
52
|
+
|
53
|
+
SCALES = %w(1 2 3 4).freeze
|
54
|
+
private_constant :SCALES
|
55
|
+
|
56
|
+
def srcset
|
57
|
+
SCALES.map { |scale| "#{url(scale.to_i)} #{scale}x" }.join(", ")
|
58
|
+
end
|
59
|
+
|
60
|
+
# See http://primercss.io/avatars/#small-avatars
|
61
|
+
def classes
|
62
|
+
size.to_i < 48 ? "avatar avatar-small" : "avatar"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
BridgetownAvatar::Builder.register
|
data/package.json
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"name": "bridgetown-avatar",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"main": "frontend/javascript/index.js",
|
5
|
+
"repository": {
|
6
|
+
"type": "git",
|
7
|
+
"url": "https://github.com/username/bridgetown-avatar.git"
|
8
|
+
},
|
9
|
+
"author": "Bridgetown Maintainers <maintainers@bridgetownrb.com>",
|
10
|
+
"homepage": "https://www.bridgetownrb.com",
|
11
|
+
"license": "MIT",
|
12
|
+
"private": false,
|
13
|
+
"files": [
|
14
|
+
"frontend"
|
15
|
+
]
|
16
|
+
}
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bridgetown-avatar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Julian Rubisch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bridgetown
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.15'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.15'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: nokogiri
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.6'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.6'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '12.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '12.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '3.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '3.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rubocop-bridgetown
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0.2'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0.2'
|
103
|
+
description:
|
104
|
+
email: julian.rubisch@hey.com
|
105
|
+
executables: []
|
106
|
+
extensions: []
|
107
|
+
extra_rdoc_files: []
|
108
|
+
files:
|
109
|
+
- ".gitignore"
|
110
|
+
- ".rspec"
|
111
|
+
- ".rubocop.yml"
|
112
|
+
- CHANGELOG.md
|
113
|
+
- Gemfile
|
114
|
+
- LICENSE.txt
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- bridgetown-avatar.gemspec
|
118
|
+
- components/bridgetown_avatar/layout_help.liquid
|
119
|
+
- content/bridgetown_avatar/example_page.md
|
120
|
+
- content/bridgetown_avatar/train-on-rails.jpeg
|
121
|
+
- layouts/bridgetown_avatar/layout.html
|
122
|
+
- lib/bridgetown-avatar.rb
|
123
|
+
- lib/bridgetown-avatar/builder.rb
|
124
|
+
- lib/bridgetown-avatar/version.rb
|
125
|
+
- package.json
|
126
|
+
homepage: https://github.com/username/bridgetown-avatar
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata:
|
130
|
+
yarn-add: bridgetown-avatar@0.1.0
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 2.5.0
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubygems_version: 3.2.3
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: Liquid tag to insert a Github avatar
|
150
|
+
test_files: []
|