##// END OF EJS Templates
Adds an helper to render other formats download links....
Jean-Philippe Lang -
r2331:f1aa0df32666
parent child
Show More
@@ -0,0 +1,33
1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 module Redmine
19 module Views
20 class OtherFormatsBuilder
21 def initialize(view)
22 @view = view
23 end
24
25 def link_to(name, options={})
26 url = { :format => name.to_s.downcase }.merge(options.delete(:url) || {})
27 caption = options.delete(:caption) || name
28 html_options = { :class => name.to_s.downcase }.merge(options)
29 @view.content_tag('span', @view.link_to(caption, url, html_options))
30 end
31 end
32 end
33 end
@@ -45,11 +45,11 class WikiController < ApplicationController
45 return
45 return
46 end
46 end
47 @content = @page.content_for_version(params[:version])
47 @content = @page.content_for_version(params[:version])
48 if params[:export] == 'html'
48 if params[:format] == 'html'
49 export = render_to_string :action => 'export', :layout => false
49 export = render_to_string :action => 'export', :layout => false
50 send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
50 send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
51 return
51 return
52 elsif params[:export] == 'txt'
52 elsif params[:format] == 'txt'
53 send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt")
53 send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt")
54 return
54 return
55 end
55 end
@@ -282,6 +282,12 module ApplicationHelper
282 elements = args.flatten
282 elements = args.flatten
283 elements.any? ? content_tag('p', args.join(' &#187; ') + ' &#187; ', :class => 'breadcrumb') : nil
283 elements.any? ? content_tag('p', args.join(' &#187; ') + ' &#187; ', :class => 'breadcrumb') : nil
284 end
284 end
285
286 def other_formats_links(&block)
287 concat('<p class="other-formats">' + l(:label_export_to), block.binding)
288 yield Redmine::Views::OtherFormatsBuilder.new(self)
289 concat('</p>', block.binding)
290 end
285
291
286 def html_title(*args)
292 def html_title(*args)
287 if args.empty?
293 if args.empty?
@@ -55,10 +55,9
55 <% end -%>
55 <% end -%>
56 </div>
56 </div>
57
57
58 <p class="other-formats">
58 <% other_formats_links do |f| %>
59 <%= l(:label_export_to) %>
59 <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => nil, :user_id => @user, :key => User.current.rss_key} %>
60 <%= link_to 'Atom', {:controller => 'projects', :action => 'activity', :id => nil, :user_id => @user, :format => :atom, :key => User.current.rss_key}, :class => 'feed' %>
60 <% end %>
61 </p>
62
61
63 <% content_for :header_tags do %>
62 <% content_for :header_tags do %>
64 <%= auto_discovery_link_tag(:atom, :controller => 'projects', :action => 'activity', :user_id => @user, :format => :atom, :key => User.current.rss_key) %>
63 <%= auto_discovery_link_tag(:atom, :controller => 'projects', :action => 'activity', :user_id => @user, :format => :atom, :key => User.current.rss_key) %>
@@ -29,11 +29,9
29 </tbody>
29 </tbody>
30 </table>
30 </table>
31
31
32 <p class="other-formats">
32 <% other_formats_links do |f| %>
33 <%= l(:label_export_to) %>
33 <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => @project, :show_messages => 1, :key => User.current.rss_key} %>
34 <span><%= link_to 'Atom', {:controller => 'projects', :action => 'activity', :id => @project, :format => 'atom', :show_messages => 1, :key => User.current.rss_key},
34 <% end %>
35 :class => 'feed' %></span>
36 </p>
37
35
38 <% content_for :header_tags do %>
36 <% content_for :header_tags do %>
39 <%= auto_discovery_link_tag(:atom, {:controller => 'projects', :action => 'activity', :id => @project, :format => 'atom', :show_messages => 1, :key => User.current.rss_key}) %>
37 <%= auto_discovery_link_tag(:atom, {:controller => 'projects', :action => 'activity', :id => @project, :format => 'atom', :show_messages => 1, :key => User.current.rss_key}) %>
@@ -241,13 +241,10 if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
241 </tr>
241 </tr>
242 </table>
242 </table>
243
243
244 <p class="other-formats">
244 <% other_formats_links do |f| %>
245 <%= l(:label_export_to) %>
245 <%= f.link_to 'PDF', :url => @gantt.params %>
246 <span><%= link_to 'PDF', @gantt.params.merge(:format => 'pdf'), :class => 'pdf' %></span>
246 <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
247 <% if @gantt.respond_to?('to_image') %>
248 <span><%= link_to 'PNG', @gantt.params.merge(:format => 'png'), :class => 'image' %></span>
249 <% end %>
247 <% end %>
250 </p>
251 <% end # query.valid? %>
248 <% end # query.valid? %>
252
249
253 <% content_for :sidebar do %>
250 <% content_for :sidebar do %>
@@ -44,12 +44,12
44 <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query} %>
44 <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query} %>
45 <p class="pagination"><%= pagination_links_full @issue_pages, @issue_count %></p>
45 <p class="pagination"><%= pagination_links_full @issue_pages, @issue_count %></p>
46
46
47 <p class="other-formats">
47 <% other_formats_links do |f| %>
48 <%= l(:label_export_to) %>
48 <%= f.link_to 'Atom', :url => {:query_id => (@query.new_record? ? nil : @query), :key => User.current.rss_key} %>
49 <span><%= link_to 'Atom', {:query_id => @query, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
49 <%= f.link_to 'CSV' %>
50 <span><%= link_to 'CSV', {:format => 'csv'}, :class => 'csv' %></span>
50 <%= f.link_to 'PDF' %>
51 <span><%= link_to 'PDF', {:format => 'pdf'}, :class => 'pdf' %></span>
51 <% end %>
52 </p>
52
53 <% end %>
53 <% end %>
54 <% end %>
54 <% end %>
55
55
@@ -108,11 +108,10 end %>
108 </div>
108 </div>
109 <% end %>
109 <% end %>
110
110
111 <p class="other-formats">
111 <% other_formats_links do |f| %>
112 <%= l(:label_export_to) %>
112 <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
113 <span><%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
113 <%= f.link_to 'PDF' %>
114 <span><%= link_to 'PDF', {:format => 'pdf'}, :class => 'pdf' %></span>
114 <% end %>
115 </p>
116
115
117 <% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
116 <% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
118
117
@@ -39,10 +39,9
39 <% end %>
39 <% end %>
40 <p class="pagination"><%= pagination_links_full @news_pages %></p>
40 <p class="pagination"><%= pagination_links_full @news_pages %></p>
41
41
42 <p class="other-formats">
42 <% other_formats_links do |f| %>
43 <%= l(:label_export_to) %>
43 <%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %>
44 <span><%= link_to 'Atom', {:project_id => @project, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
44 <% end %>
45 </p>
46
45
47 <% content_for :header_tags do %>
46 <% content_for :header_tags do %>
48 <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
47 <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
@@ -33,10 +33,9
33 :title => "#{l(:label_date_from)} #{format_date(@date_to)} #{l(:label_date_to).downcase} #{format_date(@date_to + @days - 1)}"}) unless @date_to >= Date.today %>
33 :title => "#{l(:label_date_from)} #{format_date(@date_to)} #{l(:label_date_to).downcase} #{format_date(@date_to + @days - 1)}"}) unless @date_to >= Date.today %>
34 </div>
34 </div>
35 &nbsp;
35 &nbsp;
36 <p class="other-formats">
36 <% other_formats_links do |f| %>
37 <%= l(:label_export_to) %>
37 <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %>
38 <%= link_to 'Atom', params.merge(:format => :atom, :from => nil, :key => User.current.rss_key), :class => 'feed' %>
38 <% end %>
39 </p>
40
39
41 <% content_for :header_tags do %>
40 <% content_for :header_tags do %>
42 <%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %>
41 <%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %>
@@ -14,9 +14,8
14 </p>
14 </p>
15 <% end %>
15 <% end %>
16
16
17 <p class="other-formats">
17 <% other_formats_links do |f| %>
18 <%= l(:label_export_to) %>
18 <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
19 <span><%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
19 <% end %>
20 </p>
21
20
22 <% html_title(l(:label_project_plural)) -%>
21 <% html_title(l(:label_project_plural)) -%>
@@ -15,10 +15,9
15 <%= render :partial => 'common/diff', :locals => {:diff => @diff, :diff_type => @diff_type} %>
15 <%= render :partial => 'common/diff', :locals => {:diff => @diff, :diff_type => @diff_type} %>
16 <% end -%>
16 <% end -%>
17
17
18 <p class="other-formats">
18 <% other_formats_links do |f| %>
19 <%= l(:label_export_to) %>
19 <%= f.link_to 'Diff', :url => params, :caption => 'Unified diff' %>
20 <span><%= link_to 'Unified diff', params.merge(:format => 'diff') %></span>
20 <% end %>
21 </p>
22
21
23 <% html_title(with_leading_slash(@path), 'Diff') -%>
22 <% html_title(with_leading_slash(@path), 'Diff') -%>
24
23
@@ -16,9 +16,8
16 <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
16 <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
17 <% end %>
17 <% end %>
18
18
19 <p class="other-formats">
19 <% other_formats_links do |f| %>
20 <%= l(:label_export_to) %>
20 <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
21 <span><%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
21 <% end %>
22 </p>
23
22
24 <% html_title(l(:label_revision_plural)) -%>
23 <% html_title(l(:label_revision_plural)) -%>
@@ -22,10 +22,10
22 <% content_for :header_tags do %>
22 <% content_for :header_tags do %>
23 <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :action => 'revisions', :id => @project, :page => nil, :key => User.current.rss_key})) %>
23 <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :action => 'revisions', :id => @project, :page => nil, :key => User.current.rss_key})) %>
24 <% end %>
24 <% end %>
25 <p class="other-formats">
25
26 <%= l(:label_export_to) %>
26 <% other_formats_links do |f| %>
27 <span><%= link_to 'Atom', {:action => 'revisions', :id => @project, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
27 <%= f.link_to 'Atom', :url => {:action => 'revisions', :id => @project, :key => User.current.rss_key} %>
28 </p>
28 <% end %>
29 <% end %>
29 <% end %>
30
30
31 <% content_for :header_tags do %>
31 <% content_for :header_tags do %>
@@ -22,11 +22,10 already in the URI %>
22 <%= render :partial => 'list', :locals => { :entries => @entries }%>
22 <%= render :partial => 'list', :locals => { :entries => @entries }%>
23 <p class="pagination"><%= pagination_links_full @entry_pages, @entry_count %></p>
23 <p class="pagination"><%= pagination_links_full @entry_pages, @entry_count %></p>
24
24
25 <p class="other-formats">
25 <% other_formats_links do |f| %>
26 <%= l(:label_export_to) %>
26 <%= f.link_to 'Atom', :url => params.merge({:issue_id => @issue, :key => User.current.rss_key}) %>
27 <span><%= link_to 'Atom', {:issue_id => @issue, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
27 <%= f.link_to 'CSV', :url => params %>
28 <span><%= link_to 'CSV', params.merge(:format => 'csv'), :class => 'csv' %></span>
28 <% end %>
29 </p>
30 <% end %>
29 <% end %>
31
30
32 <% html_title l(:label_spent_time), l(:label_details) %>
31 <% html_title l(:label_spent_time), l(:label_details) %>
@@ -65,10 +65,9
65 </tbody>
65 </tbody>
66 </table>
66 </table>
67
67
68 <p class="other-formats">
68 <% other_formats_links do |f| %>
69 <%= l(:label_export_to) %>
69 <%= f.link_to 'CSV', :url => params %>
70 <span><%= link_to 'CSV', params.merge({:format => 'csv'}), :class => 'csv' %></span>
70 <% end %>
71 </p>
72 <% end %>
71 <% end %>
73 <% end %>
72 <% end %>
74
73
@@ -42,11 +42,10
42 <% end %>
42 <% end %>
43 <% end %>
43 <% end %>
44
44
45 <p class="other-formats">
45 <% other_formats_links do |f| %>
46 <%= l(:label_export_to) %>
46 <%= f.link_to 'HTML', :url => {:page => @page.title, :version => @content.version} %>
47 <span><%= link_to 'HTML', {:page => @page.title, :export => 'html', :version => @content.version}, :class => 'html' %></span>
47 <%= f.link_to 'TXT', :url => {:page => @page.title, :version => @content.version} %>
48 <span><%= link_to 'TXT', {:page => @page.title, :export => 'txt', :version => @content.version}, :class => 'text' %></span>
48 <% end %>
49 </p>
50
49
51 <% content_for :header_tags do %>
50 <% content_for :header_tags do %>
52 <%= stylesheet_link_tag 'scm' %>
51 <%= stylesheet_link_tag 'scm' %>
@@ -18,11 +18,10
18 <% end %>
18 <% end %>
19
19
20 <% unless @pages.empty? %>
20 <% unless @pages.empty? %>
21 <p class="other-formats">
21 <% other_formats_links do |f| %>
22 <%= l(:label_export_to) %>
22 <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_pages => 1, :key => User.current.rss_key} %>
23 <span><%= link_to 'Atom', {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_pages => 1, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
23 <%= f.link_to 'HTML', :url => {:action => 'special', :page => 'export'} %>
24 <span><%= link_to 'HTML', {:action => 'special', :page => 'export'}, :class => 'html' %></span>
24 <% end %>
25 </p>
26 <% end %>
25 <% end %>
27
26
28 <% content_for :header_tags do %>
27 <% content_for :header_tags do %>
@@ -11,11 +11,10
11 <% end %>
11 <% end %>
12
12
13 <% unless @pages.empty? %>
13 <% unless @pages.empty? %>
14 <p class="other-formats">
14 <% other_formats_links do |f| %>
15 <%= l(:label_export_to) %>
15 <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_pages => 1, :key => User.current.rss_key} %>
16 <span><%= link_to 'Atom', {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_pages => 1, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
16 <%= f.link_to 'HTML', :url => {:action => 'special', :page => 'export'} %>
17 <span><%= link_to 'HTML', {:action => 'special', :page => 'export'} %></span>
17 <% end %>
18 </p>
19 <% end %>
18 <% end %>
20
19
21 <% content_for :header_tags do %>
20 <% content_for :header_tags do %>
@@ -307,7 +307,7 div.attachments span.author { font-size: 0.9em; color: #888; }
307 p.other-formats { text-align: right; font-size:0.9em; color: #666; }
307 p.other-formats { text-align: right; font-size:0.9em; color: #666; }
308 .other-formats span + span:before { content: "| "; }
308 .other-formats span + span:before { content: "| "; }
309
309
310 a.feed { background: url(../images/feed.png) no-repeat 1px 50%; padding: 2px 0px 3px 16px; }
310 a.atom { background: url(../images/feed.png) no-repeat 1px 50%; padding: 2px 0px 3px 16px; }
311
311
312 /***** Flash & error messages ****/
312 /***** Flash & error messages ****/
313 #errorExplanation, div.flash, .nodata, .warning {
313 #errorExplanation, div.flash, .nodata, .warning {
General Comments 0
You need to be logged in to leave comments. Login now