From f1aa0df32666931f58b34a21d2e7acf43271fc7a Mon Sep 17 00:00:00 2001
From: Jean-Philippe Lang ' + l(:label_export_to), block.binding)
+ yield Redmine::Views::OtherFormatsBuilder.new(self)
+ concat('
- <%= l(:label_export_to) %>
- <%= link_to 'Atom', {:controller => 'projects', :action => 'activity', :id => nil, :user_id => @user, :format => :atom, :key => User.current.rss_key}, :class => 'feed' %>
-
-<%= l(:label_export_to) %>
-<%= link_to 'Atom', {:controller => 'projects', :action => 'activity', :id => @project, :format => 'atom', :show_messages => 1, :key => User.current.rss_key},
- :class => 'feed' %>
-
-<%= l(:label_export_to) %>
-<%= link_to 'PDF', @gantt.params.merge(:format => 'pdf'), :class => 'pdf' %>
-<% if @gantt.respond_to?('to_image') %>
-<%= link_to 'PNG', @gantt.params.merge(:format => 'png'), :class => 'image' %>
+<% other_formats_links do |f| %>
+ <%= f.link_to 'PDF', :url => @gantt.params %>
+ <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
<% end %>
- <%= pagination_links_full @issue_pages, @issue_count %>
-<%= l(:label_export_to) %>
-<%= link_to 'Atom', {:query_id => @query, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %>
-<%= link_to 'CSV', {:format => 'csv'}, :class => 'csv' %>
-<%= link_to 'PDF', {:format => 'pdf'}, :class => 'pdf' %>
-
-<%= l(:label_export_to) %>
-<%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %>
-<%= link_to 'PDF', {:format => 'pdf'}, :class => 'pdf' %>
- <%= pagination_links_full @news_pages %>
-<%= l(:label_export_to) %>
-<%= link_to 'Atom', {:project_id => @project, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %>
-
- <%= l(:label_export_to) %>
- <%= link_to 'Atom', params.merge(:format => :atom, :from => nil, :key => User.current.rss_key), :class => 'feed' %>
-
-<%= l(:label_export_to) %> -<%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> -
+<% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> +<% end %> <% html_title(l(:label_project_plural)) -%> diff --git a/app/views/repositories/diff.rhtml b/app/views/repositories/diff.rhtml index 52a5d6057..86102cc52 100644 --- a/app/views/repositories/diff.rhtml +++ b/app/views/repositories/diff.rhtml @@ -15,10 +15,9 @@ <%= render :partial => 'common/diff', :locals => {:diff => @diff, :diff_type => @diff_type} %> <% end -%> --<%= l(:label_export_to) %> -<%= link_to 'Unified diff', params.merge(:format => 'diff') %> -
+<% other_formats_links do |f| %> + <%= f.link_to 'Diff', :url => params, :caption => 'Unified diff' %> +<% end %> <% html_title(with_leading_slash(@path), 'Diff') -%> diff --git a/app/views/repositories/revisions.rhtml b/app/views/repositories/revisions.rhtml index 8da7d582d..c06c204cd 100644 --- a/app/views/repositories/revisions.rhtml +++ b/app/views/repositories/revisions.rhtml @@ -16,9 +16,8 @@ <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> <% end %> --<%= l(:label_export_to) %> -<%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> -
+<% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> +<% end %> <% html_title(l(:label_revision_plural)) -%> diff --git a/app/views/repositories/show.rhtml b/app/views/repositories/show.rhtml index 280ae3bdd..943fe9485 100644 --- a/app/views/repositories/show.rhtml +++ b/app/views/repositories/show.rhtml @@ -22,10 +22,10 @@ <% content_for :header_tags do %> <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :action => 'revisions', :id => @project, :page => nil, :key => User.current.rss_key})) %> <% end %> --<%= l(:label_export_to) %> -<%= link_to 'Atom', {:action => 'revisions', :id => @project, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> -
+ +<% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:action => 'revisions', :id => @project, :key => User.current.rss_key} %> +<% end %> <% end %> <% content_for :header_tags do %> diff --git a/app/views/timelog/details.rhtml b/app/views/timelog/details.rhtml index b2aeb86bb..d78b384fd 100644 --- a/app/views/timelog/details.rhtml +++ b/app/views/timelog/details.rhtml @@ -22,11 +22,10 @@ already in the URI %> <%= render :partial => 'list', :locals => { :entries => @entries }%><%= pagination_links_full @entry_pages, @entry_count %>
--<%= l(:label_export_to) %> -<%= link_to 'Atom', {:issue_id => @issue, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> -<%= link_to 'CSV', params.merge(:format => 'csv'), :class => 'csv' %> -
+<% 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 %> +<% end %> <% end %> <% html_title l(:label_spent_time), l(:label_details) %> diff --git a/app/views/timelog/report.rhtml b/app/views/timelog/report.rhtml index ad7d79459..f41a1b51a 100644 --- a/app/views/timelog/report.rhtml +++ b/app/views/timelog/report.rhtml @@ -65,10 +65,9 @@ --<%= l(:label_export_to) %> -<%= link_to 'CSV', params.merge({:format => 'csv'}), :class => 'csv' %> -
+<% other_formats_links do |f| %> + <%= f.link_to 'CSV', :url => params %> +<% end %> <% end %> <% end %> diff --git a/app/views/wiki/show.rhtml b/app/views/wiki/show.rhtml index 1cb67dfd4..7abfd8a28 100644 --- a/app/views/wiki/show.rhtml +++ b/app/views/wiki/show.rhtml @@ -42,11 +42,10 @@ <% end %> <% end %> --<%= l(:label_export_to) %> -<%= link_to 'HTML', {:page => @page.title, :export => 'html', :version => @content.version}, :class => 'html' %> -<%= link_to 'TXT', {:page => @page.title, :export => 'txt', :version => @content.version}, :class => 'text' %> -
+<% other_formats_links do |f| %> + <%= f.link_to 'HTML', :url => {:page => @page.title, :version => @content.version} %> + <%= f.link_to 'TXT', :url => {:page => @page.title, :version => @content.version} %> +<% end %> <% content_for :header_tags do %> <%= stylesheet_link_tag 'scm' %> diff --git a/app/views/wiki/special_date_index.rhtml b/app/views/wiki/special_date_index.rhtml index 6717ebc85..008f89293 100644 --- a/app/views/wiki/special_date_index.rhtml +++ b/app/views/wiki/special_date_index.rhtml @@ -18,11 +18,10 @@ <% end %> <% unless @pages.empty? %> --<%= l(:label_export_to) %> -<%= link_to 'Atom', {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_pages => 1, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> -<%= link_to 'HTML', {:action => 'special', :page => 'export'}, :class => 'html' %> -
+<% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_pages => 1, :key => User.current.rss_key} %> + <%= f.link_to 'HTML', :url => {:action => 'special', :page => 'export'} %> +<% end %> <% end %> <% content_for :header_tags do %> diff --git a/app/views/wiki/special_page_index.rhtml b/app/views/wiki/special_page_index.rhtml index 72b395ef7..5547f5b1c 100644 --- a/app/views/wiki/special_page_index.rhtml +++ b/app/views/wiki/special_page_index.rhtml @@ -11,11 +11,10 @@ <% end %> <% unless @pages.empty? %> --<%= l(:label_export_to) %> -<%= link_to 'Atom', {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_pages => 1, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> -<%= link_to 'HTML', {:action => 'special', :page => 'export'} %> -
+<% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_pages => 1, :key => User.current.rss_key} %> + <%= f.link_to 'HTML', :url => {:action => 'special', :page => 'export'} %> +<% end %> <% end %> <% content_for :header_tags do %> diff --git a/lib/redmine/views/other_formats_builder.rb b/lib/redmine/views/other_formats_builder.rb new file mode 100644 index 000000000..1f5751691 --- /dev/null +++ b/lib/redmine/views/other_formats_builder.rb @@ -0,0 +1,33 @@ +# Redmine - project management software +# Copyright (C) 2006-2009 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +module Redmine + module Views + class OtherFormatsBuilder + def initialize(view) + @view = view + end + + def link_to(name, options={}) + url = { :format => name.to_s.downcase }.merge(options.delete(:url) || {}) + caption = options.delete(:caption) || name + html_options = { :class => name.to_s.downcase }.merge(options) + @view.content_tag('span', @view.link_to(caption, url, html_options)) + end + end + end +end diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 150aaf7d4..1b453966c 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -307,7 +307,7 @@ div.attachments span.author { font-size: 0.9em; color: #888; } p.other-formats { text-align: right; font-size:0.9em; color: #666; } .other-formats span + span:before { content: "| "; } -a.feed { background: url(../images/feed.png) no-repeat 1px 50%; padding: 2px 0px 3px 16px; } +a.atom { background: url(../images/feed.png) no-repeat 1px 50%; padding: 2px 0px 3px 16px; } /***** Flash & error messages ****/ #errorExplanation, div.flash, .nodata, .warning {