From 9131cdf6b91bb4585b341b54f6ddd6e7eb03d2e1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 22 Sep 2008 19:50:10 +0000 Subject: [PATCH] Truncate comments on changeset list. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1900 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/repositories_helper.rb | 6 ++++++ app/views/repositories/_revisions.rhtml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 1a82bb8ce..d41977d29 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -22,6 +22,12 @@ module RepositoriesHelper txt.to_s[0,8] end + def truncate_at_line_break(text, length = 255) + if text + text.gsub(%r{^(.{#{length}}[^\n]*)\n.+$}m, '\\1...') + end + end + def render_properties(properties) unless properties.nil? || properties.empty? content = '' diff --git a/app/views/repositories/_revisions.rhtml b/app/views/repositories/_revisions.rhtml index a938fecb8..d8ca8007a 100644 --- a/app/views/repositories/_revisions.rhtml +++ b/app/views/repositories/_revisions.rhtml @@ -18,7 +18,7 @@ <%= radio_button_tag('rev_to', changeset.revision, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('cb-#{line_num}').checked==true) {$('cb-#{line_num-1}').checked=true;}") if show_diff && (line_num > 1) %> <%= format_time(changeset.committed_on) %> <%=h changeset.committer.to_s.split('<').first %> -<%= textilizable(changeset.comments) %> +<%= textilizable(truncate_at_line_break(changeset.comments)) %> <% line_num += 1 %> <% end %> -- 2.39.5