limit wiki pages to 8 posts

This commit is contained in:
albert
2012-01-06 18:47:37 -05:00
parent 6b754cf293
commit aac315e0b2
4 changed files with 23 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
module PostSets
class SearchError < Exception
end
class WikiPage < Post
def presenter
@presenter ||= ::PostSetPresenters::WikiPage.new(self)
end
end
end

View File

@@ -82,7 +82,7 @@ class WikiPage < ActiveRecord::Base
end
def post_set
@post_set ||= PostSets::Post.new(title)
@post_set ||= PostSets::WikiPage.new(title)
end
def presenter

View File

@@ -0,0 +1,10 @@
module PostSetPresenters
class WikiPage < Post
def posts
Thread.current["records_per_page"] = 8
@post_set.posts
ensure
Thread.current["records_per_page"] = nil
end
end
end

View File

@@ -63,7 +63,8 @@ module Danbooru
end
def records_per_page
Danbooru.config.posts_per_page
# ugly hack but no easy way to pass this info down
Thread.current["records_per_page"] || Danbooru.config.posts_per_page
end
# taken from kaminari (https://github.com/amatsuda/kaminari)