work on forum
This commit is contained in:
12
app/presenters/forum_topic_presenter.rb
Normal file
12
app/presenters/forum_topic_presenter.rb
Normal 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
|
||||
22
app/presenters/paginators/forum_post.rb
Normal file
22
app/presenters/paginators/forum_post.rb
Normal 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
|
||||
23
app/presenters/paginators/forum_topic.rb
Normal file
23
app/presenters/paginators/forum_topic.rb
Normal 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
|
||||
Reference in New Issue
Block a user