# HG changeset patch # User Chris Cannam # Date 1295275629 0 # Node ID db0caa9f0ff46bd671b52b22eb8cbb7e7fc3655f # Parent 8a205cc048de0368bdc2d43bec0a4d40045aec4d Make project descriptions briefer on the projects list, and ensure that images &c are removed from them diff -r 8a205cc048de -r db0caa9f0ff4 app/models/project.rb --- a/app/models/project.rb Thu Jan 06 10:41:19 2011 +0000 +++ b/app/models/project.rb Mon Jan 17 14:47:09 2011 +0000 @@ -418,7 +418,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