mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 01:36:13 +00:00
Support GitHub API pagination
(GitHub now returns only limited data per API Call)
This commit is contained in:
parent
90ff0a2d97
commit
63dac6894a
1 changed files with 13 additions and 1 deletions
|
@ -10,7 +10,19 @@ 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)
|
||||
page = 1
|
||||
contributors = []
|
||||
while page < 10 do
|
||||
begin
|
||||
ar = JSON.parse(open("https://api.github.com/repos/bitcoin/bitcoin/contributors?page=#{page}&per_page=100","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
|
||||
rescue
|
||||
print 'GitHub API Call Failed!'
|
||||
break
|
||||
end
|
||||
break if (ar.length == 0)
|
||||
contributors.push(*ar)
|
||||
page += 1
|
||||
end
|
||||
|
||||
contributors.map do |x|
|
||||
x['name'] = x['login'] unless x.has_key?('name')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue