Browse code

Merge pull request #675 from zlu/master

Update Github API to V3

Brandon Mathis authored on 09/09/2012 at 19:51:48
Showing 1 changed files
... ...
@@ -3,22 +3,22 @@ var github = (function(){
3 3
     var i = 0, fragment = '', t = $(target)[0];
4 4
 
5 5
     for(i = 0; i < repos.length; i++) {
6
-      fragment += '<li><a href="'+repos[i].url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';
6
+      fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+(repos[i].description||'')+'</p></li>';
7 7
     }
8 8
     t.innerHTML = fragment;
9 9
   }
10 10
   return {
11 11
     showRepos: function(options){
12 12
       $.ajax({
13
-          url: "http://github.com/api/v2/json/repos/show/"+options.user+"?callback=?"
13
+          url: "https://api.github.com/users/"+options.user+"/repos?callback=?"
14 14
         , type: 'jsonp'
15 15
         , error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); }
16 16
         , success: function(data) {
17 17
           var repos = [];
18
-          if (!data || !data.repositories) { return; }
19
-          for (var i = 0; i < data.repositories.length; i++) {
20
-            if (options.skip_forks && data.repositories[i].fork) { continue; }
21
-            repos.push(data.repositories[i]);
18
+          if (!data || !data.data) { return; }
19
+          for (var i = 0; i < data.data.length; i++) {
20
+            if (options.skip_forks && data.data[i].fork) { continue; }
21
+            repos.push(data.data[i]);
22 22
           }
23 23
           repos.sort(function(a, b) {
24 24
             var aDate = new Date(a.pushed_at).valueOf(),