diff --git a/config/secrets.js b/config/secrets.js index 67dc4f736ac325..419b9277927dc2 100644 --- a/config/secrets.js +++ b/config/secrets.js @@ -9,6 +9,10 @@ module.exports = { secret: process.env.TRELLO_SECRET }, + blogger: { + key: process.env.BLOGGER_KEY, + }, + mandrill: { user: process.env.MANDRILL_USER, password: process.env.MANDRILL_PASSWORD diff --git a/controllers/resources.js b/controllers/resources.js index 8d829365e69458..16ef1ef231f4b1 100644 --- a/controllers/resources.js +++ b/controllers/resources.js @@ -124,20 +124,49 @@ module.exports = { var date2 = new Date(); var timeDiff = Math.abs(date2.getTime() - date1.getTime()); var daysRunning = Math.ceil(timeDiff / (1000 * 3600 * 24)); - client.get('https://trello.com/1/boards/BA3xVpz9/cards?key=' + secrets.trello.key, function(trello, response) { - var nonprofitProjects = trello.length || 15; - User.count({'points': {'$gt': 2}}, function(err, c3) { if (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', { - title: 'About Free Code Camp and Our Team of Volunteers', - daysRunning: daysRunning, - nonprofitProjects: nonprofitProjects, - c3: c3, - c10: c10, - c30: c30, - all: all + 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 blog = JSON.parse(blogger); + User.count({'points': {'$gt': 2}}, function (err, c3) { + if (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', { + title: 'About Free Code Camp and Our Team of Volunteers', + daysRunning: daysRunning, + nonprofitProjects: nonprofitProjects, + c3: c3, + c10: c10, + c30: c30, + 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"] + }); }); }); }); diff --git a/views/partials/blog.jade b/views/partials/blog.jade new file mode 100644 index 00000000000000..d624bd4f1770c3 --- /dev/null +++ b/views/partials/blog.jade @@ -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 \ No newline at end of file diff --git a/views/resources/about.jade b/views/resources/about.jade index 4fdf1ccfc9ca3a..6c8208650952e9 100644 --- a/views/resources/about.jade +++ b/views/resources/about.jade @@ -1,5 +1,6 @@ extends ../layout block content include ../partials/stats + include ../partials/blog include ../partials/about include ../partials/faq \ No newline at end of file