From 942091f9e844f673240d75c27f4c6d2167a664e1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 5 Mar 2008 08:25:22 +0000 Subject: [PATCH] Display links to Atom feeds (closes #496, #750). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1185 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 11 +++++++++-- app/views/issues/_list.rhtml | 2 +- app/views/issues/changes.rxml | 8 ++++---- app/views/issues/index.rhtml | 12 +++++++----- app/views/issues/show.rhtml | 13 +++++++++---- app/views/news/index.rhtml | 5 +++++ app/views/projects/activity.rhtml | 9 ++++++--- app/views/projects/gantt.rhtml | 9 +++++---- app/views/timelog/details.rhtml | 9 +++++---- app/views/wiki/show.rhtml | 9 ++++----- app/views/wiki/special_date_index.rhtml | 13 +++++++++---- app/views/wiki/special_page_index.rhtml | 13 +++++++++---- lang/en.yml | 2 +- lang/fr.yml | 2 +- public/images/feed.png | Bin 359 -> 524 bytes public/stylesheets/application.css | 14 ++++++-------- test/functional/issues_controller_test.rb | 2 +- 17 files changed, 82 insertions(+), 51 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 53627db92..4a44d09bc 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -49,7 +49,13 @@ class IssuesController < ApplicationController sort_update retrieve_query if @query.valid? - limit = %w(pdf csv).include?(params[:format]) ? Setting.issues_export_limit.to_i : per_page_option + limit = per_page_option + respond_to do |format| + format.html { } + format.atom { } + format.csv { limit = Setting.issues_export_limit.to_i } + format.pdf { limit = Setting.issues_export_limit.to_i } + end @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) @issue_pages = Paginator.new self, @issue_count, limit, params['page'] @issues = Issue.find :all, :order => sort_clause, @@ -74,7 +80,7 @@ class IssuesController < ApplicationController sort_update retrieve_query if @query.valid? - @changes = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ], + @journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ], :conditions => @query.statement, :limit => 25, :order => "#{Journal.table_name}.created_on DESC" @@ -92,6 +98,7 @@ class IssuesController < ApplicationController @priorities = Enumeration::get_values('IPRI') respond_to do |format| format.html { render :template => 'issues/show.rhtml' } + format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' } format.pdf { send_data(render(:template => 'issues/show.rfpdf', :layout => false), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") } end end diff --git a/app/views/issues/_list.rhtml b/app/views/issues/_list.rhtml index 343f7173d..91390ac67 100644 --- a/app/views/issues/_list.rhtml +++ b/app/views/issues/_list.rhtml @@ -11,7 +11,7 @@ <% issues.each do |issue| -%> "> - <%= check_box_tag("ids[]", issue.id, false) %> + <%= check_box_tag("ids[]", issue.id, false, :id => nil) %> <%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %> <% query.columns.each do |column| %><%= content_tag 'td', column_content(column, issue), :class => column.name %><% end %> diff --git a/app/views/issues/changes.rxml b/app/views/issues/changes.rxml index f1aa5d206..239d2d6a3 100644 --- a/app/views/issues/changes.rxml +++ b/app/views/issues/changes.rxml @@ -1,12 +1,12 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do xml.title @title - xml.link "rel" => "self", "href" => url_for(:controller => 'feeds', :action => 'history', :format => 'atom', :only_path => false) - xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false) + xml.link "rel" => "self", "href" => url_for(:format => 'atom', :key => User.current.rss_key, :only_path => false) + xml.link "rel" => "alternate", "href" => home_url(:only_path => false) xml.id url_for(:controller => 'welcome', :only_path => false) - xml.updated((@changes.first ? @changes.first.event_datetime : Time.now).xmlschema) + xml.updated((@journals.first ? @journals.first.event_datetime : Time.now).xmlschema) xml.author { xml.name "#{Setting.app_title}" } - @changes.each do |change| + @journals.each do |change| issue = change.issue xml.entry do xml.title "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}" diff --git a/app/views/issues/index.rhtml b/app/views/issues/index.rhtml index 4d1f4f176..d3408fa99 100644 --- a/app/views/issues/index.rhtml +++ b/app/views/issues/index.rhtml @@ -41,12 +41,14 @@

<%= l(:label_no_data) %>

<% else %> <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query} %> -
-<%= l(:label_export_to) %> -<%= link_to 'CSV', {:format => 'csv'}, :class => 'icon icon-csv' %>, -<%= link_to 'PDF', {:format => 'pdf'}, :class => 'icon icon-pdf' %> -

<%= pagination_links_full @issue_pages, @issue_count %>

+ +

+<%= l(:label_export_to) %> +<%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> +<%= link_to 'CSV', {:format => 'csv'}, :class => 'csv' %> +<%= link_to 'PDF', {:format => 'pdf'}, :class => 'pdf' %> +

<% end %> <% end %> diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml index e3999bd8e..c5efe4f25 100644 --- a/app/views/issues/show.rhtml +++ b/app/views/issues/show.rhtml @@ -95,13 +95,18 @@ end %> <% end %> -
-<%= l(:label_export_to) %><%= link_to 'PDF', {:format => 'pdf'}, :class => 'icon icon-pdf' %> -
-  +

+<%= l(:label_export_to) %> +<%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> +<%= link_to 'PDF', {:format => 'pdf'}, :class => 'pdf' %> +

<% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %> <% content_for :sidebar do %> <%= render :partial => 'issues/sidebar' %> <% end %> + +<% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %> +<% end %> diff --git a/app/views/news/index.rhtml b/app/views/news/index.rhtml index 369eaf1b1..87db8a5f7 100644 --- a/app/views/news/index.rhtml +++ b/app/views/news/index.rhtml @@ -39,6 +39,11 @@ <% end %>

<%= pagination_links_full @news_pages %>

+

+<%= l(:label_export_to) %> +<%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> +

+ <% content_for :header_tags do %> <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> <% end %> diff --git a/app/views/projects/activity.rhtml b/app/views/projects/activity.rhtml index dce333f61..aca08fd6f 100644 --- a/app/views/projects/activity.rhtml +++ b/app/views/projects/activity.rhtml @@ -27,12 +27,15 @@ <% next_params = params.clone.update :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1) %> <%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'), {:update => "content", :url => next_params}, {:href => url_for(next_params)} %> -  -
+  +

+ <%= l(:label_export_to) %> + <%= link_to 'Atom', params.merge(:format => :atom, :key => User.current.rss_key).delete_if{|k,v|k=="commit"}, :class => 'feed' %> +

<% content_for :header_tags do %> -<%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :year => nil, :month => nil, :key => User.current.rss_key})) %> +<%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :year => nil, :month => nil, :key => User.current.rss_key).delete_if{|k,v|k=="commit"}) %> <% end %> <% content_for :sidebar do %> diff --git a/app/views/projects/gantt.rhtml b/app/views/projects/gantt.rhtml index 2979bce2b..05bd4b9bc 100644 --- a/app/views/projects/gantt.rhtml +++ b/app/views/projects/gantt.rhtml @@ -223,10 +223,11 @@ if Date.today >= @date_from and Date.today <= @date_to %> -
<%= l(:label_export_to) %> -<%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :format => 'pdf'}, :class => 'icon icon-pdf' %> -<%= link_to 'PNG', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :format => 'png'}, :class => 'icon icon-image' if respond_to?('gantt_image') %> -
+

+<%= l(:label_export_to) %> +<%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :format => 'pdf'}, :class => 'pdf' %> +<%= content_tag('span', link_to('PNG', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :format => 'png'}, :class => 'image')) if respond_to?('gantt_image') %> +

<% content_for :sidebar do %>

<%= l(:label_gantt) %>

diff --git a/app/views/timelog/details.rhtml b/app/views/timelog/details.rhtml index 802090b7a..cba1597d1 100644 --- a/app/views/timelog/details.rhtml +++ b/app/views/timelog/details.rhtml @@ -37,11 +37,12 @@ <% unless @entries.empty? %> <%= render :partial => 'list', :locals => { :entries => @entries }%> -
- <%= l(:label_export_to) %> - <%= link_to 'CSV', params.merge(:format => 'csv'), :class => 'icon icon-csv' %> -

<%= pagination_links_full @entry_pages, @entry_count %>

+ +

+<%= l(:label_export_to) %> +<%= link_to 'CSV', params.merge(:format => 'csv'), :class => 'csv' %> +

<% end %> <% content_for :header_tags do %> diff --git a/app/views/wiki/show.rhtml b/app/views/wiki/show.rhtml index 77d82884f..e4413d090 100644 --- a/app/views/wiki/show.rhtml +++ b/app/views/wiki/show.rhtml @@ -36,12 +36,11 @@ <% end %> <% end %> -
+

<%= l(:label_export_to) %> -<%= link_to 'HTML', {:page => @page.title, :export => 'html', :version => @content.version}, :class => 'icon icon-html' %>, -<%= link_to 'TXT', {:page => @page.title, :export => 'txt', :version => @content.version}, :class => 'icon icon-txt' %> -

-  +<%= 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' %> +

<% 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 ac68f809e..6717ebc85 100644 --- a/app/views/wiki/special_date_index.rhtml +++ b/app/views/wiki/special_date_index.rhtml @@ -17,9 +17,14 @@ <%= render :partial => 'sidebar' %> <% end %> -
<% unless @pages.empty? %> -<%= l(:label_export_to) %> <%= link_to 'HTML', {:action => 'special', :page => 'export'}, :class => 'icon icon-html' %> +

+<%= 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' %> +

+<% end %> + +<% content_for :header_tags do %> +<%= auto_discovery_link_tag(:atom, :controller => 'projects', :action => 'activity', :id => @project, :show_wiki_pages => 1, :format => 'atom', :key => User.current.rss_key) %> <% end %> -
-  diff --git a/app/views/wiki/special_page_index.rhtml b/app/views/wiki/special_page_index.rhtml index db6629de8..f21cc3423 100644 --- a/app/views/wiki/special_page_index.rhtml +++ b/app/views/wiki/special_page_index.rhtml @@ -14,9 +14,14 @@ <%= render :partial => 'sidebar' %> <% end %> -
<% unless @pages.empty? %> -<%= l(:label_export_to) %> <%= link_to 'HTML', {:action => 'special', :page => 'export'}, :class => 'icon icon-html' %> +

+<%= 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'} %> +

+<% end %> + +<% content_for :header_tags do %> +<%= auto_discovery_link_tag(:atom, :controller => 'projects', :action => 'activity', :id => @project, :show_wiki_pages => 1, :format => 'atom', :key => User.current.rss_key) %> <% end %> -
-  diff --git a/lang/en.yml b/lang/en.yml index 7ed2c8775..a5da5a855 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -320,7 +320,7 @@ label_version: Version label_version_new: New version label_version_plural: Versions label_confirmation: Confirmation -label_export_to: Export to +label_export_to: 'Also available in:' label_read: Read... label_public_projects: Public projects label_open_issues: open diff --git a/lang/fr.yml b/lang/fr.yml index accd5c1bf..30c9f6cca 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -320,7 +320,7 @@ label_version: Version label_version_new: Nouvelle version label_version_plural: Versions label_confirmation: Confirmation -label_export_to: Exporter en +label_export_to: 'Formats disponibles:' label_read: Lire... label_public_projects: Projets publics label_open_issues: ouvert diff --git a/public/images/feed.png b/public/images/feed.png index 51dc9778e79854fbccaddc52c62d2d2fadf15677..900188ae068198fb18263442abbeb106dbbec341 100644 GIT binary patch literal 524 zcmV+n0`vWeP)oNHoN|N{V0m*FCpt zag&>K&dqnu_nmXDqK$9*xs`<-X2zMSfN2VZ0r{$u_Kg(q9RH3+UcXvY0t4Xw5<5&x z!RNODJ&}T*Od%nV1g0dH-NcI><}fp9Di;Y@8LTG*Q3b1q4_G|7LtIZvFfr*#1J3L$ zt`)To1*yu;bqu#L9d2$$hu4Yrnmp`B-th8~kYHk@qmpLQ+f>f68;PNB{s?1h=MX(% zw$}?!o>hYNgdruWnFdD#Zp`)jus-Y;kHE;l+W+oGu*+X#SG7aji zq9!pBx_~>^jILVeuPlQY(voUiHVGbBIL1xv3uDct2%S92A@nr3{!5zfu12uUgFpqx z%vMBJZgl5hNldG*(Ec}KMqmog9^$BUTCsigDq}j;`8HfWeMsL|kd4#(IFz!&ccM0R{jl8qAKtqD=ZQ3y8>Ys9!DJ4HV)m z@Q5sCVBi)4Va7{$>;3=*S<)SS9T^xl_H+M9WCilW1AIbUf%O0X|36Pqdt1Tqw~gWZ z>zlu3FnsP8`?A*e&os&RN9TXsQTF-ik@rU?zw2W7y^P`3oXD5^`@bFU{`Kw4kG01C zH!^-dQu2SN*u6C={|~7CIU4o;&gwrm<}~)y-vJuUSQ6wH%;50sMjDXQ=IP=XQgKVS zH(IFKfQNapMPaO*8H>|`FaMsext#bv>{1U?%hyI$$2U9PzkmK}2FqSIi=Xlt7q-oR zKCAIkRPoxYYi{jXc;(jBnyMK&6V@G@?9V=XVlUIoje62<=Wbk`db7gunds4If8*>n zF1G70)@%AI9DFltkMEyJU*z1lCU#t6KHBh(U(o(b5Bt1_!Qx#&7cqFc`njxgN@xNA D=CYsx diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 833937482..cd875c7f7 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -80,7 +80,7 @@ a img{ border: 0; } /***** Tables *****/ table.list { border: 1px solid #e4e4e4; border-collapse: collapse; width: 100%; margin-bottom: 4px; } table.list th { background-color:#EEEEEE; padding: 4px; white-space:nowrap; } -table.list td { overflow: hidden; text-overflow: ellipsis; vertical-align: top;} +table.list td { overflow: hidden; vertical-align: top;} table.list td.id { width: 2%; text-align: center;} table.list td.checkbox { width: 15px; padding: 0px;} @@ -228,6 +228,11 @@ div.attachments p { margin:4px 0 2px 0; } div.attachments img { vertical-align: middle; } 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; } + /***** Flash & error messages ****/ #errorExplanation, div.flash, .nodata { padding: 4px 4px 4px 30px; @@ -275,7 +280,6 @@ padding:0.6em; z-index:100; filter:alpha(opacity=50); opacity: 0.5; --khtml-opacity: 0.5; } html>body #ajax-indicator { position: fixed; } @@ -518,11 +522,6 @@ vertical-align: middle; .icon-move { background-image: url(../images/move.png); } .icon-save { background-image: url(../images/save.png); } .icon-cancel { background-image: url(../images/cancel.png); } -.icon-pdf { background-image: url(../images/pdf.png); } -.icon-csv { background-image: url(../images/csv.png); } -.icon-html { background-image: url(../images/html.png); } -.icon-image { background-image: url(../images/image.png); } -.icon-txt { background-image: url(../images/txt.png); } .icon-file { background-image: url(../images/file.png); } .icon-folder { background-image: url(../images/folder.png); } .open .icon-folder { background-image: url(../images/folder_open.png); } @@ -537,7 +536,6 @@ vertical-align: middle; .icon-attachment { background-image: url(../images/attachment.png); } .icon-index { background-image: url(../images/index.png); } .icon-history { background-image: url(../images/history.png); } -.icon-feed { background-image: url(../images/feed.png); } .icon-time { background-image: url(../images/time.png); } .icon-stats { background-image: url(../images/stats.png); } .icon-warning { background-image: url(../images/warning.png); } diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index da8118668..4f644d522 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -96,7 +96,7 @@ class IssuesControllerTest < Test::Unit::TestCase def test_changes get :changes, :project_id => 1 assert_response :success - assert_not_nil assigns(:changes) + assert_not_nil assigns(:journals) assert_equal 'application/atom+xml', @response.content_type end