From 53ca59d6d0aa79b67ef89dbef16d2550df97e11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zhao=20L=C3=BC?= Date: Thu, 19 Jul 2012 22:09:48 -0700 Subject: Updated Github API to V3. Github API V2 has been removed. The response data format also changed. --- .themes/classic/source/javascripts/github.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to '.themes/classic/source/javascripts/github.js') diff --git a/.themes/classic/source/javascripts/github.js b/.themes/classic/source/javascripts/github.js index 678775a9..8b79dad1 100644 --- a/.themes/classic/source/javascripts/github.js +++ b/.themes/classic/source/javascripts/github.js @@ -10,15 +10,15 @@ var github = (function(){ return { showRepos: function(options){ $.ajax({ - url: "http://github.com/api/v2/json/repos/show/"+options.user+"?callback=?" + url: "https://api.github.com/users/"+options.user+"/repos?callback=?" , type: 'jsonp' , error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); } , success: function(data) { var repos = []; - if (!data || !data.repositories) { return; } - for (var i = 0; i < data.repositories.length; i++) { - if (options.skip_forks && data.repositories[i].fork) { continue; } - repos.push(data.repositories[i]); + if (!data || !data.data) { return; } + for (var i = 0; i < data.data.length; i++) { + if (options.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(), -- cgit v1.2.1 From 6c26f907cc0cf4704aaf5377738721177ec048f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zhao=20L=C3=BC?= Date: Thu, 19 Jul 2012 22:09:48 -0700 Subject: Updated Github API to V3. Github API V2 has been removed. The response data format also changed. --- .themes/classic/source/javascripts/github.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.themes/classic/source/javascripts/github.js') diff --git a/.themes/classic/source/javascripts/github.js b/.themes/classic/source/javascripts/github.js index 8b79dad1..9e98b8c2 100644 --- a/.themes/classic/source/javascripts/github.js +++ b/.themes/classic/source/javascripts/github.js @@ -3,7 +3,7 @@ var github = (function(){ var i = 0, fragment = '', t = $(target)[0]; for(i = 0; i < repos.length; i++) { - fragment += '
  • '+repos[i].name+'

    '+repos[i].description+'

  • '; + fragment += '
  • '+repos[i].name+'

    '+(repos[i].description||'')+'

  • '; } t.innerHTML = fragment; } -- cgit v1.2.1 From bcdc904843d09ab686a1e380019bfdf2f145a665 Mon Sep 17 00:00:00 2001 From: Thomas Rix Date: Wed, 2 Jan 2013 20:55:09 -0800 Subject: Escape github repo descriptions, as they may contain HTML. --- .themes/classic/source/javascripts/github.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to '.themes/classic/source/javascripts/github.js') diff --git a/.themes/classic/source/javascripts/github.js b/.themes/classic/source/javascripts/github.js index 9e98b8c2..27a5a235 100644 --- a/.themes/classic/source/javascripts/github.js +++ b/.themes/classic/source/javascripts/github.js @@ -1,9 +1,12 @@ var github = (function(){ + function escapeHtml(str) { + return $('
    ').text(str).html(); + } function render(target, repos){ var i = 0, fragment = '', t = $(target)[0]; for(i = 0; i < repos.length; i++) { - fragment += '
  • '+repos[i].name+'

    '+(repos[i].description||'')+'

  • '; + fragment += '
  • '+repos[i].name+'

    '+escapeHtml(repos[i].description||'')+'

  • '; } t.innerHTML = fragment; } -- cgit v1.2.1 From cc93e6fc98777418544eccd81f106b42dd915f5b Mon Sep 17 00:00:00 2001 From: "Michael G. Schwern" Date: Mon, 18 Feb 2013 14:17:32 +1100 Subject: Use the Github API repo sorting. The Github API can sort by pushed time, no need to do it manually. http://developer.github.com/v3/repos/#list-user-repositories This is both more efficient, Github does the sorting, but it also fixes a bug. Because the list of results are paginated, if you have more than a page's worth of repositories it will only sort that page. This results in a false view of what has been recently pushed. For a good example, try my github account "schwern" with and without this patch. --- .themes/classic/source/javascripts/github.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to '.themes/classic/source/javascripts/github.js') diff --git a/.themes/classic/source/javascripts/github.js b/.themes/classic/source/javascripts/github.js index 27a5a235..92d2fda2 100644 --- a/.themes/classic/source/javascripts/github.js +++ b/.themes/classic/source/javascripts/github.js @@ -13,7 +13,7 @@ var github = (function(){ return { showRepos: function(options){ $.ajax({ - url: "https://api.github.com/users/"+options.user+"/repos?callback=?" + url: "https://api.github.com/users/"+options.user+"/repos?sort=pushed;callback=?" , type: 'jsonp' , error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); } , success: function(data) { @@ -23,14 +23,6 @@ var github = (function(){ if (options.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 (options.count) { repos.splice(options.count); } render(options.target, repos); } -- cgit v1.2.1 From cc5f508a1005fc3c82b77c73e2c82e264a578a97 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 20 Feb 2013 17:46:15 +0100 Subject: Use HTML5 '&' character to connect query params in GitHub API call. #1031. --- .themes/classic/source/javascripts/github.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.themes/classic/source/javascripts/github.js') diff --git a/.themes/classic/source/javascripts/github.js b/.themes/classic/source/javascripts/github.js index 92d2fda2..6cfc0b0b 100644 --- a/.themes/classic/source/javascripts/github.js +++ b/.themes/classic/source/javascripts/github.js @@ -13,7 +13,7 @@ var github = (function(){ return { showRepos: function(options){ $.ajax({ - url: "https://api.github.com/users/"+options.user+"/repos?sort=pushed;callback=?" + url: "https://api.github.com/users/"+options.user+"/repos?sort=pushed&callback=?" , type: 'jsonp' , error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); } , success: function(data) { -- cgit v1.2.1