Project

General

Profile

Feature #1521 » rss.patch

Patch against r1611 - Henning Perl, 2008-07-02 14:15

View differences:

app/controllers/issues_controller.rb (working copy)
54 54
      respond_to do |format|
55 55
        format.html { }
56 56
        format.atom { }
57
        format.rss  { }
57 58
        format.csv  { limit = Setting.issues_export_limit.to_i }
58 59
        format.pdf  { limit = Setting.issues_export_limit.to_i }
59 60
      end
......
66 67
                           :offset =>  @issue_pages.current.offset
67 68
      respond_to do |format|
68 69
        format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
69
        format.atom { render_feed(@issues, :title => l(:label_issue_plural)) }
70
        format.atom { render_feed(@issues, :format => 'atom', :title => l(:label_issue_plural)) }
71
        format.rss  { render_feed(@issues, :format => 'rss', :title => l(:label_issue_plural)) }
70 72
        format.csv  { send_data(issues_to_csv(@issues, @project).read, :type => 'text/csv; header=present', :filename => 'export.csv') }
71 73
        format.pdf  { send_data(render(:template => 'issues/index.rfpdf', :layout => false), :type => 'application/pdf', :filename => 'export.pdf') }
72 74
      end
......
105 107
    respond_to do |format|
106 108
      format.html { render :template => 'issues/show.rhtml' }
107 109
      format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
110
      format.rss { render :action => 'changes', :layout => false, :content_type => 'application/rss+xml' }
108 111
      format.pdf  { send_data(render(:template => 'issues/show.rfpdf', :layout => false), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
109 112
    end
110 113
  end
app/controllers/application.rb (working copy)
152 152
    @items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
153 153
    @items = @items.slice(0, Setting.feeds_limit.to_i)
154 154
    @title = options[:title] || Setting.app_title
155
    render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
155
    format = options[:format] || 'atom'
156
    render :template => "common/feed.#{format}.rxml", :layout => false, :content_type => "application/#{format}+xml"
156 157
  end
157 158
  
158 159
  def self.accept_key_auth(*actions)
app/views/common/feed.rss.rxml (revision 0)
1
xml.instruct!
2
xml.rss "version" => "2.0" do
3
  xml.channel do
4
    xml.title   truncate_single_line(@title, 100)
5
    xml.language "en-us"
6
    xml.link    url_for(params.merge({:format => nil, :only_path => false}))
7
    xml.description ""
8
    xml.lastBuildDate((@items.first ? @items.first.event_datetime : Time.now).strftime("%a, %d %b %Y %H:%M:%S CST"))
9
    xml.generator Redmine::Info.url
10
    @items.each do |item|
11
      xml.item do
12
        url = url_for(item.event_url(:only_path => false))
13
        if @project
14
          xml.title truncate_single_line(item.event_title, 100)
15
        else
16
          xml.title truncate_single_line("#{item.project} - #{item.event_title}", 100)
17
        end
18
        xml.link url
19
        xml.guid url
20
        xml.pubDate item.event_datetime.strftime("%a, %d %b %Y %H:%M:%S CST")
21
        author = item.event_author if item.respond_to?(:event_author)
22
        if author then
23
          author = "#{author.mail} (#{author})" if author.respond_to?(:mail) && !author.mail.blank?
24
          xml.author(author)
25
        end
26
        xml.description do
27
          xml.text! textilizable(item.event_description)
28
        end
29
      end
30
    end
31
  end
32
end
33

  
app/views/issues/index.rhtml (working copy)
46 46
<p class="other-formats">
47 47
<%= l(:label_export_to) %>
48 48
<span><%= link_to 'Atom', {:query_id => @query, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
49
<span><%= link_to 'RSS', {:query_id => @query, :format => 'rss', :key => User.current.rss_key}, :class => 'feed' %></span>
49 50
<span><%= link_to 'CSV', {:format => 'csv'}, :class => 'csv' %></span>
50 51
<span><%= link_to 'PDF', {:format => 'pdf'}, :class => 'pdf' %></span>
51 52
</p>
......
57 58
<% end %>
58 59

  
59 60
<% content_for :header_tags do %>
60
    <%= auto_discovery_link_tag(:atom, {:query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_issue_plural)) %>
61
    <%= auto_discovery_link_tag(:atom, {:action => 'changes', :query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_changes_details)) %>
61
    <%= auto_discovery_link_tag(:atom, {:query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_issue_plural) + " (atom)") %>
62
    <%= auto_discovery_link_tag(:atom, {:action => 'changes', :query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_changes_details) + " (atom)") %>
63
    <%= auto_discovery_link_tag(:rss, {:query_id => @query, :format => 'rss', :page => nil, :key => User.current.rss_key}, :title => l(:label_issue_plural) + " (rss)") %>
64
    <%= auto_discovery_link_tag(:rss, {:action => 'changes', :query_id => @query, :format => 'rss', :page => nil, :key => User.current.rss_key}, :title => l(:label_changes_details) + " (rss)") %>
62 65
    <%= javascript_include_tag 'context_menu' %>
63 66
    <%= stylesheet_link_tag 'context_menu' %>
64 67
<% end %>
app/views/issues/show.rhtml (working copy)
105 105
<p class="other-formats">
106 106
<%= l(:label_export_to) %>
107 107
<span><%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
108
<span><%= link_to 'RSS', {:format => 'rss', :key => User.current.rss_key}, :class => 'feed' %></span>
108 109
<span><%= link_to 'PDF', {:format => 'pdf'}, :class => 'pdf' %></span>
109 110
</p>
110 111

  
......
115 116
<% end %>
116 117

  
117 118
<% content_for :header_tags do %>
118
    <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %>
119
    <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject} (atom)") %>
120
    <%= auto_discovery_link_tag(:rss, {:format => 'rss', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject} (rss)") %>
119 121
    <%= stylesheet_link_tag 'scm' %>
120 122
<% end %>
(2-2/2)