Fixed url redirect after submission, upvoting now works
This commit is contained in:
@ -29,9 +29,11 @@ exports.index = function(req, res, next) {
|
||||
exports.returnIndividualStory = function(req, res, next) {
|
||||
var dashedName = req.params.storyName;
|
||||
|
||||
storyName = dashedName.replace(/\-/g, ' ');
|
||||
var storyName = dashedName.replace(/\-/g, ' ');
|
||||
|
||||
Story.find({'headline' : new RegExp(storyName, 'i')}, function(err, story) {
|
||||
debug('looking for %s', storyName);
|
||||
|
||||
Story.find({'storyLink' : new RegExp(storyName, 'i')}, function(err, story) {
|
||||
if (err) {
|
||||
next(err);
|
||||
}
|
||||
@ -134,11 +136,10 @@ exports.storySubmission = function(req, res, next) {
|
||||
|
||||
story.save(function(err, data) {
|
||||
if (err) {
|
||||
throw err;
|
||||
return res.status(500);
|
||||
}
|
||||
res.send(JSON.stringify({
|
||||
storyLink: story.storyLink.replace(/\s/g, '-').toLowerCase()
|
||||
}));
|
||||
});
|
||||
|
||||
};
|
||||
|
@ -177,9 +177,7 @@ $(document).ready(function() {
|
||||
$('#story-submit').bind('click', storySubmitButtonHandler);
|
||||
})
|
||||
.done(function (data, textStatus, xhr) {
|
||||
window.dataReturn = data;
|
||||
console.log(data);
|
||||
window.location = '/stories/' + data.storyLink;
|
||||
window.location = '/stories/' + JSON.parse(data).storyLink;
|
||||
});
|
||||
|
||||
};
|
||||
|
@ -5,6 +5,7 @@ block content
|
||||
var storyId = !{JSON.stringify(id)};
|
||||
var comments = !{JSON.stringify(comments)};
|
||||
var upVotes = !{JSON.stringify(upVotes)};
|
||||
var user = !{JSON.stringify(user)};
|
||||
|
||||
.panel.panel-info
|
||||
.panel-heading.text-center Camper News
|
||||
|
Reference in New Issue
Block a user