Skip to content

Commit

Permalink
Add blogger API to FCC and list 5 most recent blog posts on about page
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Q Larson committed Jan 13, 2015
1 parent a29408b commit 4bdc3d3
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 14 deletions.
4 changes: 4 additions & 0 deletions config/secrets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 43 additions & 14 deletions controllers/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
});
});
});
});
Expand Down
14 changes: 14 additions & 0 deletions views/partials/blog.jade
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions views/resources/about.jade
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extends ../layout
block content
include ../partials/stats
include ../partials/blog
include ../partials/about
include ../partials/faq

0 comments on commit 4bdc3d3

Please sign in to comment.