Commit 4db45b8c authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Fixed: changesets titles should not be multiline in atom feeds (#1356).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1491 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 735db3da
...@@ -90,6 +90,11 @@ module ApplicationHelper ...@@ -90,6 +90,11 @@ module ApplicationHelper
include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format) include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format)
end end
# Truncates and returns the string as a single line
def truncate_single_line(string, *args)
truncate(string, *args).gsub(%r{[\r\n]+}m, ' ')
end
def html_hours(text) def html_hours(text)
text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>') text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>')
end end
...@@ -301,7 +306,7 @@ module ApplicationHelper ...@@ -301,7 +306,7 @@ module ApplicationHelper
if project && (changeset = project.changesets.find_by_revision(oid)) if project && (changeset = project.changesets.find_by_revision(oid))
link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid}, link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid},
:class => 'changeset', :class => 'changeset',
:title => truncate(changeset.comments, 100)) :title => truncate_single_line(changeset.comments, 100))
end end
elsif sep == '#' elsif sep == '#'
oid = oid.to_i oid = oid.to_i
...@@ -340,7 +345,9 @@ module ApplicationHelper ...@@ -340,7 +345,9 @@ module ApplicationHelper
end end
when 'commit' when 'commit'
if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"])) if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"]))
link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision}, :class => 'changeset', :title => truncate(changeset.comments, 100) link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
:class => 'changeset',
:title => truncate_single_line(changeset.comments, 100)
end end
when 'source', 'export' when 'source', 'export'
if project && project.repository if project && project.repository
......
...@@ -21,6 +21,10 @@ module ProjectsHelper ...@@ -21,6 +21,10 @@ module ProjectsHelper
link_to h(version.name), { :controller => 'versions', :action => 'show', :id => version }, options link_to h(version.name), { :controller => 'versions', :action => 'show', :id => version }, options
end end
def format_activity_title(text)
h(truncate_single_line(text, 100))
end
def format_activity_day(date) def format_activity_day(date)
date == Date.today ? l(:label_today).titleize : format_date(date) date == Date.today ? l(:label_today).titleize : format_date(date)
end end
......
xml.instruct! xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
xml.title @title xml.title truncate_single_line(@title, 100)
xml.link "rel" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false})) xml.link "rel" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false}))
xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false) xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
xml.id url_for(:controller => 'welcome', :only_path => false) xml.id url_for(:controller => 'welcome', :only_path => false)
...@@ -10,7 +10,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do ...@@ -10,7 +10,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
@items.each do |item| @items.each do |item|
xml.entry do xml.entry do
url = url_for(item.event_url(:only_path => false)) url = url_for(item.event_url(:only_path => false))
xml.title truncate(item.event_title, 100) xml.title truncate_single_line(item.event_title, 100)
xml.link "rel" => "alternate", "href" => url xml.link "rel" => "alternate", "href" => url
xml.id url xml.id url
xml.updated item.event_datetime.xmlschema xml.updated item.event_datetime.xmlschema
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
<dl> <dl>
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> <% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
<dt class="<%= e.event_type %>"><span class="time"><%= format_time(e.event_datetime, false) %></span> <dt class="<%= e.event_type %>"><span class="time"><%= format_time(e.event_datetime, false) %></span>
<%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %> <%= link_to h(truncate(e.event_title, 100)), e.event_url %></dt> <%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %>
<%= link_to format_activity_title(e.event_title), e.event_url %></dt>
<dd><span class="description"><%= format_activity_description(e.event_description) %></span> <dd><span class="description"><%= format_activity_description(e.event_description) %></span>
<span class="author"><%= e.event_author if e.respond_to?(:event_author) %></span></dd> <span class="author"><%= e.event_author if e.respond_to?(:event_author) %></span></dd>
<% end -%> <% end -%>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment