Permalink
Browse files

Fix rails 3 bugs in will_paginate

  • Loading branch information...
sudara committed Mar 26, 2009
1 parent c30658f commit e7c456b0e927d75d7ab20a574bbd8444f229b250
Showing with 2 additions and 3,352 deletions.
  1. +1 −1 app/models/user/findability.rb
  2. +1 −0 config/environment.rb
  3. +0 −4 vendor/plugins/will_paginate/.gitignore
  4. +0 −49 vendor/plugins/will_paginate/.manifest
  5. +0 −92 vendor/plugins/will_paginate/CHANGELOG
  6. +0 −18 vendor/plugins/will_paginate/LICENSE
  7. +0 −131 vendor/plugins/will_paginate/README.rdoc
  8. +0 −62 vendor/plugins/will_paginate/Rakefile
  9. BIN vendor/plugins/will_paginate/examples/apple-circle.gif
  10. +0 −69 vendor/plugins/will_paginate/examples/index.haml
  11. +0 −92 vendor/plugins/will_paginate/examples/index.html
  12. +0 −90 vendor/plugins/will_paginate/examples/pagination.css
  13. +0 −91 vendor/plugins/will_paginate/examples/pagination.sass
  14. +0 −1 vendor/plugins/will_paginate/init.rb
  15. +0 −86 vendor/plugins/will_paginate/lib/will_paginate.rb
  16. +0 −16 vendor/plugins/will_paginate/lib/will_paginate/array.rb
  17. +0 −145 vendor/plugins/will_paginate/lib/will_paginate/collection.rb
  18. +0 −32 vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb
  19. +0 −247 vendor/plugins/will_paginate/lib/will_paginate/finder.rb
  20. +0 −132 vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb
  21. +0 −39 vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb
  22. +0 −9 vendor/plugins/will_paginate/lib/will_paginate/version.rb
  23. +0 −374 vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb
  24. +0 −21 vendor/plugins/will_paginate/test/boot.rb
  25. +0 −140 vendor/plugins/will_paginate/test/collection_test.rb
  26. +0 −8 vendor/plugins/will_paginate/test/console
  27. +0 −22 vendor/plugins/will_paginate/test/database.yml
  28. +0 −434 vendor/plugins/will_paginate/test/finder_test.rb
  29. +0 −3 vendor/plugins/will_paginate/test/fixtures/admin.rb
  30. +0 −13 vendor/plugins/will_paginate/test/fixtures/developer.rb
  31. +0 −13 vendor/plugins/will_paginate/test/fixtures/developers_projects.yml
  32. +0 −15 vendor/plugins/will_paginate/test/fixtures/project.rb
  33. +0 −6 vendor/plugins/will_paginate/test/fixtures/projects.yml
  34. +0 −29 vendor/plugins/will_paginate/test/fixtures/replies.yml
  35. +0 −7 vendor/plugins/will_paginate/test/fixtures/reply.rb
  36. +0 −38 vendor/plugins/will_paginate/test/fixtures/schema.rb
  37. +0 −6 vendor/plugins/will_paginate/test/fixtures/topic.rb
  38. +0 −30 vendor/plugins/will_paginate/test/fixtures/topics.yml
  39. +0 −2 vendor/plugins/will_paginate/test/fixtures/user.rb
  40. +0 −35 vendor/plugins/will_paginate/test/fixtures/users.yml
  41. +0 −37 vendor/plugins/will_paginate/test/helper.rb
  42. +0 −36 vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb
  43. +0 −69 vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb
  44. +0 −11 vendor/plugins/will_paginate/test/lib/load_fixtures.rb
  45. +0 −165 vendor/plugins/will_paginate/test/lib/view_test_process.rb
  46. +0 −56 vendor/plugins/will_paginate/test/tasks.rake
  47. +0 −355 vendor/plugins/will_paginate/test/view_test.rb
  48. +0 −21 vendor/plugins/will_paginate/will_paginate.gemspec
@@ -57,7 +57,7 @@ def self.paginate_by_params(params)
)
# inject the result array into the paginated collection:
- pager.replace(result)
+ pager.replace(result.collect(&:first))
unless pager.total_entries
# the pager didn't manage to guess the total count, do it manually
View
@@ -13,6 +13,7 @@
config.gem 'newrelic_rpm'
config.gem 'BlueCloth', :lib => 'bluecloth'
config.gem 'hpricot' # for comment processing / markdown fixing
+ config.gem 'mislav-will_paginate', :lib => 'will_paginate'
# Rmagick is *not* required (for example, sudara uses imagescience)
# config.gem 'rmagick', :lib => 'RMagick'
@@ -1,4 +0,0 @@
-/doc
-/rails
-*.gem
-/coverage
@@ -1,49 +0,0 @@
-CHANGELOG
-LICENSE
-README.rdoc
-Rakefile
-examples
-examples/apple-circle.gif
-examples/index.haml
-examples/index.html
-examples/pagination.css
-examples/pagination.sass
-init.rb
-lib
-lib/will_paginate
-lib/will_paginate.rb
-lib/will_paginate/array.rb
-lib/will_paginate/collection.rb
-lib/will_paginate/core_ext.rb
-lib/will_paginate/finder.rb
-lib/will_paginate/named_scope.rb
-lib/will_paginate/named_scope_patch.rb
-lib/will_paginate/version.rb
-lib/will_paginate/view_helpers.rb
-test
-test/boot.rb
-test/collection_test.rb
-test/console
-test/database.yml
-test/finder_test.rb
-test/fixtures
-test/fixtures/admin.rb
-test/fixtures/developer.rb
-test/fixtures/developers_projects.yml
-test/fixtures/project.rb
-test/fixtures/projects.yml
-test/fixtures/replies.yml
-test/fixtures/reply.rb
-test/fixtures/schema.rb
-test/fixtures/topic.rb
-test/fixtures/topics.yml
-test/fixtures/user.rb
-test/fixtures/users.yml
-test/helper.rb
-test/lib
-test/lib/activerecord_test_case.rb
-test/lib/activerecord_test_connector.rb
-test/lib/load_fixtures.rb
-test/lib/view_test_process.rb
-test/tasks.rake
-test/view_test.rb
@@ -1,92 +0,0 @@
-== master
-
-* ActiveRecord 2.1: remove :include from count query when tables are not
- referenced in :conditions
-
-== 2.3.2, released 2008-05-16
-
-* Fixed LinkRenderer#stringified_merge by removing "return" from iterator block
-* Ensure that 'href' values in pagination links are escaped URLs
-
-== 2.3.1, released 2008-05-04
-
-* Fixed page numbers not showing with custom routes and implicit first page
-* Try to use Hanna for documentation (falls back to default RDoc template if not)
-
-== 2.3.0, released 2008-04-29
-
-* Changed LinkRenderer to receive collection, options and reference to view template NOT in
- constructor, but with the #prepare method. This is a step towards supporting passing of
- LinkRenderer (or subclass) instances that may be preconfigured in some way
-* LinkRenderer now has #page_link and #page_span methods for easier customization of output in
- subclasses
-* Changed page_entries_info() method to adjust its output according to humanized class name of
- collection items. Override this with :entry_name parameter (singular).
-
- page_entries_info(@posts)
- #-> "Displaying all 12 posts"
- page_entries_info(@posts, :entry_name => 'item')
- #-> "Displaying all 12 items"
-
-== 2.2.3, released 2008-04-26
-
-* will_paginate gem is no longer published on RubyForge, but on
- gems.github.com:
-
- gem sources -a http://gems.github.com/ (you only need to do this once)
- gem install mislav-will_paginate
-
-* extract reusable pagination testing stuff into WillPaginate::View
-* rethink the page URL construction mechanizm to be more bulletproof when
- combined with custom routing for page parameter
-* test that anchor parameter can be used in pagination links
-
-== 2.2.2, released 2008-04-21
-
-* Add support for page parameter in custom routes like "/foo/page/2"
-* Change output of "page_entries_info" on single-page collection and erraneous
- output with empty collection as reported by Tim Chater
-
-== 2.2.1, released 2008-04-08
-
-* take less risky path when monkeypatching named_scope; fix that it no longer
- requires ActiveRecord::VERSION
-* use strings in "respond_to?" calls to work around a bug in acts_as_ferret
- stable (ugh)
-* add rake release task
-
-
-== 2.2.0, released 2008-04-07
-
-=== API changes
-* Rename WillPaginate::Collection#page_count to "total_pages" for consistency.
- If you implemented this interface, change your implementation accordingly.
-* Remove old, deprecated style of calling Array#paginate as "paginate(page,
- per_page)". If you want to specify :page, :per_page or :total_entries, use a
- parameter hash.
-* Rename LinkRenderer#url_options to "url_for" and drastically optimize it
-
-=== View changes
-* Added "prev_page" and "next_page" CSS classes on previous/next page buttons
-* Add examples of pagination links styling in "examples/index.html"
-* Change gap in pagination links from "..." to
- "<span class="gap">&hellip;</span>".
-* Add "paginated_section", a block helper that renders pagination both above and
- below content in the block
-* Add rel="prev|next|start" to page links
-
-=== Other
-
-* Add ability to opt-in for Rails 2.1 feature "named_scope" by calling
- WillPaginate.enable_named_scope (tested in Rails 1.2.6 and 2.0.2)
-* Support complex page parameters like "developers[page]"
-* Move Array#paginate definition to will_paginate/array.rb. You can now easily
- use pagination on arrays outside of Rails:
-
- gem 'will_paginate'
- require 'will_paginate/array'
-
-* Add "paginated_each" method for iterating through every record by loading only
- one page of records at the time
-* Rails 2: Rescue from WillPaginate::InvalidPage error with 404 Not Found by
- default
@@ -1,18 +0,0 @@
-Copyright (c) 2007 PJ Hyett and Mislav Marohnić
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,131 +0,0 @@
-= WillPaginate
-
-Pagination is just limiting the number of records displayed. Why should you let
-it get in your way while developing, then? This plugin makes magic happen. Did
-you ever want to be able to do just this on a model:
-
- Post.paginate :page => 1, :order => 'created_at DESC'
-
-... and then render the page links with a single view helper? Well, now you
-can.
-
-Some resources to get you started:
-
-* Your mind reels with questions? Join our
- {Google group}[http://groups.google.com/group/will_paginate].
-* The will_paginate project page: http://github.com/mislav/will_paginate
-* How to report bugs: http://github.com/mislav/will_paginate/wikis/report-bugs
-* Ryan Bates made an awesome screencast[http://railscasts.com/episodes/51],
- check it out.
-
-== Installation
-
-The recommended way is that you get the gem:
-
- gem install mislav-will_paginate --source http://gems.github.com/
-
-After that you don't need the will_paginate <i>plugin</i> in your Rails
-application anymore. Just add a simple require to the end of
-"config/environment.rb":
-
- gem 'mislav-will_paginate', '~> 2.2'
- require 'will_paginate'
-
-That's it. Remember to install the gem on <b>all</b> machines that you are
-deploying to.
-
-<i>There are extensive
-{installation instructions}[http://github.com/mislav/will_paginate/wikis/installation]
-on {the wiki}[http://github.com/mislav/will_paginate/wikis].</i>
-
-
-== Example usage
-
-Use a paginate finder in the controller:
-
- @posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC'
-
-Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the
-records. Don't forget to tell it which page you want, or it will complain!
-Read more on WillPaginate::Finder::ClassMethods.
-
-Render the posts in your view like you would normally do. When you need to render
-pagination, just stick this in:
-
- <%= will_paginate @posts %>
-
-You're done. (Copy and paste the example fancy CSS styles from the bottom.) You
-can find the option list at WillPaginate::ViewHelpers.
-
-How does it know how much items to fetch per page? It asks your model by calling
-its <tt>per_page</tt> class method. You can define it like this:
-
- class Post < ActiveRecord::Base
- cattr_reader :per_page
- @@per_page = 50
- end
-
-... or like this:
-
- class Post < ActiveRecord::Base
- def self.per_page
- 50
- end
- end
-
-... or don't worry about it at all. WillPaginate defines it to be <b>30</b> by default.
-But you can always specify the count explicitly when calling +paginate+:
-
- @posts = Post.paginate :page => params[:page], :per_page => 50
-
-The +paginate+ finder wraps the original finder and returns your resultset that now has
-some new properties. You can use the collection as you would with any ActiveRecord
-resultset. WillPaginate view helpers also need that object to be able to render pagination:
-
- <ol>
- <% for post in @posts -%>
- <li>Render `post` in some nice way.</li>
- <% end -%>
- </ol>
-
- <p>Now let's render us some pagination!</p>
- <%= will_paginate @posts %>
-
-More detailed documentation:
-
-* WillPaginate::Finder::ClassMethods for pagination on your models;
-* WillPaginate::ViewHelpers for your views.
-
-
-== Authors and credits
-
-Authors:: Mislav Marohnić, PJ Hyett
-Original announcement:: http://errtheblog.com/post/929
-Original PHP source:: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php
-
-All these people helped making will_paginate what it is now with their code
-contributions or just simply awesome ideas:
-
-Chris Wanstrath, Dr. Nic Williams, K. Adam Christensen, Mike Garey, Bence
-Golda, Matt Aimonetti, Charles Brian Quinn, Desi McAdam, James Coglan, Matijs
-van Zuijlen, Maria, Brendan Ribera, Todd Willey, Bryan Helmkamp, Jan Berkel,
-Lourens Naudé, Rick Olson, Russell Norris, Piotr Usewicz, Chris Eppstein.
-
-
-== Usable pagination in the UI
-
-There are some CSS styles to get you started in the "examples/" directory. They
-are showcased in the <b>"examples/index.html"</b> file.
-
-More reading about pagination as design pattern:
-
-* Pagination 101:
- http://kurafire.net/log/archive/2007/06/22/pagination-101
-* Pagination gallery:
- http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/
-* Pagination on Yahoo Design Pattern Library:
- http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination
-
-Want to discuss, request features, ask questions? Join the
-{Google group}[http://groups.google.com/group/will_paginate].
-
@@ -1,62 +0,0 @@
-require 'rubygems'
-begin
- hanna_dir = '/home/mislav/projects/hanna/lib'
- $:.unshift hanna_dir if File.exists? hanna_dir
- require 'hanna/rdoctask'
-rescue LoadError
- require 'rake'
- require 'rake/rdoctask'
-end
-load 'test/tasks.rake'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Generate RDoc documentation for the will_paginate plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG').
- include('lib/**/*.rb').
- exclude('lib/will_paginate/named_scope*').
- exclude('lib/will_paginate/array.rb').
- exclude('lib/will_paginate/version.rb')
-
- rdoc.main = "README.rdoc" # page to start on
- rdoc.title = "will_paginate documentation"
-
- rdoc.rdoc_dir = 'doc' # rdoc output folder
- rdoc.options << '--inline-source' << '--charset=UTF-8'
- rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/'
-end
-
-desc %{Update ".manifest" with the latest list of project filenames. Respect\
-.gitignore by excluding everything that git ignores. Update `files` and\
-`test_files` arrays in "*.gemspec" file if it's present.}
-task :manifest do
- list = Dir['**/*'].sort
- spec_file = Dir['*.gemspec'].first
- list -= [spec_file] if spec_file
-
- File.read('.gitignore').each_line do |glob|
- glob = glob.chomp.sub(/^\//, '')
- list -= Dir[glob]
- list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob)
- puts "excluding #{glob}"
- end
-
- if spec_file
- spec = File.read spec_file
- spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do
- assignment = $1
- bunch = $2 ? list.grep(/^test\//) : list
- '%s%%w(%s)' % [assignment, bunch.join(' ')]
- end
-
- File.open(spec_file, 'w') {|f| f << spec }
- end
- File.open('.manifest', 'w') {|f| f << list.join("\n") }
-end
-
-task :examples do
- %x(haml examples/index.haml examples/index.html)
- %x(sass examples/pagination.sass examples/pagination.css)
-end
Binary file not shown.
Oops, something went wrong.

0 comments on commit e7c456b

Please sign in to comment.