add ajax for github calls
This commit is contained in:
@ -99,7 +99,7 @@ module.exports = {
|
||||
githubCalls: function(req, res) {
|
||||
var githubHeaders = {headers: {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1521.3 Safari/537.36'}, port:80 };
|
||||
client.get('https://api.github.com/repos/freecodecamp/freecodecamp/pulls?client_id=' + secrets.github.clientID + '&client_secret=' + secrets.github.clientSecret, githubHeaders, function(pulls, res3) {
|
||||
pulls = Object.keys(JSON.parse(pulls)).length || "Can't connect to github";
|
||||
pulls = pulls ? Object.keys(JSON.parse(pulls)).length : "Can't connect to github";
|
||||
client.get('https://api.github.com/repos/freecodecamp/freecodecamp/issues?client_id=' + secrets.github.clientID + '&client_secret=' + secrets.github.clientSecret, githubHeaders, function (issues, res4) {
|
||||
issues = ((pulls === parseInt(pulls)) && issues) ? Object.keys(JSON.parse(issues)).length - pulls : "Can't connect to GitHub";
|
||||
res.send({"issues": issues, "pulls" : pulls});
|
||||
|
14
views/partials/github.jade
Normal file
14
views/partials/github.jade
Normal file
@ -0,0 +1,14 @@
|
||||
#github
|
||||
script.
|
||||
(function() {
|
||||
$.ajax({
|
||||
url: 'http://localhost:3001/api/github',
|
||||
type: 'GET'
|
||||
}).done(
|
||||
function(data) {
|
||||
var github = document.createElement('div');
|
||||
console.log(data);
|
||||
$(github).html('<div class="row"><div class="col-xs-6 text-right">Open Issues:</div><div class="col-xs-6 text-left">' + data.issues + ' <a href="https://github.com/freecodecamp/freecodecamp/issues">(create one)</a></div></div><div class="row"><div class="col-xs-6 text-right">Open Pull Requests:</div><div class="col-xs-6 text-left">' + data.pulls + ' <a href="https://github.com/freecodecamp/freecodecamp/pulls">(create one)</a></div></div>').prependTo($('#github'))
|
||||
}
|
||||
);
|
||||
})();
|
@ -6,16 +6,7 @@ h2.stats-text
|
||||
.col-xs-6.text-right Nonprofit Projects:
|
||||
.col-xs-6.text-left
|
||||
include ../partials/trello
|
||||
//.row
|
||||
// .col-xs-6.text-right Open Issues:
|
||||
// .col-xs-6.text-left= issues
|
||||
// |  
|
||||
// a(href="https://github.com/freecodecamp/freecodecamp/issues") (create one)
|
||||
//.row
|
||||
// .col-xs-6.text-right Pull Requests:
|
||||
// .col-xs-6.text-left= pulls
|
||||
// |  
|
||||
// a(href="https://github.com/freecodecamp/freecodecamp/pulls") (create one)
|
||||
include ../partials/github
|
||||
.row
|
||||
.col-xs-6.text-right Campers with at least...
|
||||
.col-xs-4
|
||||
|
@ -29,7 +29,7 @@ block content
|
||||
.panel-heading.landing-panel-heading.text-center Blog
|
||||
.panel-body
|
||||
.landing-panel-body.text-center
|
||||
include ../partials/blog
|
||||
include ../partials/blogger
|
||||
.panel.panel-info
|
||||
.panel-heading.landing-panel-heading.text-center Tweets
|
||||
.panel-body
|
||||
|
Reference in New Issue
Block a user