From a7e32302a6c91c56e6511d1a44a64db07f53221d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 24 Apr 2009 16:51:07 +0000 Subject: Adds single forum atom feed (#3181). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2682 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/boards_controller.rb | 36 +++++++++++++++++++++++------------- app/models/board.rb | 4 ++++ app/views/boards/show.rhtml | 8 ++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) (limited to 'app') diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 8d53f81e4..eaac14e5b 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -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 } diff --git a/app/models/board.rb b/app/models/board.rb index 3bc18efec..ada138375 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -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 diff --git a/app/views/boards/show.rhtml b/app/views/boards/show.rhtml index 011a25e06..7f1600af0 100644 --- a/app/views/boards/show.rhtml +++ b/app/views/boards/show.rhtml @@ -59,4 +59,12 @@

<%= l(:label_no_data) %>

<% 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 %> -- cgit v1.2.3