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