How to fix Octopress GitHub aside

The first thing that I noticed when installing Octopress was that the Github aside widget was stuck in a Status updating... loop. I decided to investigate the issue :)

It turns out that Octopress is a little bit dated. GitHub has changed its API URL endpoints and as such, the AJAX request that is made turns into a 404 and we're stuck "updating...". So I took it upon myself to fix, which I will at some point make a pull request for on the official repository. But in the interim, he's how to fix it:

First open up source/javascripts/github.js and then look for the showRepos function. Paste over it with this:

{% codeblock showRepos function lang:js %} showRepos: function(options){
$.ajax({ 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.data) { return; } for (var i = 0; i < data.data.length; i++) { if (options.skipforks && data.data[i].fork) { continue; } repos.push(data.data[i]); } repos.sort(function(a, b) { var aDate = new Date(a.pushedat).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);
    }
});

} {% endcodeblock %}

And that's all there is to fixing it! You'll have to run rake generate again so that it can compile the source, but you should soon see your GitHub repos show.

Update: I've just sent a pull request to imathis to fix this.


comments powered by Disqus