Skip to content

Commit

Permalink
Suggest github stars, forks, issues
Browse files Browse the repository at this point in the history
  • Loading branch information
espadrine committed Jan 19, 2015
1 parent d75133f commit f3238a7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ var github = function(url, cb) {
var user = userRepo[0];
var repo = userRepo[1];
Promise.all([
githubIssues(user, repo),
githubForks(user, repo),
githubStars(user, repo),
githubLicense(user, repo),
]).then(function(badges) {
cb({badges:badges});
Expand All @@ -40,6 +43,31 @@ var github = function(url, cb) {
});
};

var githubIssues = function(user, repo) {
var userRepo = user + '/' + repo;
return Promise.resolve({
name: 'GitHub issues',
link: 'https://github.com/' + userRepo + '/issues',
badge: 'https://img.shields.io/github/issues/' + userRepo + '.svg',
});
};
var githubForks = function(user, repo) {
var userRepo = user + '/' + repo;
return Promise.resolve({
name: 'GitHub forks',
link: 'https://github.com/' + userRepo + '/network',
badge: 'https://img.shields.io/github/forks/' + userRepo + '.svg',
});
};
var githubStars = function(user, repo) {
var userRepo = user + '/' + repo;
return Promise.resolve({
name: 'GitHub stars',
link: 'https://github.com/' + userRepo + '/stargazers',
badge: 'https://img.shields.io/github/stars/' + userRepo + '.svg',
});
};

// user: eg, qubyte
// repo: eg, rubidium
// returns a promise of {link, badge, name}
Expand Down

0 comments on commit f3238a7

Please sign in to comment.