From c502a60cd16d8ae64710c9b1c22b2fadf7ed3e51 Mon Sep 17 00:00:00 2001 From: jordan Date: Wed, 6 Apr 2011 16:51:31 +0000 Subject: [PATCH] SPLUNK-196, making filtration to the summary and headline properties of the Node model, removing multiple spaces and new lines breaks, we don't need them and they cause trouble to the title attribute of the tag. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@937 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/models/node.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/forum/models/node.py b/forum/models/node.py index 0ebcd21..a71ae47 100644 --- a/forum/models/node.py +++ b/forum/models/node.py @@ -43,7 +43,12 @@ class NodeContent(models.Model): @property def headline(self): - return self.title + title = self.title + + # Replaces multiple spaces with single ones. + title = re.sub(' +',' ', title) + + return title def tagname_list(self): if self.tagnames: @@ -309,7 +314,15 @@ class Node(BaseModel, NodeContent): @property def summary(self): - return strip_tags(self.html)[:SUMMARY_LENGTH] + content = strip_tags(self.html)[:SUMMARY_LENGTH] + + # Remove multiple spaces. + content = re.sub(' +',' ', content) + + # Remove line breaks. We don't need them at all. + content = content.replace("\n", '') + + return content @models.permalink def get_revisions_url(self): -- 2.39.5