diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-07-10 19:18:12 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-07-10 19:18:12 +0000 |
commit | b2044e6dfc261656ee477fa0287c98bda3fa183d (patch) | |
tree | b9d50e229eb6d18ad97a05333c3c37c7ded692bd | |
parent | 731eadc4502f7fccc85dcc2ab4c29a9da4f5a415 (diff) | |
download | redmine-b2044e6dfc261656ee477fa0287c98bda3fa183d.tar.gz redmine-b2044e6dfc261656ee477fa0287c98bda3fa183d.zip |
Don't generate urls with params.
git-svn-id: http://svn.redmine.org/redmine/trunk@15631 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/views/activities/index.html.erb | 2 | ||||
-rw-r--r-- | app/views/gantts/show.html.erb | 4 | ||||
-rw-r--r-- | app/views/issues/index.html.erb | 6 | ||||
-rw-r--r-- | app/views/repositories/diff.html.erb | 2 | ||||
-rw-r--r-- | app/views/timelog/index.html.erb | 4 | ||||
-rw-r--r-- | lib/redmine/views/other_formats_builder.rb | 10 | ||||
-rw-r--r-- | test/integration/issues_test.rb | 2 |
7 files changed, 20 insertions, 10 deletions
diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb index 26613aef8..d939fdc79 100644 --- a/app/views/activities/index.html.erb +++ b/app/views/activities/index.html.erb @@ -38,7 +38,7 @@ </span> <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %> + <%= f.link_to_with_query_parameters 'Atom', 'from' => nil, :key => User.current.rss_key %> <% end %> <% content_for :header_tags do %> diff --git a/app/views/gantts/show.html.erb b/app/views/gantts/show.html.erb index 0f7092081..09a17b166 100644 --- a/app/views/gantts/show.html.erb +++ b/app/views/gantts/show.html.erb @@ -345,8 +345,8 @@ </table> <% other_formats_links do |f| %> - <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %> - <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %> + <%= f.link_to_with_query_parameters 'PDF', @gantt.params %> + <%= f.link_to_with_query_parameters('PNG', @gantt.params) if @gantt.respond_to?('to_image') %> <% end %> <% end # query.valid? %> diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index fd762023f..d120ce71e 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -76,9 +76,9 @@ <% end %> <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => params.merge(:key => User.current.rss_key) %> - <%= f.link_to 'CSV', :url => params, :onclick => "showModal('csv-export-options', '350px'); return false;" %> - <%= f.link_to 'PDF', :url => params %> + <%= f.link_to_with_query_parameters 'Atom', :key => User.current.rss_key %> + <%= f.link_to_with_query_parameters 'CSV', {}, :onclick => "showModal('csv-export-options', '350px'); return false;" %> + <%= f.link_to_with_query_parameters 'PDF' %> <% end %> <div id="csv-export-options" style="display:none;"> diff --git a/app/views/repositories/diff.html.erb b/app/views/repositories/diff.html.erb index 5d0b899a7..889a65f7e 100644 --- a/app/views/repositories/diff.html.erb +++ b/app/views/repositories/diff.html.erb @@ -21,7 +21,7 @@ <% end -%> <% other_formats_links do |f| %> - <%= f.link_to 'Diff', :url => params, :caption => 'Unified diff' %> + <%= f.link_to_with_query_parameters 'Diff', {}, :caption => 'Unified diff' %> <% end %> <% html_title(with_leading_slash(@path), 'Diff') -%> diff --git a/app/views/timelog/index.html.erb b/app/views/timelog/index.html.erb index a875e53af..b32e7092c 100644 --- a/app/views/timelog/index.html.erb +++ b/app/views/timelog/index.html.erb @@ -21,8 +21,8 @@ <span class="pagination"><%= pagination_links_full @entry_pages, @entry_count %></span> <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => params.merge({:issue_id => @issue, :key => User.current.rss_key}) %> - <%= f.link_to 'CSV', :url => params, :onclick => "showModal('csv-export-options', '330px'); return false;" %> + <%= f.link_to_with_query_parameters 'Atom', :key => User.current.rss_key %> + <%= f.link_to_with_query_parameters 'CSV', {}, :onclick => "showModal('csv-export-options', '330px'); return false;" %> <% end %> <div id="csv-export-options" style="display:none;"> diff --git a/lib/redmine/views/other_formats_builder.rb b/lib/redmine/views/other_formats_builder.rb index 48af0fbcb..4caee2142 100644 --- a/lib/redmine/views/other_formats_builder.rb +++ b/lib/redmine/views/other_formats_builder.rb @@ -28,6 +28,16 @@ module Redmine html_options = { :class => name.to_s.downcase, :rel => 'nofollow' }.merge(options) @view.content_tag('span', @view.link_to(caption, url, html_options)) end + + # Preserves query parameters + def link_to_with_query_parameters(name, url={}, options={}) + params = @view.request.query_parameters.except(:page, :format).except(*url.keys) + url = {:params => params, :page => nil, :format => name.to_s.downcase}.merge(url) + + caption = options.delete(:caption) || name + html_options = { :class => name.to_s.downcase, :rel => 'nofollow' }.merge(options) + @view.content_tag('span', @view.link_to(caption, url, html_options)) + end end end end diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb index 668f346d4..5cafcda4b 100644 --- a/test/integration/issues_test.rb +++ b/test/integration/issues_test.rb @@ -123,7 +123,7 @@ class IssuesTest < Redmine::IntegrationTest get '/issues', :project_id => 'ecookbook' %w(Atom PDF CSV).each do |format| - assert_select 'a[rel=nofollow][href=?]', "/projects/ecookbook/issues.#{format.downcase}", :text => format + assert_select 'a[rel=nofollow][href=?]', "/issues.#{format.downcase}?project_id=ecookbook", :text => format end end |