changeset 1215:2101a7c906b3 cannam

Fix failure to truncate long descriptions without carriage returns in them correctly
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Tue, 12 Mar 2013 10:29:50 +0000
parents c212850aec6e
children 05ce7de07fef
files app/models/project.rb
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/app/models/project.rb	Tue Mar 12 10:21:45 2013 +0000
+++ b/app/models/project.rb	Tue Mar 12 10:29:50 2013 +0000
@@ -473,7 +473,7 @@
   end
 
   # Returns a short description of the projects (first lines)
-  def short_description(length = 255)
+  def short_description(length = 200)
 
     ## The short description is used in lists, e.g. Latest projects,
     ## My projects etc.  It should be no more than a line or two with
@@ -488,7 +488,7 @@
     ## 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
+    description.gsub(/![^\s]+!/, '').gsub(/^(\s*[^\n\r]*).*$/m, '\1').gsub(/^(.{#{length}}[^\.;:,-]*).*$/m, '\1 ...').strip if description
   end
 
   def css_classes