Mootools Github Request
Me playing around with Mootools extending the Request.JSON class to pull Github repos, not quite finished.
HTML
<ul id="gh_repos">
<li class="loading">Loading</li>
</ul>
CSS
#gh_repos{min-height:350px; border:1px solid #222}
JavaScript
window.addEvents({
domready: function() {
new Request.Github('svizion', {
data: {
count: 5
},
onFailure: function (err) {
$$('#gh_repos li.loading').addClass('error').set("html","Github is busted! or maybe my scripting skillz need work...");
},
onSuccess: function(repos) {
if (repos.data) repos = repos.data;
var i = 0,
fragment = '',
t = document.id('gh_repos');
repos.splice(8);
for (i = 0; i < repos.length; i++) {
if (repos[i].fork) {
continue;
}
fragment += '<li><a href="' + repos[i].html_url + '">' + repos[i].name + '</a><p>' + repos[i].description + '</p></li>';
}
t.set('html', fragment);
}
}).send();
}
});
Request.Github = new Class({
Extends: Request.JSONP,
options: {
url: "https://api.github.com/users/{user}/repos",
skip_forks: true,
callbackKey: "callback",
count: 10,
data: {
type: "public",
sort: "updated"
}
},
initialize: function(user, options) {
this.parent(options);
this.options.url = this.options.url.substitute({
user: user
});
},
success: function(data, script) {
this.parent(data, script);
}
});