@@ -35,19 +35,29 class BoardsController < ApplicationController | |||||
35 | end |
|
35 | end | |
36 |
|
36 | |||
37 | def show |
|
37 | def show | |
38 | sort_init 'updated_on', 'desc' |
|
38 | respond_to do |format| | |
39 | sort_update 'created_on' => "#{Message.table_name}.created_on", |
|
39 | format.html { | |
40 | 'replies' => "#{Message.table_name}.replies_count", |
|
40 | sort_init 'updated_on', 'desc' | |
41 |
|
|
41 | sort_update 'created_on' => "#{Message.table_name}.created_on", | |
42 |
|
42 | 'replies' => "#{Message.table_name}.replies_count", | ||
43 | @topic_count = @board.topics.count |
|
43 | 'updated_on' => "#{Message.table_name}.updated_on" | |
44 | @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] |
|
44 | ||
45 | @topics = @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '), |
|
45 | @topic_count = @board.topics.count | |
46 | :include => [:author, {:last_reply => :author}], |
|
46 | @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] | |
47 | :limit => @topic_pages.items_per_page, |
|
47 | @topics = @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '), | |
48 | :offset => @topic_pages.current.offset |
|
48 | :include => [:author, {:last_reply => :author}], | |
49 | @message = Message.new |
|
49 | :limit => @topic_pages.items_per_page, | |
50 | render :action => 'show', :layout => !request.xhr? |
|
50 | :offset => @topic_pages.current.offset | |
|
51 | @message = Message.new | |||
|
52 | render :action => 'show', :layout => !request.xhr? | |||
|
53 | } | |||
|
54 | format.atom { | |||
|
55 | @messages = @board.messages.find :all, :order => 'created_on DESC', | |||
|
56 | :include => [:author, :board], | |||
|
57 | :limit => Setting.feeds_limit.to_i | |||
|
58 | render_feed(@messages, :title => "#{@project}: #{@board}") | |||
|
59 | } | |||
|
60 | end | |||
51 | end |
|
61 | end | |
52 |
|
62 | |||
53 | verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index } |
|
63 | verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index } |
@@ -27,6 +27,10 class Board < ActiveRecord::Base | |||||
27 | validates_length_of :name, :maximum => 30 |
|
27 | validates_length_of :name, :maximum => 30 | |
28 | validates_length_of :description, :maximum => 255 |
|
28 | validates_length_of :description, :maximum => 255 | |
29 |
|
29 | |||
|
30 | def to_s | |||
|
31 | name | |||
|
32 | end | |||
|
33 | ||||
30 | def reset_counters! |
|
34 | def reset_counters! | |
31 | self.class.reset_counters!(id) |
|
35 | self.class.reset_counters!(id) | |
32 | end |
|
36 | end |
@@ -59,4 +59,12 | |||||
59 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
59 | <p class="nodata"><%= l(:label_no_data) %></p> | |
60 | <% end %> |
|
60 | <% end %> | |
61 |
|
61 | |||
|
62 | <% other_formats_links do |f| %> | |||
|
63 | <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> | |||
|
64 | <% end %> | |||
|
65 | ||||
62 | <% html_title h(@board.name) %> |
|
66 | <% html_title h(@board.name) %> | |
|
67 | ||||
|
68 | <% content_for :header_tags do %> | |||
|
69 | <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %> | |||
|
70 | <% end %> |
@@ -86,6 +86,7 ActionController::Routing::Routes.draw do |map| | |||||
86 | board_views.connect 'projects/:project_id/boards', :action => 'index' |
|
86 | board_views.connect 'projects/:project_id/boards', :action => 'index' | |
87 | board_views.connect 'projects/:project_id/boards/new', :action => 'new' |
|
87 | board_views.connect 'projects/:project_id/boards/new', :action => 'new' | |
88 | board_views.connect 'projects/:project_id/boards/:id', :action => 'show' |
|
88 | board_views.connect 'projects/:project_id/boards/:id', :action => 'show' | |
|
89 | board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show' | |||
89 | board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit' |
|
90 | board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit' | |
90 | end |
|
91 | end | |
91 | board_routes.with_options :conditions => {:method => :post} do |board_actions| |
|
92 | board_routes.with_options :conditions => {:method => :post} do |board_actions| |
@@ -84,6 +84,10 class BoardsControllerTest < Test::Unit::TestCase | |||||
84 | {:method => :get, :path => '/projects/world_domination/boards/44'}, |
|
84 | {:method => :get, :path => '/projects/world_domination/boards/44'}, | |
85 | :controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination' |
|
85 | :controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination' | |
86 | ) |
|
86 | ) | |
|
87 | assert_routing( | |||
|
88 | {:method => :get, :path => '/projects/world_domination/boards/44.atom'}, | |||
|
89 | :controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination', :format => 'atom' | |||
|
90 | ) | |||
87 | end |
|
91 | end | |
88 |
|
92 | |||
89 | def test_show |
|
93 | def test_show | |
@@ -95,6 +99,15 class BoardsControllerTest < Test::Unit::TestCase | |||||
95 | assert_not_nil assigns(:topics) |
|
99 | assert_not_nil assigns(:topics) | |
96 | end |
|
100 | end | |
97 |
|
101 | |||
|
102 | def test_show_atom | |||
|
103 | get :show, :project_id => 1, :id => 1, :format => 'atom' | |||
|
104 | assert_response :success | |||
|
105 | assert_template 'common/feed.atom' | |||
|
106 | assert_not_nil assigns(:board) | |||
|
107 | assert_not_nil assigns(:project) | |||
|
108 | assert_not_nil assigns(:messages) | |||
|
109 | end | |||
|
110 | ||||
98 | def test_edit_routing |
|
111 | def test_edit_routing | |
99 | assert_routing( |
|
112 | assert_routing( | |
100 | {:method => :get, :path => '/projects/world_domination/boards/44/edit'}, |
|
113 | {:method => :get, :path => '/projects/world_domination/boards/44/edit'}, |
General Comments 0
You need to be logged in to leave comments.
Login now