Mercurial > hg > soundsoftware-site
comparison app/models/project.rb @ 335:7acd282bee3c cannam-pre-20110113-merge
Introduce render_project_short_description into projects helper; use it in welcome page (latest projects) as well as project lists, to avoid text formatting appearing in these lists
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Wed, 30 Mar 2011 11:05:16 +0100 |
parents | 05f9a2a9c753 |
children | 350acce374a2 |
comparison
equal
deleted
inserted
replaced
332:e665cc1fdf07 | 335:7acd282bee3c |
---|---|
421 name | 421 name |
422 end | 422 end |
423 | 423 |
424 # Returns a short description of the projects (first lines) | 424 # Returns a short description of the projects (first lines) |
425 def short_description(length = 255) | 425 def short_description(length = 255) |
426 | |
427 ## The short description is used in lists, e.g. Latest projects, | |
428 ## My projects etc. It should be no more than a line or two with | |
429 ## no text formatting. | |
430 | |
426 ## Original Redmine code: this truncates to the CR that is more | 431 ## Original Redmine code: this truncates to the CR that is more |
427 ## than "length" characters from the start. | 432 ## than "length" characters from the start. |
428 # description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description | 433 # description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description |
429 ## That's too much for us, and also we want to omit images and the | 434 |
430 ## like. Truncate instead to the first CR that follows _any_ | 435 ## That can leave too much text for us, and also we want to omit |
431 ## non-blank text, and to the next word break beyond "length" | 436 ## images and the like. Truncate instead to the first CR that |
432 ## characters if the result is still longer than that. | 437 ## follows _any_ non-blank text, and to the next word break beyond |
438 ## "length" characters if the result is still longer than that. | |
439 ## | |
433 description.gsub(/![^\s]+!/, '').gsub(/^(\s*[^\n\r]*).*$/m, '\1').gsub(/^(.{#{length}}\b).*$/m, '\1 ...').strip if description | 440 description.gsub(/![^\s]+!/, '').gsub(/^(\s*[^\n\r]*).*$/m, '\1').gsub(/^(.{#{length}}\b).*$/m, '\1 ...').strip if description |
434 end | 441 end |
435 | 442 |
436 def css_classes | 443 def css_classes |
437 s = 'project' | 444 s = 'project' |