Add blogger API to FCC and list 5 most recent blog posts on about page

This commit is contained in:
Michael Q Larson
2015-01-12 21:28:58 -08:00
parent a29408bacb
commit 4bdc3d34ad
4 changed files with 62 additions and 14 deletions

View File

@ -9,6 +9,10 @@ module.exports = {
secret: process.env.TRELLO_SECRET secret: process.env.TRELLO_SECRET
}, },
blogger: {
key: process.env.BLOGGER_KEY,
},
mandrill: { mandrill: {
user: process.env.MANDRILL_USER, user: process.env.MANDRILL_USER,
password: process.env.MANDRILL_PASSWORD password: process.env.MANDRILL_PASSWORD

View File

@ -124,12 +124,30 @@ module.exports = {
var date2 = new Date(); var date2 = new Date();
var timeDiff = Math.abs(date2.getTime() - date1.getTime()); var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var daysRunning = Math.ceil(timeDiff / (1000 * 3600 * 24)); var daysRunning = Math.ceil(timeDiff / (1000 * 3600 * 24));
client.get('https://trello.com/1/boards/BA3xVpz9/cards?key=' + secrets.trello.key, function(trello, response) { client.get('https://trello.com/1/boards/BA3xVpz9/cards?key=' + secrets.trello.key, function(trello, res2) {
client.get('https://www.googleapis.com/blogger/v3/blogs/2421288658305323950/posts?key=' + secrets.blogger.key, function(blogger, res3) {
var nonprofitProjects = trello.length || 15; var nonprofitProjects = trello.length || 15;
User.count({'points': {'$gt': 2}}, function(err, c3) { if (err) { debug('User err: ', err); next(err); } var blog = JSON.parse(blogger);
User.count({'points': {'$gt': 9}}, function(err, c10) { if (err) { debug('User err: ', err); next(err); } User.count({'points': {'$gt': 2}}, function (err, c3) {
User.count({'points': {'$gt': 29}}, function(err, c30) { if (err) { debug('User err: ', err); next(err); } if (err) {
User.count({'points': {'$gt': 53}}, function(err, all) { if (err) { debug('User err: ', err); next(err); } debug('User err: ', err);
next(err);
}
User.count({'points': {'$gt': 9}}, function (err, c10) {
if (err) {
debug('User err: ', err);
next(err);
}
User.count({'points': {'$gt': 29}}, function (err, c30) {
if (err) {
debug('User err: ', err);
next(err);
}
User.count({'points': {'$gt': 53}}, function (err, all) {
if (err) {
debug('User err: ', err);
next(err);
}
res.render('resources/about', { res.render('resources/about', {
title: 'About Free Code Camp and Our Team of Volunteers', title: 'About Free Code Camp and Our Team of Volunteers',
daysRunning: daysRunning, daysRunning: daysRunning,
@ -137,7 +155,18 @@ module.exports = {
c3: c3, c3: c3,
c10: c10, c10: c10,
c30: c30, c30: c30,
all: all all: all,
blog1Title: blog["items"][0]["title"],
blog1Link: blog["items"][0]["url"],
blog2Title: blog["items"][1]["title"],
blog2Link: blog["items"][1]["url"],
blog3Title: blog["items"][2]["title"],
blog3Link: blog["items"][2]["url"],
blog4Title: blog["items"][3]["title"],
blog4Link: blog["items"][3]["url"],
blog5Title: blog["items"][4]["title"],
blog5Link: blog["items"][4]["url"]
});
}); });
}); });
}); });

14
views/partials/blog.jade Normal file
View File

@ -0,0 +1,14 @@
.panel.panel-primary
.panel-heading.landing-panel-heading.text-center New posts on blog.freecodecamp.com
.panel-body
.landing-panel-body.text-center
h2
a(href=blog1Link)= blog1Title
h2
a(href=blog2Link)= blog2Title
h2
a(href=blog3Link)= blog3Title
h2
a(href=blog4Link)= blog4Title
h2
a(href=blog5Link)= blog5Title

View File

@ -1,5 +1,6 @@
extends ../layout extends ../layout
block content block content
include ../partials/stats include ../partials/stats
include ../partials/blog
include ../partials/about include ../partials/about
include ../partials/faq include ../partials/faq