mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 01:36:13 +00:00
more work on contributor list; merge contributors by name, use aliases from _config.yml
This commit is contained in:
parent
f2613a9d93
commit
1183de9fce
4 changed files with 79 additions and 0 deletions
55
_plugins/contributors.rb
Normal file
55
_plugins/contributors.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
require 'open-uri'
|
||||
require 'json'
|
||||
require 'aquarium'
|
||||
require 'yaml'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class CategoryGenerator < Generator
|
||||
def fetch_contributors
|
||||
contributors = JSON.parse(open("http://github.com/api/v2/json/repos/show/bitcoin/bitcoin/contributors/anon").read)["contributors"]
|
||||
|
||||
contributors.map do |x|
|
||||
x['name'] = x['login'] unless x.has_key?('name')
|
||||
x['name'] = x['login'] if x['name'] == ""
|
||||
|
||||
x
|
||||
end
|
||||
end
|
||||
|
||||
def merge_contributors(contributors, aliases)
|
||||
contributors = contributors.map do |c|
|
||||
c['name'] = aliases[c['name']] if aliases.has_key?(c['name'])
|
||||
|
||||
c
|
||||
end
|
||||
|
||||
hoaoh = contributors.reduce({}) do |result, item|
|
||||
result.merge({ item['name'] => [item] }) { |key, old, new| old[0]['contributions'] += new[0]['contributions']; old }
|
||||
end
|
||||
|
||||
hoaoh.values.map { |sublist|
|
||||
sublist.reduce({}) do |merged,h|
|
||||
merged.merge(h) do |key,old,new| (key=='name' ? old : old+new) end
|
||||
end
|
||||
}.flatten
|
||||
end
|
||||
|
||||
def generate(site)
|
||||
@contributors = merge_contributors(fetch_contributors(), site.config['aliases']).sort_by{|c| - c['contributions']}
|
||||
@primary_devs = JSON.parse(open("http://github.com/api/v2/json/repos/show/bitcoin/bitcoin/collaborators").read)["collaborators"]
|
||||
|
||||
Aquarium::Aspects::Aspect.new :around, :invoking => :site_payload, :on_type => Site do |execution_point, site, *args|
|
||||
result = execution_point.proceed
|
||||
result['site']['project'] = {
|
||||
"primary_devs" => @primary_devs,
|
||||
"contributors" => @contributors
|
||||
}
|
||||
result
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue