Skip to content

Instantly share code, notes, and snippets.

@ctdk
Created June 13, 2012 17:39
Show Gist options
  • Select an option

  • Save ctdk/2925425 to your computer and use it in GitHub Desktop.

Select an option

Save ctdk/2925425 to your computer and use it in GitHub Desktop.
Diff to fix Octopress' github.js to make it not use the deactivated Github v2 API
diff --git a/source/javascripts/github.js b/source/javascripts/github.js
index 678775a..bc4c9bd 100644
--- a/source/javascripts/github.js
+++ b/source/javascripts/github.js
@@ -3,22 +3,22 @@ var github = (function(){
var i = 0, fragment = '', t = $(target)[0];
for(i = 0; i < repos.length; i++) {
- fragment += '<li><a href="'+repos[i].url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';
+ fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';
}
t.innerHTML = fragment;
}
return {
showRepos: function(options){
$.ajax({
- url: "https://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(),
@jondkinney
Copy link
Copy Markdown

There's another little bit that needs to change above this patch. Line 6:

Old version:

fragment += '<li><a href="'+repos[i].url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';

New Version

fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';

The URL is now html_url

@ctdk
Copy link
Copy Markdown
Author

ctdk commented Jul 7, 2012

Huh, weird. I swear it worked before, but maybe I dreamed it up. Anyway, I'll update this shortly.

@ctdk
Copy link
Copy Markdown
Author

ctdk commented Jul 7, 2012

And, updated. Thanks for the heads up.

@dideler
Copy link
Copy Markdown

dideler commented Aug 18, 2012

Works great, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment