diff --git a/js/github.js b/js/github.js index e56837f..e9b9f4f 100644 --- a/js/github.js +++ b/js/github.js @@ -215,20 +215,46 @@ return this; }; - // Get a list of this user's repositories. + // Get a list of this user's repositories, 30 per page // // gh.user("fitzgen").repos(function (data) { // alert(data.repositories.length); // }); - gh.user.prototype.repos = function (callback, context) { - gh.repo.forUser(this.username, callback, context); + gh.user.prototype.repos = function (callback, context, page) { + gh.repo.forUser(this.username, callback, context, page); return this; }; - gh.user.prototype.orgs = function (callback, context) { - gh.org.forUser(this.username, callback, context); - return this; - }; + // Get a list of all repos for this user. + // + // gh.user("fitzgen").allRepos(function (repos) { + // alert(repos.length); + // }); + gh.user.prototype.allRepos = function(callback, context) { + var repos = []; + var username = this.username; + + var page = 1; + + var exitCallback = function (repos) { callback.call(context, { repositories: repos }) }; + + var pageLoop = function (data) { + repos = repos.concat(data.repositories); + var reposLength = data.repositories.length; + + if (reposLength == 0) { + exitCallback(repos); + } + else { + page += 1; + gh.repo.forUser(username, pageLoop, context, page); + } + } + + gh.repo.forUser(username, pageLoop, context, page); + + return this; + } // Make this user fork the repo that lives at // http://github.com/user/repo. You must be authenticated as this user for @@ -276,15 +302,6 @@ this.user = user; }; - gh.org = function(user, org) { - if (!(this instanceof gh.org)) { - return new gh.org(user, org); - } - - this.org = org; - this.user = user; - }; - // Get basic information on this repo. // // gh.repo("schacon", "grit").show(function (data) { @@ -412,13 +429,11 @@ }; // Get all the repos that are owned by `user`. - gh.repo.forUser = function (user, callback, context) { - jsonp("repos/show/" + user, callback, context); - return this; - }; + gh.repo.forUser = function (user, callback, context, page) { + if (!page) + page = 1; - gh.org.forUser = function (user, callback, context) { - jsonp("user/show/" + user + "/organizations", callback, context); + jsonp("repos/show/" + user + '?page=' + page, callback, context); return this; }; @@ -684,3 +699,4 @@ ); }(window)); + diff --git a/js/githubresume.js b/js/githubresume.js index d467b81..22a1a21 100644 --- a/js/githubresume.js +++ b/js/githubresume.js @@ -59,7 +59,7 @@ var run = function() { var itemCount = 0, maxItems = 5, maxLanguages = 9; var res = gh_user.show(function(data) { - gh_user.repos(function(data) { + gh_user.allRepos(function(data) { repos = data; }); @@ -106,7 +106,7 @@ var run = function() { }); }); - gh_user.repos(function(data) { + gh_user.allRepos(function(data) { var repos = data.repositories; var sorted = []; diff --git a/views/index.html b/views/index.html index ae1d04d..f92e783 100644 --- a/views/index.html +++ b/views/index.html @@ -52,7 +52,7 @@

Notes, Information and Future features


- This is the first version, please keep in mind that it only fetches your first 30 repositories for now. I am planning on adding + This is the first version. I am planning on adding things as such as your most committed forks, most committed repositories and make the "My Popular Repositories" be built from your complete list of repositories. The issue right now is say you have 37 repositories, this will only retrieve the first 30 repositories that were created. I'll put a note here when this is fixed or feel free to fork the page,