Skip to content

Commit 03e19dc

Browse files
committedAug 9, 2022
close #37
1 parent 50a0676 commit 03e19dc

7 files changed

+165
-59
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
_site
33
.DS_Store
44
.jekyll-cache
5+
.env

‎Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ gem 'html-proofer'
66
gem 'rake'
77

88
gem "webrick", "~> 1.7"
9+
10+
gem "octokit", "~> 5.2"
11+
12+
gem "dotenv", "~> 2.8"

‎Gemfile.lock

+14
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ GEM
55
public_suffix (>= 2.0.2, < 5.0)
66
colorator (1.1.0)
77
concurrent-ruby (1.1.10)
8+
dotenv (2.8.1)
89
em-websocket (0.5.3)
910
eventmachine (>= 0.12.9)
1011
http_parser.rb (~> 0)
1112
ethon (0.15.0)
1213
ffi (>= 1.15.0)
1314
eventmachine (1.2.7)
15+
faraday (2.5.1)
16+
faraday-net_http (>= 2.0, < 3.1)
17+
ruby2_keywords (>= 0.0.4)
18+
faraday-net_http (3.0.0)
1419
ffi (1.15.5)
1520
forwardable-extended (2.6.0)
1621
html-proofer (4.3.2)
@@ -63,6 +68,9 @@ GEM
6368
nokogiri (1.13.8)
6469
mini_portile2 (~> 2.8.0)
6570
racc (~> 1.4)
71+
octokit (5.2.0)
72+
faraday (>= 1, < 3)
73+
sawyer (~> 0.9)
6674
parallel (1.22.1)
6775
pathutil (0.16.2)
6876
forwardable-extended (~> 2.6)
@@ -75,9 +83,13 @@ GEM
7583
ffi (~> 1.0)
7684
rexml (3.2.5)
7785
rouge (3.30.0)
86+
ruby2_keywords (0.0.5)
7887
safe_yaml (1.0.5)
7988
sassc (2.4.0)
8089
ffi (~> 1.9)
90+
sawyer (0.9.2)
91+
addressable (>= 2.3.5)
92+
faraday (>= 0.17.3, < 3)
8193
terminal-table (2.0.0)
8294
unicode-display_width (~> 1.1, >= 1.1.1)
8395
typhoeus (1.4.0)
@@ -91,9 +103,11 @@ PLATFORMS
91103
ruby
92104

93105
DEPENDENCIES
106+
dotenv (~> 2.8)
94107
html-proofer
95108
jekyll
96109
just-the-docs
110+
octokit (~> 5.2)
97111
rake
98112
webrick (~> 1.7)
99113

‎Rakefile

+31
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
require 'dotenv'
12
require 'html-proofer'
3+
require 'json'
4+
require 'octokit'
25
require 'yaml'
36

7+
Dotenv.load
8+
49
@config = YAML.load_file '_config.yml'
510
@baseurl = ENV['BASEURL'] || @config.dig('baseurl')
611

712
task :test do
813
Rake::Task["reset"].invoke
914
sh "bundle exec jekyll build -b '#{@baseurl}' -d '_site#{@baseurl}'"
1015
opts = {
16+
disable_external: true,
1117
ignore_urls: [/elasticlunr/]
1218
}
1319
HTMLProofer.check_directory('./_site', opts).run
@@ -18,5 +24,30 @@ task :reset do
1824
end
1925

2026
task :build do
27+
Rake::Task["octokit"].invoke
2128
sh "bundle exec jekyll build -b '#{@baseurl}'"
2229
end
30+
31+
task :octokit do
32+
@file = './src/_data/contributors.json'
33+
@client = ENV['TOKEN'].empty? ?
34+
Octokit::Client.new :
35+
Octokit::Client.new(access_token: ENV['TOKEN'])
36+
@users = {}
37+
@repos = @client.org_repos('minicomp').map(&:full_name)
38+
@repos.each do |repo|
39+
@client.contribs(repo).each do |user|
40+
next if user.type == 'Bot' or user.login == 'gitter-badger'
41+
if @users.key? user.login
42+
@users[user.login][:contributions] += user.contributions
43+
else
44+
@users[user.login] = {
45+
contributions: user.contributions,
46+
avatar_url: user.avatar_url
47+
}
48+
end
49+
end
50+
end
51+
@data = @users.sort_by { |_k, v| -v[:contributions] }.to_h
52+
File.open(@file, 'w') { |f| f.write JSON.pretty_generate(@data) }
53+
end

‎src/_data/contributors.json

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"elotroalex": {
3+
"contributions": 553,
4+
"avatar_url": "https://avatars.githubusercontent.com/u/242606?v=4"
5+
},
6+
"mnyrop": {
7+
"contributions": 514,
8+
"avatar_url": "https://avatars.githubusercontent.com/u/25022284?v=4"
9+
},
10+
"karlstolley": {
11+
"contributions": 107,
12+
"avatar_url": "https://avatars.githubusercontent.com/u/170719?v=4"
13+
},
14+
"amzoss": {
15+
"contributions": 60,
16+
"avatar_url": "https://avatars.githubusercontent.com/u/4193810?v=4"
17+
},
18+
"workergnome": {
19+
"contributions": 40,
20+
"avatar_url": "https://avatars.githubusercontent.com/u/34536?v=4"
21+
},
22+
"JohannGillium": {
23+
"contributions": 7,
24+
"avatar_url": "https://avatars.githubusercontent.com/u/17035165?v=4"
25+
},
26+
"KitaitiMakoto": {
27+
"contributions": 6,
28+
"avatar_url": "https://avatars.githubusercontent.com/u/386512?v=4"
29+
},
30+
"zoews": {
31+
"contributions": 3,
32+
"avatar_url": "https://avatars.githubusercontent.com/u/12399460?v=4"
33+
},
34+
"bmschmidt": {
35+
"contributions": 2,
36+
"avatar_url": "https://avatars.githubusercontent.com/u/1110758?v=4"
37+
},
38+
"tcatapano": {
39+
"contributions": 2,
40+
"avatar_url": "https://avatars.githubusercontent.com/u/966898?v=4"
41+
},
42+
"pbinkley": {
43+
"contributions": 2,
44+
"avatar_url": "https://avatars.githubusercontent.com/u/272816?v=4"
45+
},
46+
"sagarjauhari": {
47+
"contributions": 1,
48+
"avatar_url": "https://avatars.githubusercontent.com/u/1958807?v=4"
49+
},
50+
"ngeraci": {
51+
"contributions": 1,
52+
"avatar_url": "https://avatars.githubusercontent.com/u/23507721?v=4"
53+
},
54+
"chrisfinazzo": {
55+
"contributions": 1,
56+
"avatar_url": "https://avatars.githubusercontent.com/u/1534882?v=4"
57+
},
58+
"camillevilla": {
59+
"contributions": 1,
60+
"avatar_url": "https://avatars.githubusercontent.com/u/5402927?v=4"
61+
},
62+
"frederik-elwert": {
63+
"contributions": 1,
64+
"avatar_url": "https://avatars.githubusercontent.com/u/3049661?v=4"
65+
},
66+
"bulbil": {
67+
"contributions": 1,
68+
"avatar_url": "https://avatars.githubusercontent.com/u/2319626?v=4"
69+
},
70+
"MartinPaulEve": {
71+
"contributions": 1,
72+
"avatar_url": "https://avatars.githubusercontent.com/u/1042615?v=4"
73+
},
74+
"dzoladz": {
75+
"contributions": 1,
76+
"avatar_url": "https://avatars.githubusercontent.com/u/10561752?v=4"
77+
}
78+
}

‎src/_data/contributors.yml

-42
This file was deleted.

‎src/contributors.md

+37-17
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,44 @@ nav_order: 2
66

77
# Contributors
88

9-
The following list is a start towards the [all-contributors specification](https://github.com/kentcdodds/all-contributors) using [emoji key](https://github.com/kentcdodds/all-contributors#emoji-key). __Want to be added to this list?__ Make a GitHub [issue](https://github.com/minicomp/wiki/issues)!
9+
The following list is pulled from the GitHub API and collects contributions from across the [Minicomp](https://github.com/minicomp) repositories. It takes a village to care for an open source project, and the whole village deserves credit!
1010

1111

12-
<div class='contributors'>
13-
{% for contributor in site.data.contributors %}
14-
{% assign user = contributor.github_username %}
15-
<div class='contributor'>
16-
<a href="https://github.com/{{ user }}">
17-
<img alt="github avatar for @{{ user }}" src="https://github.com/{{ user }}.png"/>
18-
<p>
19-
{{ user }}<br>
20-
{{ contributor.icons }}
21-
</p>
22-
</a>
23-
</div>
12+
<style>
13+
.contributors {
14+
display: flex;
15+
flex-wrap: wrap;
16+
}
17+
.contributor {
18+
flex: auto;
19+
max-width: 12.5%;
20+
margin-right: 2rem;
21+
margin-bottom: 2rem;
22+
}
23+
.contributor p.info {
24+
font-size: .7em;
25+
line-height: 1em;
26+
padding: 0;
27+
margin: 0;
28+
}
29+
.contributor img {
30+
margin: 0 auto;
31+
}
32+
</style>
33+
34+
<div class="contributors">
35+
{% for c in site.data.contributors %}
36+
{% assign user = c[0] %}
37+
{% assign img = c[1].avatar_url %}
38+
{% assign count = c[1].contributions %}
39+
<div class="contributor">
40+
<a href="https://github.com/{{ user }}">
41+
<img src="{{ img }}?v=3?s=100" width="100px;" alt="github avatar for @{{ user }}"/><br>
42+
<p class="info">
43+
@{{ user }}<br>
44+
commits: {{ count }}
45+
</p>
46+
</a>
47+
</div>
2448
{% endfor %}
2549
</div>
26-
27-
### Contribute
28-
29-
Check back for forthcoming contributing guides.

0 commit comments

Comments
 (0)
Please sign in to comment.