Fixing broken reply interaction with links.

This commit is contained in:
Samuel Clay 2013-01-03 17:56:01 -08:00
parent 40fa172edc
commit f9ae4baefe
5 changed files with 23 additions and 15 deletions

View file

@ -2291,7 +2291,7 @@ class MInteraction(mongo.Document):
'user_id': user_id,
'with_user_id': reply_user_id,
'category': 'comment_reply',
'content': reply_content,
'content': linkify(strip_tags(reply_content)),
'feed_id': "social:%s" % user_id,
'story_feed_id': story_feed_id,
'title': story_title,
@ -2302,7 +2302,7 @@ class MInteraction(mongo.Document):
original = cls.objects.filter(**params).limit(1)
if original:
original = original[0]
original.content = reply_content
original.content = linkify(strip_tags(reply_content))
original.save()
else:
original_message = None
@ -2316,7 +2316,7 @@ class MInteraction(mongo.Document):
'user_id': user_id,
'with_user_id': reply_user_id,
'category': 'comment_reply',
'content': reply_content,
'content': linkify(strip_tags(reply_content)),
'feed_id': "social:%s" % user_id,
'story_feed_id': story_feed_id,
'content_id': story_id,
@ -2342,7 +2342,7 @@ class MInteraction(mongo.Document):
'user_id': user_id,
'with_user_id': reply_user_id,
'category': 'reply_reply',
'content': reply_content,
'content': linkify(strip_tags(reply_content)),
'feed_id': "social:%s" % comment_user_id,
'story_feed_id': story_feed_id,
'title': story_title,
@ -2367,7 +2367,7 @@ class MInteraction(mongo.Document):
'user_id': user_id,
'with_user_id': reply_user_id,
'category': 'reply_reply',
'content': reply_content,
'content': linkify(strip_tags(reply_content)),
'feed_id': "social:%s" % comment_user_id,
'story_feed_id': story_feed_id,
'content_id': story_id,
@ -2514,7 +2514,7 @@ class MActivity(mongo.Document):
'user_id': user_id,
'with_user_id': comment_user_id,
'category': 'comment_reply',
'content': reply_content,
'content': linkify(strip_tags(reply_content)),
'feed_id': "social:%s" % comment_user_id,
'story_feed_id': story_feed_id,
'title': story_title,
@ -2525,7 +2525,7 @@ class MActivity(mongo.Document):
original = cls.objects.filter(**params).limit(1)
if original:
original = original[0]
original.content = reply_content
original.content = linkify(strip_tags(reply_content))
original.save()
else:
original_message = None
@ -2539,7 +2539,7 @@ class MActivity(mongo.Document):
'user_id': user_id,
'with_user_id': comment_user_id,
'category': 'comment_reply',
'content': reply_content,
'content': linkify(strip_tags(reply_content)),
'feed_id': "social:%s" % comment_user_id,
'story_feed_id': story_feed_id,
'content_id': story_id,

View file

@ -15,9 +15,14 @@ NEWSBLUR.Models.Comment = Backbone.Model.extend({
},
strip_html_in_comments: function() {
this.attributes['comments'] = this.get('comments').replace(/<\/?[^>]+(>|$)/g, "");
this.attributes['comments'] = this.strip_html(this.get('comments'));
},
strip_html: function(html) {
return html.replace(/<\/?[^>]+(>|$)/g, "");
}
});
NEWSBLUR.Collections.Comments = Backbone.Collection.extend({
@ -30,7 +35,9 @@ NEWSBLUR.Collections.Comments = Backbone.Collection.extend({
NEWSBLUR.Models.CommentReply = Backbone.Model.extend({
stripped_comments: function() {
return NEWSBLUR.Models.Comment.prototype.strip_html(this.get('comments'));
}
});

View file

@ -56,11 +56,11 @@ NEWSBLUR.Views.SocialPageComment = Backbone.View.extend({
$error.text("You must be following " + NEWSBLUR.Globals.blurblog_username + " to reply");
return;
}
var reply_comments = options.reply && options.reply.stripped_comments();
var $form = $.make('div', { className: 'NB-story-comment-reply NB-story-comment-reply-form' }, [
$.make('img', { className: 'NB-story-comment-reply-photo', src: current_user.get('photo_url') }),
$.make('div', { className: 'NB-story-comment-username NB-story-comment-reply-username' }, current_user.get('username')),
$.make('input', { type: 'text', className: 'NB-input NB-story-comment-reply-comments', value: options.reply && options.reply.get("comments") }),
$.make('input', { type: 'text', className: 'NB-input NB-story-comment-reply-comments', value: reply_comments }),
$.make('div', { className: 'NB-modal-submit-button NB-modal-submit-green' }, options.is_editing ? 'Save' : 'Post'),
(options.is_editing && $.make('div', { className: 'NB-modal-submit-button NB-modal-submit-delete' }, 'Delete'))
]);

View file

@ -141,11 +141,12 @@ NEWSBLUR.Views.StoryComment = Backbone.View.extend({
$error.text("You must be following " + this.user.get('username') + " to reply");
return;
}
var reply_comments = options.reply && options.reply.stripped_comments();
var $form = $.make('div', { className: 'NB-story-comment-reply NB-story-comment-reply-form' }, [
$.make('img', { className: 'NB-story-comment-reply-photo', src: current_user.get('photo_url') }),
$.make('div', { className: 'NB-story-comment-username NB-story-comment-reply-username' }, current_user.get('username')),
$.make('input', { type: 'text', className: 'NB-input NB-story-comment-reply-comments', value: options.reply && options.reply.get("comments") }),
$.make('input', { type: 'text', className: 'NB-input NB-story-comment-reply-comments', value: reply_comments }),
$.make('div', { className: 'NB-modal-submit-button NB-modal-submit-green' }, options.is_editing ? 'Save' : 'Post'),
(options.is_editing && $.make('div', { className: 'NB-modal-submit-button NB-modal-submit-delete' }, 'Delete'))
]);

View file

@ -52,7 +52,7 @@
{{ username }} replied to <span class="NB-interaction-username NB-splash-link" data-user-id="{{ activity.with_user_id }}">{{ activity.with_user.username }}</span>:
</div>
<div class="NB-interaction-content">
"<span class="NB-interaction-reply-content NB-splash-link" data-story-id="{{ activity.content_id }}">{{ activity.content|truncatewords:16 }}</span>"
"<span class="NB-interaction-reply-content NB-splash-link" data-story-id="{{ activity.content_id }}">{{ activity.content|safe|truncatewords:16 }}</span>"
</div>
{% endif %}