Skip to content

og-shawn-crigger/Request-Github

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 

Repository files navigation

Request-Github

A simple extension of Request.JSONP to pull Github repo data.

How to use

window.addEvents({

    domready: function() {

        //Change to use your Github username
        new Request.Github('svizion', {
            show_forks: false,
            count     : 10,
            data: {
                type: "public",
                sort: "updated"
            },
            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 = '',
                    // Change the id to your element.
                    t = document.id('gh_repos');

				// Count the repos and slice the array/object
                if (this.options.count){
                    repos.splice(this.options.count);
                }
                for (i = 0; i < repos.length; i++) {
                	// Weed out the forks.
                    if ( ! this.options.show_forks && repos[i].fork) {
                        continue;
                    }

                    // Build up the html
                    fragment += '<li><a href="' + repos[i].html_url + '">' + repos[i].name + '</a><p>' + repos[i].description + '</p></li>';
                }
                // Drop it in the DOM
                t.set('html', fragment);

            }
        }).send();
    }


});

Please see Github's API Docs for other options.

About

A simple Mootools extension of Request.JSONP to pull Github repo data.

Resources

Stars

Watchers

Forks

Packages

No packages published