Using the GitHub API to pre-sort repos based on pushed date. #1031.

This commit is contained in:
Parker Moore 2013-02-20 17:44:50 +01:00
parent f6fdb92e92
commit f64fa33d69

View File

@ -236,7 +236,7 @@ var octopress = (function(){
var count = parseInt(target.attr('data-count'))
var skip_forks = target.attr('data-skip') == 'true';
$.ajax({
url: "https://api.github.com/users/"+user+"/repos?callback=?"
url: "https://api.github.com/users/"+user+"/repos?sort=pushed&callback=?"
, dataType: 'jsonp'
, error: function (err) { target.find('.loading').addClass('error').text("Error loading feed"); }
, success: function(data) {
@ -246,13 +246,6 @@ var octopress = (function(){
if (skip_forks && data.data[i].fork) { continue; }
repos.push(data.data[i]);
}
repos.sort(function(a, b) {
var aDate = new Date(a.pushed_at).valueOf(),
bDate = new Date(b.pushed_at).valueOf();
if (aDate === bDate) { return 0; }
return aDate > bDate ? -1 : 1;
});
if (count) { repos.splice(count); }
render(target, repos);