Merge pull request #217 from terakilobyte/fix-no-user-comment-display

Fix no user comment display
pull/221/head
Free Code Camp 2015-03-17 18:16:16 -04:00
commit 0052f99863
5 changed files with 34 additions and 11 deletions

1
.gitignore vendored
View File

@ -25,3 +25,4 @@ Thumbs.db
bower_components
.eslintignore
.eslintrc
public/js/bundle.js

View File

@ -148,7 +148,7 @@ exports.returnIndividualStory = function(req, res, next) {
upVotes: story.upVotes,
comments: story.comments,
id: story._id,
user: req.user,
user: req.user || null,
timeAgo: moment(story.timePosted).fromNow(),
image: story.image,
page: 'show',
@ -227,6 +227,9 @@ exports.comments = function(req, res, next) {
};
exports.newStory = function(req, res) {
if (!req.user) {
return res.status(500);
}
var url = req.body.data.url;
var cleanURL = sanitizeHtml(url, {
allowedTags: [],
@ -284,6 +287,9 @@ exports.newStory = function(req, res) {
exports.storySubmission = function(req, res) {
var data = req.body.data;
if (req.user._id.toString() !== data.author.userId.toString()) {
return res.status(500);
}
var storyLink = data.headline
.replace(/\'/g, '')
.replace(/\"/g, '')
@ -327,6 +333,9 @@ exports.storySubmission = function(req, res) {
exports.commentSubmit = function(req, res) {
var data = req.body.data;
if (req.user._id.toString() !== data.author.userId.toString()) {
return res.status(500);
}
var sanitizedBody = sanitizeHtml(data.body,
{
allowedTags: [],
@ -353,6 +362,11 @@ exports.commentSubmit = function(req, res) {
exports.commentOnCommentSubmit = function(req, res) {
var data = req.body.data;
if (req.user._id.toString() !== data.author.userId.toString()) {
return res.status(500);
}
var sanitizedBody = sanitizeHtml(data.body,
{
allowedTags: [],

View File

@ -33,6 +33,9 @@ editor.setOption("extraKeys", {
cm.replaceSelection(spaces);
}
},
"Ctrl-Enter": function() {
bonfireExecute();
return false;

View File

@ -21,6 +21,7 @@
success: function (data, textStatus, xhr) {
commentDetails = data;
var div = document.createElement('div');
$(div)
.html(
'<div class="media media-news">' +
@ -55,6 +56,9 @@
sentinel--;
if (!sentinel) {
$('.comment-a-comment').on('click', 'a', function () {
if (!user) {
return;
}
$(this).unbind('click');
$('.comment-to-comment-formgroup').empty();
$('#initial-comment-submit').addClass('hidden-element');

View File

@ -42,22 +42,23 @@
span &thinsp;by&thinsp;
a(href="/" + author.username) @#{author.username}
.col-xs-12#reply-area
.hidden-element#initial-comment-submit
form.form-horizontal.control-label-story-submission
.col-xs-12
.input-group
input#comment-box.big-text-field.field-responsive.form-control(type='text', placeholder='Enter your reply', autofocus)
span.input-group-btn
button#comment-button.btn.btn-big.btn-primary.btn-responsive(type='button') Send
span.spacer.pull-left#textarea_feedback
if (user !== null)
.col-xs-12#reply-area
.hidden-element#initial-comment-submit
form.form-horizontal.control-label-story-submission
.col-xs-12
.input-group
input#comment-box.big-text-field.field-responsive.form-control(type='text', placeholder='Enter your reply', autofocus)
span.input-group-btn
button#comment-button.btn.btn-big.btn-primary.btn-responsive(type='button') Send
span.spacer.pull-left#textarea_feedback
script.
if (image) {
$('#image-display').removeClass('hidden-element')
}
$('#reply-to-main-post').on('click', function() {
if (!user) return;
$('#initial-comment-submit').removeClass('hidden-element');
$(this).unbind('click');
$('.comment-to-comment-formgroup').empty();