summaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2014-02-06 03:33:33 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2014-02-06 03:33:33 +0000
commitae7a4b9678dedbdfae0c62d9cc84667ef7388866 (patch)
tree65e91f487a6d3bb1184a3f2e632777c45284fccb /app/helpers
parente4d152e84a0f77fa0484d16c86022097ff31e2fb (diff)
downloadredmine-ae7a4b9678dedbdfae0c62d9cc84667ef7388866.tar.gz
redmine-ae7a4b9678dedbdfae0c62d9cc84667ef7388866.zip
Rails4: add ApplicationHelper#truncate_single_line_raw method replacing truncate_single_line
git-svn-id: http://svn.redmine.org/redmine/trunk@12830 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 54852abf5..e2e3349ed 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -224,7 +224,7 @@ module ApplicationHelper
end
def format_activity_title(text)
- h(truncate_single_line(text, :length => 100))
+ h(truncate_single_line_raw(text, 100))
end
def format_activity_day(date)
@@ -397,9 +397,17 @@ module ApplicationHelper
# Truncates and returns the string as a single line
def truncate_single_line(string, *args)
+ ActiveSupport::Deprecation.warn(
+ "ApplicationHelper#truncate_single_line is deprecated and will be removed in Rails 4 poring")
+ # Rails 4 ActionView::Helpers::TextHelper#truncate escapes.
+ # So, result is broken.
truncate(string.to_s, *args).gsub(%r{[\r\n]+}m, ' ')
end
+ def truncate_single_line_raw(string, length)
+ string.truncate(length).gsub(%r{[\r\n]+}m, ' ')
+ end
+
# Truncates at line break after 250 characters or options[:length]
def truncate_lines(string, options={})
length = options[:length] || 250
@@ -759,7 +767,7 @@ module ApplicationHelper
:repository_id => repository.identifier_param,
:rev => changeset.revision},
:class => 'changeset',
- :title => truncate_single_line(changeset.comments, :length => 100))
+ :title => truncate_single_line_raw(changeset.comments, 100))
end
end
elsif sep == '#'
@@ -841,7 +849,7 @@ module ApplicationHelper
if repository && (changeset = Changeset.visible.where("repository_id = ? AND scmid LIKE ?", repository.id, "#{name}%").first)
link = link_to h("#{project_prefix}#{repo_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.identifier},
:class => 'changeset',
- :title => truncate_single_line(changeset.comments, :length => 100)
+ :title => truncate_single_line_raw(changeset.comments, 100)
end
else
if repository && User.current.allowed_to?(:browse_repository, project)