Merge branch 'staging' of https://github.com/FreeCodeCamp/freecodecamp into staging
This commit is contained in:
@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"timePosted": {
|
"timePosted": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "0"
|
"default": 0
|
||||||
},
|
},
|
||||||
"link": {
|
"link": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -35,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
"rank": {
|
"rank": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "-Infinity"
|
"default": 0
|
||||||
},
|
},
|
||||||
"upVotes": {
|
"upVotes": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
@ -53,13 +53,6 @@
|
|||||||
"storyLink": {
|
"storyLink": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
},
|
|
||||||
"difficulty": "string",
|
|
||||||
"description": "array",
|
|
||||||
"tests": "array",
|
|
||||||
"challengeSeed": "array",
|
|
||||||
"MDNlinks": {
|
|
||||||
"type": "array"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"validations": [],
|
"validations": [],
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
"gulp-minify-css": "~0.5.1",
|
"gulp-minify-css": "~0.5.1",
|
||||||
"helmet": "~0.9.0",
|
"helmet": "~0.9.0",
|
||||||
"helmet-csp": "^0.2.3",
|
"helmet-csp": "^0.2.3",
|
||||||
|
"hpp": "^0.2.0",
|
||||||
"jade": "~1.8.0",
|
"jade": "~1.8.0",
|
||||||
"less": "~1.7.5",
|
"less": "~1.7.5",
|
||||||
"less-middleware": "~2.0.1",
|
"less-middleware": "~2.0.1",
|
||||||
|
@ -324,7 +324,7 @@ $(document).ready(function() {
|
|||||||
$('#story-submit').bind('click', storySubmitButtonHandler);
|
$('#story-submit').bind('click', storySubmitButtonHandler);
|
||||||
})
|
})
|
||||||
.done(function (data, textStatus, xhr) {
|
.done(function (data, textStatus, xhr) {
|
||||||
window.location = '/news/' + JSON.parse(data).storyLink;
|
window.location = '/stories/' + JSON.parse(data).storyLink;
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,7 @@ module.exports = function(app) {
|
|||||||
app.use(router);
|
app.use(router);
|
||||||
|
|
||||||
function returnIndividualFieldGuide(req, res, next) {
|
function returnIndividualFieldGuide(req, res, next) {
|
||||||
var dashedName = req.params.fieldGuideName;
|
var dashedNameFromQuery = req.params.fieldGuideName;
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
var completed = req.user.completedFieldGuides;
|
var completed = req.user.completedFieldGuides;
|
||||||
|
|
||||||
@ -32,9 +32,7 @@ module.exports = function(app) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(berks): loopback might have issue with regex here.
|
FieldGuide.find({ where: {'dashedName': dashedNameFromQuery}},
|
||||||
FieldGuide.find(
|
|
||||||
{ dashedName: new RegExp(dashedName, 'i') },
|
|
||||||
function(err, fieldGuideFromMongo) {
|
function(err, fieldGuideFromMongo) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
@ -46,15 +44,15 @@ module.exports = function(app) {
|
|||||||
'Please double check the name.'
|
'Please double check the name.'
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.redirect('/field-guide');
|
return res.redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
var fieldGuide = R.head(fieldGuideFromMongo);
|
var fieldGuide = R.head(fieldGuideFromMongo);
|
||||||
fieldGuide.name.toLowerCase().replace(/\s/g, '-').replace(/\?/g, '');
|
fieldGuide.name.toLowerCase().replace(/\s/g, '-').replace(/\?/g, '');
|
||||||
|
|
||||||
if (fieldGuide.dashedName !== dashedName) {
|
//if (fieldGuide.dashedName !== dashedNameFromQuery) {
|
||||||
return res.redirect('../field-guide/' + fieldGuide.dashedName);
|
// return res.redirect('../field-guide/' + fieldGuide.dashedName);
|
||||||
}
|
//}
|
||||||
res.render('field-guide/show', {
|
res.render('field-guide/show', {
|
||||||
title: fieldGuide.name,
|
title: fieldGuide.name,
|
||||||
fieldGuideId: fieldGuide.id,
|
fieldGuideId: fieldGuide.id,
|
||||||
|
@ -2,7 +2,7 @@ var nodemailer = require('nodemailer'),
|
|||||||
sanitizeHtml = require('sanitize-html'),
|
sanitizeHtml = require('sanitize-html'),
|
||||||
moment = require('moment'),
|
moment = require('moment'),
|
||||||
mongodb = require('mongodb'),
|
mongodb = require('mongodb'),
|
||||||
// debug = require('debug')('freecc:cntr:story'),
|
debug = require('debug')('freecc:cntr:story'),
|
||||||
utils = require('../utils'),
|
utils = require('../utils'),
|
||||||
MongoClient = mongodb.MongoClient,
|
MongoClient = mongodb.MongoClient,
|
||||||
secrets = require('../../config/secrets');
|
secrets = require('../../config/secrets');
|
||||||
@ -13,7 +13,6 @@ module.exports = function(app) {
|
|||||||
var Story = app.models.Story;
|
var Story = app.models.Story;
|
||||||
|
|
||||||
router.get('/stories/hotStories', hotJSON);
|
router.get('/stories/hotStories', hotJSON);
|
||||||
router.get('/stories/recentStories', recentJSON);
|
|
||||||
router.get('/stories/comments/:id', comments);
|
router.get('/stories/comments/:id', comments);
|
||||||
router.post('/stories/comment/', commentSubmit);
|
router.post('/stories/comment/', commentSubmit);
|
||||||
router.post('/stories/comment/:id/comment', commentOnCommentSubmit);
|
router.post('/stories/comment/:id/comment', commentOnCommentSubmit);
|
||||||
@ -22,9 +21,9 @@ module.exports = function(app) {
|
|||||||
router.get('/stories/submit/new-story', preSubmit);
|
router.get('/stories/submit/new-story', preSubmit);
|
||||||
router.post('/stories/preliminary', newStory);
|
router.post('/stories/preliminary', newStory);
|
||||||
router.post('/stories/', storySubmission);
|
router.post('/stories/', storySubmission);
|
||||||
router.get('/news/', hot);
|
router.get('/stories/', hot);
|
||||||
router.post('/stories/search', getStories);
|
router.post('/stories/search', getStories);
|
||||||
router.get('/news/:storyName', returnIndividualStory);
|
router.get('/stories/:storyName', returnIndividualStory);
|
||||||
router.post('/stories/upvote/', upvote);
|
router.post('/stories/upvote/', upvote);
|
||||||
|
|
||||||
app.use(router);
|
app.use(router);
|
||||||
@ -44,12 +43,19 @@ module.exports = function(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hotJSON(req, res, next) {
|
function hotJSON(req, res, next) {
|
||||||
var story = Story.find({}).sort({'timePosted': -1}).limit(1000);
|
//var story = Story.find({}).sort({'timePosted': -1}).limit(1000);
|
||||||
story.exec(function(err, stories) {
|
//story.exec(function(err, stories) {
|
||||||
|
// if (err) {
|
||||||
|
// return next(err);
|
||||||
|
// }
|
||||||
|
//Story.find([{$match: {}},
|
||||||
|
// {$sort: {'timePosted': -1}},
|
||||||
|
// {$limit: 1000}], function(err, stories) {
|
||||||
|
Story.find({order: 'timePosted DESC', limit: 1000}, function(err, stories) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
debug(stories);
|
||||||
var foundationDate = 1413298800000;
|
var foundationDate = 1413298800000;
|
||||||
|
|
||||||
var sliceVal = stories.length >= 100 ? 100 : stories.length;
|
var sliceVal = stories.length >= 100 ? 100 : stories.length;
|
||||||
@ -63,16 +69,6 @@ module.exports = function(app) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function recentJSON(req, res, next) {
|
|
||||||
var story = Story.find({}).sort({'timePosted': -1}).limit(100);
|
|
||||||
story.exec(function(err, stories) {
|
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
return res.json(stories);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function hot(req, res) {
|
function hot(req, res) {
|
||||||
return res.render('stories/index', {
|
return res.render('stories/index', {
|
||||||
title: 'Hot stories currently trending on Camper News',
|
title: 'Hot stories currently trending on Camper News',
|
||||||
@ -136,11 +132,12 @@ module.exports = function(app) {
|
|||||||
|
|
||||||
|
|
||||||
function returnIndividualStory(req, res, next) {
|
function returnIndividualStory(req, res, next) {
|
||||||
|
debug('hit return individual route');
|
||||||
var dashedName = req.params.storyName;
|
var dashedName = req.params.storyName;
|
||||||
|
|
||||||
var storyName = dashedName.replace(/\-/g, ' ').trim();
|
var storyName = dashedName.replace(/\-/g, ' ').trim();
|
||||||
|
|
||||||
Story.find({'storyLink': storyName}, function(err, story) {
|
Story.find({where: {'storyLink': storyName}}, function(err, story) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
@ -152,7 +149,7 @@ module.exports = function(app) {
|
|||||||
'Please double check the name.'
|
'Please double check the name.'
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.redirect('/news/');
|
return res.redirect('/stories/');
|
||||||
}
|
}
|
||||||
|
|
||||||
story = story.pop();
|
story = story.pop();
|
||||||
@ -160,7 +157,7 @@ module.exports = function(app) {
|
|||||||
.replace(/\s+/g, ' ')
|
.replace(/\s+/g, ' ')
|
||||||
.replace(/\s/g, '-');
|
.replace(/\s/g, '-');
|
||||||
if (dashedNameFull !== dashedName) {
|
if (dashedNameFull !== dashedName) {
|
||||||
return res.redirect('../news/' + dashedNameFull);
|
return res.redirect('../stories/' + dashedNameFull);
|
||||||
}
|
}
|
||||||
|
|
||||||
var userVoted = false;
|
var userVoted = false;
|
||||||
@ -324,7 +321,7 @@ module.exports = function(app) {
|
|||||||
});
|
});
|
||||||
return res.json({
|
return res.json({
|
||||||
alreadyPosted: true,
|
alreadyPosted: true,
|
||||||
storyURL: '/news/' + story.pop().storyLink
|
storyURL: '/stories/' + story.pop().storyLink
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
utils.getURLTitle(url, processResponse);
|
utils.getURLTitle(url, processResponse);
|
||||||
@ -600,7 +597,7 @@ module.exports = function(app) {
|
|||||||
data.author.username + ' replied to you on Camper News.',
|
data.author.username + ' replied to you on Camper News.',
|
||||||
'You can keep this conversation going.',
|
'You can keep this conversation going.',
|
||||||
'Just head back to the discussion here: ',
|
'Just head back to the discussion here: ',
|
||||||
'http://freecodecamp.com/news/' + data.originalStoryLink,
|
'http://freecodecamp.com/stories/' + data.originalStoryLink,
|
||||||
'- the Free Code Camp Volunteer Team'
|
'- the Free Code Camp Volunteer Team'
|
||||||
].join('\n')
|
].join('\n')
|
||||||
};
|
};
|
||||||
|
@ -323,7 +323,7 @@ module.exports = function(app) {
|
|||||||
|
|
||||||
function returnUser (req, res, next) {
|
function returnUser (req, res, next) {
|
||||||
User.find(
|
User.find(
|
||||||
{ 'profile.username': req.params.username.toLowerCase() },
|
{where: { 'username': req.params.username.toLowerCase() }},
|
||||||
function(err, user) {
|
function(err, user) {
|
||||||
if (err) {
|
if (err) {
|
||||||
debug('Username err: ', err);
|
debug('Username err: ', err);
|
||||||
|
@ -27,6 +27,7 @@ var R = require('ramda'),
|
|||||||
expressValidator = require('express-validator'),
|
expressValidator = require('express-validator'),
|
||||||
forceDomain = require('forcedomain'),
|
forceDomain = require('forcedomain'),
|
||||||
lessMiddleware = require('less-middleware'),
|
lessMiddleware = require('less-middleware'),
|
||||||
|
hpp = require('hpp'),
|
||||||
|
|
||||||
passportProviders = require('./passport-providers'),
|
passportProviders = require('./passport-providers'),
|
||||||
/**
|
/**
|
||||||
@ -59,6 +60,7 @@ app.use(lessMiddleware(path.join(__dirname, '/public')));
|
|||||||
app.use(logger('dev'));
|
app.use(logger('dev'));
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
app.use(hpp());
|
||||||
app.use(expressValidator({
|
app.use(expressValidator({
|
||||||
customValidators: {
|
customValidators: {
|
||||||
matchRegex: function (param, regex) {
|
matchRegex: function (param, regex) {
|
||||||
|
@ -25,7 +25,7 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height
|
|||||||
li
|
li
|
||||||
a(href='/challenges/waypoint-join-our-chat-room') Chat
|
a(href='/challenges/waypoint-join-our-chat-room') Chat
|
||||||
li
|
li
|
||||||
a(href='/news') News
|
a(href='/stories') News
|
||||||
li
|
li
|
||||||
a(href='/field-guide') Guide
|
a(href='/field-guide') Guide
|
||||||
li.hidden-xs.hidden-sm
|
li.hidden-xs.hidden-sm
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
" by <a href='/" + data[i].author.username + "'>@" + data[i].author.username + "</a> " +
|
" by <a href='/" + data[i].author.username + "'>@" + data[i].author.username + "</a> " +
|
||||||
"</div>" +
|
"</div>" +
|
||||||
"<div class='col-xs-12'>" +
|
"<div class='col-xs-12'>" +
|
||||||
"<br><a class='btn btn-no-shadow btn-primary btn-block btn-primary-ghost' href='/news/" + linkedName + "'>discuss</a>" +
|
"<br><a class='btn btn-no-shadow btn-primary btn-block btn-primary-ghost' href='/stories/" + linkedName + "'>discuss</a>" +
|
||||||
"</div>" +
|
"</div>" +
|
||||||
"</div>" +
|
"</div>" +
|
||||||
"<div class='hidden-xs row media-stories'>" +
|
"<div class='hidden-xs row media-stories'>" +
|
||||||
@ -56,7 +56,7 @@
|
|||||||
"</a>" +
|
"</a>" +
|
||||||
"</div>" +
|
"</div>" +
|
||||||
"<div class='story-byline col-xs-12 wrappable'>" +
|
"<div class='story-byline col-xs-12 wrappable'>" +
|
||||||
"<a class='btn btn-no-shadow btn-primary btn-xs btn-primary-ghost' href='/news/" + linkedName + "'>discuss</a> · " +
|
"<a class='btn btn-no-shadow btn-primary btn-xs btn-primary-ghost' href='/stories/" + linkedName + "'>discuss</a> · " +
|
||||||
rank + (rank > 1 ? " points" : " point") + " · posted " +
|
rank + (rank > 1 ? " points" : " point") + " · posted " +
|
||||||
moment(data[i].timePosted).fromNow() +
|
moment(data[i].timePosted).fromNow() +
|
||||||
" by <a href='/" + data[i].author.username + "'>@" + data[i].author.username + "</a> " +
|
" by <a href='/" + data[i].author.username + "'>@" + data[i].author.username + "</a> " +
|
||||||
|
Reference in New Issue
Block a user