changeset 122:7c628fc7e91d cannam

Make project descriptions briefer on the projects list, and ensure that images &c are removed from them
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Mon, 17 Jan 2011 14:47:09 +0000
parents 5abca4493163
children 605adf7e1735
files app/models/project.rb
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/models/project.rb	Mon Jan 17 13:37:10 2011 +0000
+++ b/app/models/project.rb	Mon Jan 17 14:47:09 2011 +0000
@@ -438,7 +438,14 @@
   
   # Returns a short description of the projects (first lines)
   def short_description(length = 255)
-    description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
+    ## Original Redmine code: this truncates to the CR that is more
+    ## than "length" characters from the start.
+    # description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
+    ## That's too much for us, and also we want to omit images and the
+    ## like.  Truncate instead to the first CR that follows _any_
+    ## non-blank text, and to the next word break beyond "length"
+    ## characters if the result is still longer than that.
+    description.gsub(/![^\s]+!/, '').gsub(/^(\s*[^\n\r]*).*$/m, '\1').gsub(/^(.{#{length}}\b).*$/m, '\1 ...').strip if description
   end
 
   def css_classes