Clean up privacy policy routing. Adopt same pattern from courseware/bonfire mongo lookup to fieldguides.

This commit is contained in:
terakilobyte
2015-04-24 13:49:32 -04:00
parent 5f6177378f
commit b3929f693b
3 changed files with 12 additions and 22 deletions

18
app.js
View File

@ -253,12 +253,8 @@ app.use(express.static(__dirname + '/public', { maxAge: 86400000 }));
app.get('/', homeController.index); app.get('/', homeController.index);
app.get('/privacy', function(req, res) {
res.redirect(301, "/field-guide/free-code-camp's-privacy-policy");
});
app.get('/nonprofit-project-instructions', function(req, res) { app.get('/nonprofit-project-instructions', function(req, res) {
res.redirect(301, "/field-guide/free-code-camp's-privacy-policy"); res.redirect(301, '/field-guide/nonprofit-project-instructions');
}); });
app.get('/chat', resourcesController.chat); app.get('/chat', resourcesController.chat);
@ -384,17 +380,17 @@ app.post(
passportConf.isAuthenticated, passportConf.isAuthenticated,
contactController.postDoneWithFirst100Hours contactController.postDoneWithFirst100Hours
); );
//app.get(
// '/nonprofit-project-instructions',
// passportConf.isAuthenticated,
// resourcesController.nonprofitProjectInstructions
//);
app.post( app.post(
'/update-progress', '/update-progress',
passportConf.isAuthenticated, passportConf.isAuthenticated,
userController.updateProgress userController.updateProgress
); );
app.get('/privacy', function(req, res) {
res.redirect(301, '/field-guide/the-free-code-camp-privacy-policy');
});
app.get('/api/slack', function(req, res) { app.get('/api/slack', function(req, res) {
if (req.user) { if (req.user) {
if (req.user.email) { if (req.user.email) {
@ -590,7 +586,7 @@ app.post('/completed-bonfire/', bonfireController.completedBonfire);
app.get('/field-guide/:fieldGuideName', fieldGuideController.returnIndividualFieldGuide); app.get('/field-guide/:fieldGuideName', fieldGuideController.returnIndividualFieldGuide);
app.get('/field-guide', fieldGuideController.returnNextFieldGuide); app.get('/field-guide/', fieldGuideController.returnNextFieldGuide);
app.post('/completed-field-guide/', fieldGuideController.completedFieldGuide); app.post('/completed-field-guide/', fieldGuideController.completedFieldGuide);

View File

@ -9,12 +9,12 @@ exports.returnIndividualFieldGuide = function(req, res, next) {
var fieldGuideName = dashedName.replace(/\-/g, ' '); var fieldGuideName = dashedName.replace(/\-/g, ' ');
FieldGuide.find({'name': new RegExp(fieldGuideName, 'i')}, function(err, fieldGuide) { FieldGuide.find({'name': new RegExp(fieldGuideName, 'i')}, function(err, fieldGuideFromMongo) {
if (err) { if (err) {
next(err); next(err);
} }
if (fieldGuide.length < 1) { if (fieldGuideFromMongo.length < 1) {
req.flash('errors', { req.flash('errors', {
msg: "404: We couldn't find a field guide entry with that name. Please double check the name." msg: "404: We couldn't find a field guide entry with that name. Please double check the name."
}); });
@ -22,9 +22,9 @@ exports.returnIndividualFieldGuide = function(req, res, next) {
return res.redirect('/field-guide'); return res.redirect('/field-guide');
} }
fieldGuide = fieldGuide.pop(); fieldGuide = fieldGuideFromMongo.pop();
var dashedNameFull = fieldGuide.name.toLowerCase().replace(/\s/g, '-').replace(/\?/g, ''); var dashedNameFull = fieldGuide.name.toLowerCase().replace(/\s/g, '-').replace(/\?/g, '');
if (dashedNameFull != dashedName) { if (dashedNameFull !== dashedName) {
return res.redirect('../field-guide/' + dashedNameFull); return res.redirect('../field-guide/' + dashedNameFull);
} }
res.render('field-guide/show', { res.render('field-guide/show', {
@ -69,7 +69,7 @@ exports.returnNextFieldGuide = function(req, res, next) {
return next(err); return next(err);
} }
fieldGuide = fieldGuide.pop(); fieldGuide = fieldGuide.pop();
if (fieldGuide === undefined) { if (typeof fieldGuide === 'undefined') {
req.flash('success', { req.flash('success', {
msg: "You've read all our current Field Guide entries. You can contribute to our Field Guide <a href='https://github.com/FreeCodeCamp/freecodecamp/blob/master/seed_data/field-guides.json'>here</a>." msg: "You've read all our current Field Guide entries. You can contribute to our Field Guide <a href='https://github.com/FreeCodeCamp/freecodecamp/blob/master/seed_data/field-guides.json'>here</a>."
}); });

View File

@ -44,12 +44,6 @@ Array.zip = function(left, right, combinerFunction) {
}; };
module.exports = { module.exports = {
privacy: function privacy(req, res) {
res.render('resources/privacy', {
title: 'Privacy'
});
},
sitemap: function sitemap(req, res, next) { sitemap: function sitemap(req, res, next) {
var appUrl = 'http://www.freecodecamp.com'; var appUrl = 'http://www.freecodecamp.com';
var now = moment(new Date()).format('YYYY-MM-DD'); var now = moment(new Date()).format('YYYY-MM-DD');