]> source.dussan.org Git - redmine.git/commitdiff
Adds single forum atom feed (#3181).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 24 Apr 2009 16:51:07 +0000 (16:51 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 24 Apr 2009 16:51:07 +0000 (16:51 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2682 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/boards_controller.rb
app/models/board.rb
app/views/boards/show.rhtml
config/routes.rb
test/functional/boards_controller_test.rb

index 8d53f81e4bc40e149c68be6e6d36372a1b374302..eaac14e5b8b8f80daa5e3503abc2f75f71aeaaec 100644 (file)
@@ -35,19 +35,29 @@ class BoardsController < ApplicationController
   end
 
   def show
-    sort_init 'updated_on', 'desc'
-    sort_update        'created_on' => "#{Message.table_name}.created_on",
-                'replies' => "#{Message.table_name}.replies_count",
-                'updated_on' => "#{Message.table_name}.updated_on"
-      
-    @topic_count = @board.topics.count
-    @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
-    @topics =  @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '),
-                                  :include => [:author, {:last_reply => :author}],
-                                  :limit  =>  @topic_pages.items_per_page,
-                                  :offset =>  @topic_pages.current.offset
-    @message = Message.new
-    render :action => 'show', :layout => !request.xhr?
+    respond_to do |format|
+      format.html {
+        sort_init 'updated_on', 'desc'
+        sort_update    'created_on' => "#{Message.table_name}.created_on",
+                    'replies' => "#{Message.table_name}.replies_count",
+                    'updated_on' => "#{Message.table_name}.updated_on"
+          
+        @topic_count = @board.topics.count
+        @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
+        @topics =  @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '),
+                                      :include => [:author, {:last_reply => :author}],
+                                      :limit  =>  @topic_pages.items_per_page,
+                                      :offset =>  @topic_pages.current.offset
+        @message = Message.new
+        render :action => 'show', :layout => !request.xhr?
+      }
+      format.atom {
+        @messages = @board.messages.find :all, :order => 'created_on DESC',
+                                               :include => [:author, :board],
+                                               :limit => Setting.feeds_limit.to_i
+        render_feed(@messages, :title => "#{@project}: #{@board}")
+      }
+    end
   end
   
   verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index }
index 3bc18efec64ae926718f7ee885673a1840abec66..ada138375343eea4adfb3199f48444b0c095be04 100644 (file)
@@ -27,6 +27,10 @@ class Board < ActiveRecord::Base
   validates_length_of :name, :maximum => 30
   validates_length_of :description, :maximum => 255
   
+  def to_s
+    name
+  end
+  
   def reset_counters!
     self.class.reset_counters!(id)
   end
index 011a25e06508a5241f3e5ca065ef82e9a8e74bea..7f1600af03635f3403bf10c35d51ba047db7aa5f 100644 (file)
 <p class="nodata"><%= l(:label_no_data) %></p>
 <% end %>
 
+<% other_formats_links do |f| %>
+       <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
+<% end %>
+
 <% html_title h(@board.name) %>
+
+<% content_for :header_tags do %>
+    <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %>
+<% end %>
index 2a480061280991f86297c88c52bc51997b41366c..bfacb1d3a5a2960a13eb0c2e9c25929eab23aa4e 100644 (file)
@@ -86,6 +86,7 @@ ActionController::Routing::Routes.draw do |map|
       board_views.connect 'projects/:project_id/boards', :action => 'index'
       board_views.connect 'projects/:project_id/boards/new', :action => 'new'
       board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
+      board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show'
       board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
     end
     board_routes.with_options :conditions => {:method => :post} do |board_actions|
index b9df5517f6f00a83161f7b1c5e4559e6314399c2..01db0f94b5b8ca0917f2c12c2ab530dff6bb63e0 100644 (file)
@@ -84,6 +84,10 @@ class BoardsControllerTest < Test::Unit::TestCase
       {:method => :get, :path => '/projects/world_domination/boards/44'},
       :controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination'
     )
+    assert_routing(
+      {:method => :get, :path => '/projects/world_domination/boards/44.atom'},
+      :controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination', :format => 'atom'
+    )
   end
   
   def test_show
@@ -95,6 +99,15 @@ class BoardsControllerTest < Test::Unit::TestCase
     assert_not_nil assigns(:topics)
   end
   
+  def test_show_atom
+    get :show, :project_id => 1, :id => 1, :format => 'atom'
+    assert_response :success
+    assert_template 'common/feed.atom'
+    assert_not_nil assigns(:board)
+    assert_not_nil assigns(:project)
+    assert_not_nil assigns(:messages)
+  end
+  
   def test_edit_routing
     assert_routing(
       {:method => :get, :path => '/projects/world_domination/boards/44/edit'},