work on forum

This commit is contained in:
albert
2011-03-11 19:24:19 -05:00
parent 7dd345ca75
commit 21cc1cbafa
24 changed files with 343 additions and 1306 deletions

View File

@@ -0,0 +1,12 @@
class ForumTopicPresenter < Presenter
attr_reader :forum_topic, :forum_posts
def initialize(forum_topic, forum_posts)
@forum_posts = forum_posts
@forum_topic = forum_topic
end
def pagination_html(template)
Paginators::ForumTopic.new(forum_topic, forum_posts).numbered_pagination_html(template)
end
end

View File

@@ -0,0 +1,22 @@
module Paginators
class ForumPost < Base
attr_accessor :forum_posts
def initialize(forum_posts)
@forum_posts = forum_posts
end
protected
def total_pages
forum_posts.total_entries
end
def current_page
forum_posts.current_page
end
def paginated_link(template, page)
template.link_to(page, template.forum_posts_path(:search => template.params[:search], :page => page))
end
end
end

View File

@@ -0,0 +1,23 @@
module Paginators
class ForumTopic < Base
attr_accessor :forum_topic, :forum_posts
def initialize(forum_topic, forum_posts)
@forum_topic = forum_topic
@forum_posts = forum_posts
end
protected
def total_pages
forum_posts.total_pages
end
def current_page
forum_posts.current_page
end
def paginated_link(template, page)
template.link_to(page, template.forum_topic_path(forum_topic, :page => page))
end
end
end