diff --git a/Gemfile b/Gemfile index 254945c6d..a3bd122c4 100644 --- a/Gemfile +++ b/Gemfile @@ -19,5 +19,4 @@ gem "simple_form" gem "mechanize" gem "nokogiri" gem "meta_search", :git => "git://github.com/ernie/meta_search.git" -gem "will_paginate", :git => "git://github.com/mmack/will_paginate.git", :branch => "rails3.1" gem "silent-postgres" diff --git a/Gemfile.lock b/Gemfile.lock index a81fee34a..f424c75d0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,13 +7,6 @@ GIT activerecord (~> 3.1.0.alpha) activesupport (~> 3.1.0.alpha) -GIT - remote: git://github.com/mmack/will_paginate.git - revision: 5816b4e8d4382b4b167621a9aea4b8fe72983c37 - branch: rails3.1 - specs: - will_paginate (3.1.0) - GIT remote: http://github.com/EmmanuelOga/ffaker.git revision: 52feff4ecddbe8834b63beb122b153b65833e309 @@ -143,4 +136,3 @@ DEPENDENCIES simple_form simplecov super_exception_notifier - will_paginate! diff --git a/app/controllers/post_versions_controller.rb b/app/controllers/post_versions_controller.rb index 01bbba81f..f5f2b2760 100644 --- a/app/controllers/post_versions_controller.rb +++ b/app/controllers/post_versions_controller.rb @@ -1,6 +1,5 @@ class PostVersionsController < ApplicationController def index - @search = PostVersion.search(params[:search]) - @post_versions = @search.paginate(:page => params[:page], :order => "updated_at DESC") + @search = PostVersion.search(params[:search]).paginate(params[:paginate]) end end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index f8847b24c..d80164d4f 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -4,9 +4,8 @@ class PostsController < ApplicationController respond_to :html, :xml, :json def index - @post_set = PostSets::Base.new(params) - extend_post_set(@post_set) - respond_with(@post_set) + @posts = Post.search(params[:search]).paginate(params[:page]) + respond_with(@posts) end def show diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb index fa5af5a4d..cb17822f5 100644 --- a/app/helpers/pagination_helper.rb +++ b/app/helpers/pagination_helper.rb @@ -1,64 +1,61 @@ module PaginationHelper - def smart_paginator(set, &block) - if params[:page] && set.page > 1000 - set.extend(PostSets::Sequential) - sequential_paginator(set) + def smart_paginator(records, &block) + if records.is_sequential_paginator? || params[:page].to_i > 200 + sequential_paginator(records) else - set.extend(PostSets::Numbered) - numbered_paginator(set, &block) + numbered_paginator(records, &block) end end - def sequential_paginator(set) + def sequential_paginator(records) html = "
" html.html_safe end - def numbered_paginator(set, &block) + def numbered_paginator(records, &block) html = "" html.html_safe end def numbered_paginator_final_item(total_pages, current_page, &block) - if total_pages <= 1000 + if total_pages <= 200 numbered_paginator_item(total_pages, current_page, &block) else "" diff --git a/app/logical/post_sets/base.rb b/app/logical/post_sets/base.rb deleted file mode 100644 index d43c11356..000000000 --- a/app/logical/post_sets/base.rb +++ /dev/null @@ -1,80 +0,0 @@ -# A PostSet represents a paginated slice of posts. It is used in conjunction -# with the helpers to render the paginator. -# -# Usage: -# -# @post_set = PostSets::Base.new(params) -# @post_set.extend(PostSets::Sequential) -# @post_set.extend(PostSets::Post) - -module PostSets - class Base - attr_reader :params, :posts - delegate :to_xml, :to_json, :to => :posts - - def initialize(params) - @params = params - end - - # Should a return a paginated array of posts. This means it should have - # at most| - | Post | -Date | -User | -Rating | -Parent | -IP Address | -Tags | -||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| - <%= button_to_function "Undo", "PostTagHistory.undo()", :id => "undo" %> - <%= button_to_function "Revert to", "PostTagHistory.revert()", :id => "revert" %> - | -|||||||||||||||||||||
| - | <%= link_to change[:change].post_id, :controller => "post", :action => "show", :id => change[:change].post_id %> | -<%= change[:change].created_at.strftime("%Y-%m-%d %H:%M") %> | -<%= link_to change[:change].author, :controller => "user", :action => "show", :id => change[:change].user_id %> | -<%= change[:change].rating %> | -<%= change[:parent_id] %> | -- <% if @current_user.is_admin? %> - <%= change[:ip_addr] %> - <% end %> - | -- - - - | + +||||||||||||||
| Post | +Date | +User | +Rating | +Parent | +IP Address | +Tags |
|---|