fixes to limit
This commit is contained in:
@@ -5,7 +5,7 @@ class PostsController < ApplicationController
|
|||||||
rescue_from PostSets::SearchError, :with => :search_error
|
rescue_from PostSets::SearchError, :with => :search_error
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@post_set = PostSets::Post.new(tag_query, params[:page])
|
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit])
|
||||||
@posts = @post_set.posts
|
@posts = @post_set.posts
|
||||||
respond_with(@posts) do |format|
|
respond_with(@posts) do |format|
|
||||||
format.atom
|
format.atom
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class WikiPage < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def post_set
|
def post_set
|
||||||
@post_set ||= PostSets::WikiPage.new(title)
|
@post_set ||= PostSets::WikiPage.new(title, 1, 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
def presenter
|
def presenter
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
module PostSetPresenters
|
module PostSetPresenters
|
||||||
class WikiPage < Post
|
class WikiPage < Post
|
||||||
def posts
|
def posts
|
||||||
Thread.current["records_per_page"] = 4
|
|
||||||
@post_set.posts
|
@post_set.posts
|
||||||
ensure
|
|
||||||
Thread.current["records_per_page"] = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
require "danbooru/paginator/active_record_extension"
|
require "danbooru/paginator/active_record_extension"
|
||||||
require "danbooru/paginator/numbered_collection_extension"
|
require "danbooru/paginator/numbered_collection_extension"
|
||||||
require "danbooru/paginator/sequential_collection_extension"
|
require "danbooru/paginator/sequential_collection_extension"
|
||||||
|
require "danbooru/paginator/pagination_error"
|
||||||
|
|
||||||
ActiveRecord::Base.__send__(:include, Danbooru::Paginator::ActiveRecordExtension)
|
ActiveRecord::Base.__send__(:include, Danbooru::Paginator::ActiveRecordExtension)
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ module Danbooru
|
|||||||
end
|
end
|
||||||
|
|
||||||
def records_per_page
|
def records_per_page
|
||||||
# ugly hack but no easy way to pass this info down
|
(@paginator_options[:limit] || Danbooru.config.posts_per_page).to_i
|
||||||
(Thread.current["records_per_page"] || @paginator_options[:limit] || Danbooru.config.posts_per_page).to_i
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# taken from kaminari (https://github.com/amatsuda/kaminari)
|
# taken from kaminari (https://github.com/amatsuda/kaminari)
|
||||||
|
|||||||
Reference in New Issue
Block a user