mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 09:46:12 +00:00
Clean some code and add documentation
This commit is contained in:
parent
06685bbe13
commit
9b05a0bc8e
15 changed files with 208 additions and 140 deletions
|
@ -1,57 +1,61 @@
|
|||
#contributors.rb fetches Bitcoin-Qt contributors list and set
|
||||
#site.project.contributors array. This is later used to
|
||||
#display the list of contributors on the "Development" page.
|
||||
|
||||
require 'open-uri'
|
||||
require 'json'
|
||||
require 'yaml'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class CategoryGenerator < Generator
|
||||
def fetch_contributors
|
||||
contributors = JSON.parse(open("https://api.github.com/repos/bitcoin/bitcoin/contributors","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
|
||||
class CategoryGenerator < Generator
|
||||
def fetch_contributors
|
||||
contributors = JSON.parse(open("https://api.github.com/repos/bitcoin/bitcoin/contributors","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
|
||||
|
||||
contributors.map do |x|
|
||||
x['name'] = x['login'] unless x.has_key?('name')
|
||||
x['name'] = x['login'] if x['name'] == ""
|
||||
contributors.map do |x|
|
||||
x['name'] = x['login'] unless x.has_key?('name')
|
||||
x['name'] = x['login'] if x['name'] == ""
|
||||
|
||||
x
|
||||
end
|
||||
end
|
||||
x
|
||||
end
|
||||
end
|
||||
|
||||
def merge_contributors(contributors, aliases)
|
||||
contributors = contributors.map do |c|
|
||||
c['name'] = aliases[c['name']] if aliases.has_key?(c['name'])
|
||||
def merge_contributors(contributors, aliases)
|
||||
contributors = contributors.map do |c|
|
||||
c['name'] = aliases[c['name']] if aliases.has_key?(c['name'])
|
||||
|
||||
c
|
||||
end
|
||||
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 = 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
|
||||
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)
|
||||
class << site
|
||||
attr_accessor :primary_devs, :contributors
|
||||
def generate(site)
|
||||
class << site
|
||||
attr_accessor :primary_devs, :contributors
|
||||
|
||||
def site_payload
|
||||
result = super
|
||||
result['site']['project'] = {
|
||||
"primary_devs" => self.primary_devs,
|
||||
"contributors" => self.contributors
|
||||
}
|
||||
result
|
||||
end
|
||||
end
|
||||
def site_payload
|
||||
result = super
|
||||
result['site']['project'] = {
|
||||
"primary_devs" => self.primary_devs,
|
||||
"contributors" => self.contributors
|
||||
}
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
site.primary_devs = JSON.parse(open("https://api.github.com/repos/bitcoin/bitcoin/collaborators","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
|
||||
site.contributors = merge_contributors(fetch_contributors(), site.config['aliases']).sort_by{|c| - c['contributions']}
|
||||
end
|
||||
site.primary_devs = JSON.parse(open("https://api.github.com/repos/bitcoin/bitcoin/collaborators","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
|
||||
site.contributors = merge_contributors(fetch_contributors(), site.config['aliases']).sort_by{|c| - c['contributions']}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue