# HG changeset patch # User Chris Cannam # Date 1301479536 -3600 # Node ID 7f5bd8f2d79b5edfd61bbe91b480af7a9b49635a # Parent 9e5fc43c12a65836918b6586467ac8facb7d0dc7# Parent 7acd282bee3ce6f8ec186cff3d3b3cd5e10dba9c Merge diff -r 9e5fc43c12a6 -r 7f5bd8f2d79b app/controllers/welcome_controller.rb --- a/app/controllers/welcome_controller.rb Tue Mar 29 18:06:56 2011 +0100 +++ b/app/controllers/welcome_controller.rb Wed Mar 30 11:05:36 2011 +0100 @@ -18,6 +18,9 @@ class WelcomeController < ApplicationController caches_action :robots + include ProjectsHelper + helper :projects + def index @news = News.latest User.current @projects = Project.latest User.current diff -r 9e5fc43c12a6 -r 7f5bd8f2d79b app/helpers/projects_helper.rb --- a/app/helpers/projects_helper.rb Tue Mar 29 18:06:56 2011 +0100 +++ b/app/helpers/projects_helper.rb Wed Mar 30 11:05:36 2011 +0100 @@ -48,6 +48,16 @@ options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) content_tag('select', options, :name => 'project[parent_id]', :id => 'project_parent_id') end + + def render_project_short_description(project) + s = '' + if (project.short_description) + s << "
" + s << textilizable(project.short_description, :project => project).gsub(/<[^>]+>/, '') + s << "
" + end + s + end # Renders a tree of projects as a nested set of unordered lists # The given collection may be a subset of the whole project tree @@ -73,7 +83,7 @@ classes = (ancestors.empty? ? 'root' : 'child') s << "
  • " + link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}") - s << "
    #{textilizable(project.short_description, :project => project)}
    " unless project.description.blank? + s << render_project_short_description(project) s << "
    \n" ancestors << project end @@ -127,8 +137,7 @@ else s << " " << l("field_is_private") << "" end - desc = textilizable(project.short_description, :project => project).gsub(/<[^>]+>/, '') - s << "
    #{desc}
    " unless project.description.blank? + s << render_project_short_description(project) s << "\n" ancestors << project end @@ -199,11 +208,7 @@ s << " no_description" if project.description.blank? s << "'>" << link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}"); s << "" - unless project.description.blank? - s << "
    " - s << textilizable(project.short_description, :project => project).gsub(/<[^>]+>/, '') - s << "
    " - end + s << render_project_short_description(project) s << "" diff -r 9e5fc43c12a6 -r 7f5bd8f2d79b app/models/project.rb --- a/app/models/project.rb Tue Mar 29 18:06:56 2011 +0100 +++ b/app/models/project.rb Wed Mar 30 11:05:36 2011 +0100 @@ -423,13 +423,20 @@ # Returns a short description of the projects (first lines) def short_description(length = 255) + + ## 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 + ## no text formatting. + ## 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. + + ## That can leave too much text 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 diff -r 9e5fc43c12a6 -r 7f5bd8f2d79b app/views/welcome/index.rhtml --- a/app/views/welcome/index.rhtml Tue Mar 29 18:06:56 2011 +0100 +++ b/app/views/welcome/index.rhtml Wed Mar 30 11:05:36 2011 +0100 @@ -33,9 +33,9 @@