changes
This commit is contained in:
@@ -50,6 +50,11 @@ module Danbooru
|
||||
|
||||
def paginate_numbered(page)
|
||||
page = [page.to_i, 1].max
|
||||
|
||||
if page > Danbooru.config.max_numbered_pages
|
||||
raise Error.new("You cannot go beyond page #{Danbooru.config.max_numbered_pages}. Please narrow your search terms.")
|
||||
end
|
||||
|
||||
limit(records_per_page).offset((page - 1) * records_per_page).tap do |obj|
|
||||
obj.extend(NumberedCollectionExtension)
|
||||
obj.total_pages = (obj.total_count.to_f / records_per_page).ceil
|
||||
|
||||
6
lib/danbooru/paginator/error.rb
Normal file
6
lib/danbooru/paginator/error.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
module Danbooru
|
||||
module Paginator
|
||||
class Error < Exception
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user