comparison app/models/project.rb @ 130:db0caa9f0ff4 cannam-pre-20110113-merge

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 94944d00e43c
children 05f9a2a9c753
comparison
equal deleted inserted replaced
114:8a205cc048de 130:db0caa9f0ff4
416 name 416 name
417 end 417 end
418 418
419 # Returns a short description of the projects (first lines) 419 # Returns a short description of the projects (first lines)
420 def short_description(length = 255) 420 def short_description(length = 255)
421 description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description 421 ## Original Redmine code: this truncates to the CR that is more
422 ## than "length" characters from the start.
423 # description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
424 ## That's too much for us, and also we want to omit images and the
425 ## like. Truncate instead to the first CR that follows _any_
426 ## non-blank text, and to the next word break beyond "length"
427 ## characters if the result is still longer than that.
428 description.gsub(/![^\s]+!/, '').gsub(/^(\s*[^\n\r]*).*$/m, '\1').gsub(/^(.{#{length}}\b).*$/m, '\1 ...').strip if description
422 end 429 end
423 430
424 def css_classes 431 def css_classes
425 s = 'project' 432 s = 'project'
426 s << ' root' if root? 433 s << ' root' if root?