diff --git a/apps/social/models.py b/apps/social/models.py index 5c3bdfa51..b1f2195ad 100644 --- a/apps/social/models.py +++ b/apps/social/models.py @@ -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, diff --git a/media/js/newsblur/models/comments.js b/media/js/newsblur/models/comments.js index 420c565cf..83e1b8417 100644 --- a/media/js/newsblur/models/comments.js +++ b/media/js/newsblur/models/comments.js @@ -15,8 +15,13 @@ 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, ""); } + }); @@ -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')); + } }); diff --git a/media/js/newsblur/social_page/social_page_comment.js b/media/js/newsblur/social_page/social_page_comment.js index 180b197da..73ca5b63d 100644 --- a/media/js/newsblur/social_page/social_page_comment.js +++ b/media/js/newsblur/social_page/social_page_comment.js @@ -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')) ]); diff --git a/media/js/newsblur/views/story_comment_view.js b/media/js/newsblur/views/story_comment_view.js index a479cd8c7..176c7a95e 100644 --- a/media/js/newsblur/views/story_comment_view.js +++ b/media/js/newsblur/views/story_comment_view.js @@ -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')) ]); diff --git a/templates/reader/activities_module.xhtml b/templates/reader/activities_module.xhtml index 3c5ef33f8..a0da5c457 100644 --- a/templates/reader/activities_module.xhtml +++ b/templates/reader/activities_module.xhtml @@ -52,7 +52,7 @@ {{ username }} replied to {{ activity.with_user.username }}:
- "{{ activity.content|truncatewords:16 }}" + "{{ activity.content|safe|truncatewords:16 }}"
{% endif %}