From fe007d08b35834c07d1cc0cb96dc264e9c486315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 8 Dec 2014 00:23:53 +0100 Subject: [PATCH] FIX: remove links and html 'hellips' from topic/post summaries --- app/models/user_profile.rb | 6 +++--- lib/topic_view.rb | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/user_profile.rb b/app/models/user_profile.rb index 023d86504c8..2941b922334 100644 --- a/app/models/user_profile.rb +++ b/app/models/user_profile.rb @@ -10,8 +10,8 @@ class UserProfile < ActiveRecord::Base BAKED_VERSION = 1 - def bio_excerpt(length=350) - excerpt = PrettyText.excerpt(bio_cooked, length) + def bio_excerpt(length=350, opts={}) + excerpt = PrettyText.excerpt(bio_cooked, length, opts) return excerpt if excerpt.blank? || (user.has_trust_level?(TrustLevel[1]) && !user.suspended?) PrettyText.strip_links(excerpt) end @@ -23,7 +23,7 @@ class UserProfile < ActiveRecord::Base def bio_summary return nil unless bio_cooked.present? - bio_excerpt(500) + bio_excerpt(500, strip_links: true, text_entities: true) end def recook_bio diff --git a/lib/topic_view.rb b/lib/topic_view.rb index 83b59047b9e..526a8831d33 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -114,7 +114,8 @@ class TopicView def summary return nil if desired_post.blank? # TODO, this is actually quite slow, should be cached in the post table - desired_post.excerpt(500) + excerpt = desired_post.excerpt(500, strip_links: true, text_entities: true) + (excerpt || "").gsub(/\n/, ' ').strip end def image_url