Skip to content

Commit

Permalink
Clean up views, remove API controller views, add the gmail-shortcuts,…
Browse files Browse the repository at this point in the history
… control-shortcuts and deploy-a-website static views. Move all resource controller views to a resources view folder and update routes
  • Loading branch information
Michael Q Larson committed Dec 26, 2014
1 parent fffc4ec commit a5fa274
Show file tree
Hide file tree
Showing 36 changed files with 238 additions and 984 deletions.
5 changes: 5 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ app.get('/jquery-exercises', resourcesController.jqueryExercises);
app.get('/live-pair-programming', resourcesController.livePairProgramming);
app.get('/javascript-in-your-inbox', resourcesController.javaScriptInYourInbox);
app.get('/chromebook', resourcesController.chromebook);
app.get('/deploy-a-website', resourcesController.deployAWebsite);
app.get('/gmail-shortcuts', resourcesController.gmailShortcuts);
app.get('/control-shortcuts', resourcesController.controlShortcuts);
app.get('/control-shortcuts', resourcesController.deployAWebsite);
app.get('/stats', resourcesController.stats);

app.get(
'/pair-program-with-team-viewer',
Expand Down
5 changes: 5 additions & 0 deletions config/secrets.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ module.exports = {

sessionSecret: process.env.SESSION_SECRET,

trello: {
key: process.env.TRELLO_KEY,
secret: process.env.TRELLO_SECRET
},

mandrill: {
user: process.env.MANDRILL_USER,
password: process.env.MANDRILL_PASSWORD
Expand Down
93 changes: 71 additions & 22 deletions controllers/resources.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,121 @@
var User = require('../models/User'),
resources = require('./resources.json'),
questions = resources.questions,
steps = resources.steps;
steps = resources.steps,
secrets = require('./../config/secrets')

//NOTE(BERKS): Async, total users may not available before it is used.
var totalUsers = 0;
User.count({}, function(err, count) {
totalUsers = count;
});
var Client = require('node-rest-client').Client;
client = new Client();

/**
* GET /
* Resources.
*/
//TODO: Stats view

module.exports = {
learnToCode: function(req, res) {
res.render('learn-to-code', {
res.render('resources/learn-to-code', {
title: 'Learn to Code'
});
},

privacy: function privacy(req, res) {
res.render('privacy', {
res.render('resources/privacy', {
title: 'Privacy'
});
},

statistics: function statistics(req, res) {
res.render('statistics', {
title: 'Code Camper Statistics'
//totalUsers: totalUsers,
//usersOverTenChallenges: usersOverTenChallenges
stats: function stats(req, res) {
var date1 = new Date("10/15/2014");
var date2 = new Date();
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var daysRunning = Math.ceil(timeDiff / (1000 * 3600 * 24));
var nonprofitProjects = client.get('https://trello.com/1/boards/BA3xVpz9/cards?key=' + secrets.trello.key, function(data, response){return data.length;});
User.count({}, function(err, users) { if (err) { debug('User err: ', err); next(err); }
User.count({'points': {'$gt': 2}}, function(err, c2) { if (err) { debug('User err: ', err); next(err); }
User.count({'points': {'$gt': 4}}, function(err, c4) { if (err) { debug('User err: ', err); next(err); }
User.count({'points': {'$gt': 9}}, function(err, c9) { if (err) { debug('User err: ', err); next(err); }
User.count({'points': {'$gt': 19}}, function(err, c19) { if (err) { debug('User err: ', err); next(err); }
User.count({'points': {'$gt': 29}}, function(err, c29) { if (err) { debug('User err: ', err); next(err); }
User.count({'points': {'$gt': 39}}, function(err, c39) { if (err) { debug('User err: ', err); next(err); }
User.count({'points': {'$gt': 49}}, function(err, c49) { if (err) { debug('User err: ', err); next(err); }
User.count({'points': {'$gt': 59}}, function(err, c59) { if (err) { debug('User err: ', err); next(err); }
res.render('resources/stats', {
title: 'Free Code Camp Stats:',
daysRunning: daysRunning,
users: users,
nonprofitProjects: nonprofitProjects, /* can't yet get this to work. Async issue?
Hardcoded value for now and created a Trello card */
c2: c2,
c4: c4,
c9: c9,
c19: c19,
c29: c29,
c39: c39,
c49: c49,
c59: c59
});
});
});
});
});
});
});
});
});
});
},

deployAWebsite: function deployAWebsite(req, res) {
res.render('resources/deploy-a-website', {
title: 'Deploy a Dynamic Website in 7 Minutes'
});
},

gmailShortcuts: function gmailShortcuts(req, res) {
res.render('resources/gmail-shortcuts', {
title: 'These Gmail Shortcuts will save you Hours'
});
},

controlShortcuts: function controlShortcuts(req, res) {
res.render('resources/control-shortcuts', {
title: 'These Control Shortcuts will save you Hours'
});
},

chromebook: function chromebook(req, res) {
res.render('chromebook', {
res.render('resources/chromebook', {
title: 'Win a Chromebook'
});
},

jqueryExercises: function jqueryExercises(req, res) {
res.render('jquery-exercises', {
res.render('resources/jquery-exercises', {
title: 'jQuery Exercises'
});
},

livePairProgramming: function(req, res) {
res.render('live-pair-programming', {
res.render('resources/live-pair-programming', {
title: 'Live Pair Programming'
});
},

javaScriptInYourInbox: function(req, res) {
res.render('javascript-in-your-inbox', {
res.render('resources/javascript-in-your-inbox', {
title: 'JavaScript in your Inbox'
});
},

programmerInterviewQuestionsApp: function(req, res) {
res.render('programmer-interview-questions-app', {
res.render('resources/programmer-interview-questions-app', {
title: 'Programmer Interview Questions App'
});
},

pairProgramWithTeamViewer: function(req, res) {
res.render('pair-program-with-team-viewer', {
res.render('resources/pair-program-with-team-viewer', {
title: 'Challenge: Pair Program with Team Viewer',
name: 'Pair Program with Team Viewer',
video: '',
Expand All @@ -77,13 +126,13 @@ module.exports = {
},

about: function(req, res) {
res.render('about', {
res.render('resources/about', {
title: 'About Free Code Camp and Our Team of Volunteers'
});
},

doneWithFirst100Hours: function(req, res) {
res.render('done-with-first-100-hours', {
res.render('resources/done-with-first-100-hours', {
title:
'Congratulations on finishing the first 100 hours of Free Code Camp!'
});
Expand Down
5 changes: 0 additions & 5 deletions views/about.jade

This file was deleted.

47 changes: 0 additions & 47 deletions views/api/aviary.jade

This file was deleted.

26 changes: 0 additions & 26 deletions views/api/clockwork.jade

This file was deleted.

40 changes: 0 additions & 40 deletions views/api/facebook.jade

This file was deleted.

57 changes: 0 additions & 57 deletions views/api/foursquare.jade

This file was deleted.

Loading

0 comments on commit a5fa274

Please sign in to comment.