Permalink
Browse files

Latest will_paginate/rails3

  • Loading branch information...
lifo committed Jun 3, 2010
1 parent ff92009 commit 6f3bedfa1fa1d4481ab4794798f0af5e3041425c
Showing with 2,872 additions and 2,950 deletions.
  1. +4 −0 vendor/plugins/will_paginate/.gitignore
  2. +0 −43 vendor/plugins/will_paginate/.manifest
  3. +24 −58 vendor/plugins/will_paginate/CHANGELOG.rdoc
  4. +14 −0 vendor/plugins/will_paginate/Gemfile
  5. +1 −1 vendor/plugins/will_paginate/LICENSE
  6. +78 −60 vendor/plugins/will_paginate/README.rdoc
  7. +14 −35 vendor/plugins/will_paginate/Rakefile
  8. BIN vendor/plugins/will_paginate/examples/apple-circle.gif
  9. +0 −69 vendor/plugins/will_paginate/examples/index.haml
  10. +0 −92 vendor/plugins/will_paginate/examples/index.html
  11. +0 −90 vendor/plugins/will_paginate/examples/pagination.css
  12. +0 −91 vendor/plugins/will_paginate/examples/pagination.sass
  13. +11 −78 vendor/plugins/will_paginate/lib/will_paginate.rb
  14. +25 −8 vendor/plugins/will_paginate/lib/will_paginate/array.rb
  15. +8 −7 vendor/plugins/will_paginate/lib/will_paginate/collection.rb
  16. +26 −0 vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb
  17. +50 −0 vendor/plugins/will_paginate/lib/will_paginate/deprecation.rb
  18. +0 −264 vendor/plugins/will_paginate/lib/will_paginate/finder.rb
  19. +9 −0 vendor/plugins/will_paginate/lib/will_paginate/finders.rb
  20. +158 −0 vendor/plugins/will_paginate/lib/will_paginate/finders/active_record.rb
  21. +51 −0 vendor/plugins/will_paginate/lib/will_paginate/finders/active_resource.rb
  22. +112 −0 vendor/plugins/will_paginate/lib/will_paginate/finders/base.rb
  23. +30 −0 vendor/plugins/will_paginate/lib/will_paginate/finders/data_mapper.rb
  24. +23 −0 vendor/plugins/will_paginate/lib/will_paginate/finders/sequel.rb
  25. +0 −170 vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb
  26. +0 −37 vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb
  27. +24 −0 vendor/plugins/will_paginate/lib/will_paginate/railtie.rb
  28. +5 −5 vendor/plugins/will_paginate/lib/will_paginate/version.rb
  29. +25 −391 vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb
  30. +134 −0 vendor/plugins/will_paginate/lib/will_paginate/view_helpers/action_view.rb
  31. +126 −0 vendor/plugins/will_paginate/lib/will_paginate/view_helpers/base.rb
  32. +130 −0 vendor/plugins/will_paginate/lib/will_paginate/view_helpers/link_renderer.rb
  33. +83 −0 vendor/plugins/will_paginate/lib/will_paginate/view_helpers/link_renderer_base.rb
  34. +13 −0 vendor/plugins/will_paginate/lib/will_paginate/view_helpers/merb.rb
  35. +147 −0 vendor/plugins/will_paginate/spec/collection_spec.rb
  36. +2 −2 vendor/plugins/will_paginate/{test → spec}/console
  37. +8 −0 vendor/plugins/will_paginate/spec/console_fixtures.rb
  38. +3 −3 vendor/plugins/will_paginate/{test → spec}/database.yml
  39. +377 −0 vendor/plugins/will_paginate/spec/finders/active_record_spec.rb
  40. +52 −0 vendor/plugins/will_paginate/spec/finders/active_resource_spec.rb
  41. +114 −0 vendor/plugins/will_paginate/spec/finders/activerecord_test_connector.rb
  42. +62 −0 vendor/plugins/will_paginate/spec/finders/data_mapper_spec.rb
  43. +20 −0 vendor/plugins/will_paginate/spec/finders/data_mapper_test_connector.rb
  44. +53 −0 vendor/plugins/will_paginate/spec/finders/sequel_spec.rb
  45. +9 −0 vendor/plugins/will_paginate/spec/finders/sequel_test_connector.rb
  46. +76 −0 vendor/plugins/will_paginate/spec/finders_spec.rb
  47. 0 vendor/plugins/will_paginate/{test → spec}/fixtures/admin.rb
  48. +1 −2 vendor/plugins/will_paginate/{test → spec}/fixtures/developer.rb
  49. 0 vendor/plugins/will_paginate/{test → spec}/fixtures/developers_projects.yml
  50. +2 −4 vendor/plugins/will_paginate/{test → spec}/fixtures/project.rb
  51. +1 −1 vendor/plugins/will_paginate/{test → spec}/fixtures/projects.yml
  52. 0 vendor/plugins/will_paginate/{test → spec}/fixtures/replies.yml
  53. +1 −1 vendor/plugins/will_paginate/{test → spec}/fixtures/reply.rb
  54. 0 vendor/plugins/will_paginate/{test → spec}/fixtures/schema.rb
  55. +7 −0 vendor/plugins/will_paginate/spec/fixtures/topic.rb
  56. 0 vendor/plugins/will_paginate/{test → spec}/fixtures/topics.yml
  57. 0 vendor/plugins/will_paginate/{test → spec}/fixtures/user.rb
  58. 0 vendor/plugins/will_paginate/{test → spec}/fixtures/users.yml
  59. +2 −0 vendor/plugins/will_paginate/spec/rcov.opts
  60. +2 −0 vendor/plugins/will_paginate/spec/spec.opts
  61. +74 −0 vendor/plugins/will_paginate/spec/spec_helper.rb
  62. +60 −0 vendor/plugins/will_paginate/spec/tasks.rake
  63. +356 −0 vendor/plugins/will_paginate/spec/view_helpers/action_view_spec.rb
  64. +64 −0 vendor/plugins/will_paginate/spec/view_helpers/base_spec.rb
  65. +84 −0 vendor/plugins/will_paginate/spec/view_helpers/link_renderer_base_spec.rb
  66. +103 −0 vendor/plugins/will_paginate/spec/view_helpers/view_example_group.rb
  67. +0 −21 vendor/plugins/will_paginate/test/boot.rb
  68. +0 −143 vendor/plugins/will_paginate/test/collection_test.rb
  69. +0 −473 vendor/plugins/will_paginate/test/finder_test.rb
  70. +0 −10 vendor/plugins/will_paginate/test/fixtures/topic.rb
  71. +0 −37 vendor/plugins/will_paginate/test/helper.rb
  72. +0 −43 vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb
  73. +0 −75 vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb
  74. +0 −11 vendor/plugins/will_paginate/test/lib/load_fixtures.rb
  75. +0 −179 vendor/plugins/will_paginate/test/lib/view_test_process.rb
  76. +0 −59 vendor/plugins/will_paginate/test/tasks.rake
  77. +0 −373 vendor/plugins/will_paginate/test/view_test.rb
  78. +14 −14 vendor/plugins/will_paginate/will_paginate.gemspec
@@ -0,0 +1,4 @@
+.bundle
+doc
+*.gem
+coverage
@@ -1,43 +0,0 @@
-CHANGELOG.rdoc
-LICENSE
-README.rdoc
-Rakefile
-examples/apple-circle.gif
-examples/index.haml
-examples/index.html
-examples/pagination.css
-examples/pagination.sass
-init.rb
-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/boot.rb
-test/collection_test.rb
-test/console
-test/database.yml
-test/finder_test.rb
-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/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,59 +1,25 @@
-= 2.3.12, released 2009-12-01
-
-* make view helpers "HTML safe" for Rails 2.3.5 with rails_xss plugin
-
-= 2.3.11, released 2009-06-02
-
-* fix `enable_actionpack`
-
-= 2.3.10, released 2009-05-21
-
-* count_by_sql: don't use table alias with any adapters starting with "oracle"
-* Add back "AS count_table" alias to `paginate_by_sql` counter SQL
-
-= 2.3.9, released 2009-05-29
-
-* remove "AS count_table" alias from `paginate_by_sql` counter SQL
-* Rails 2.3.2 compat: monkeypatch Rails issue #2189 (count breaks has_many :through)
-* fix generation of page URLs that contain the "@" character
-* check for method existance in a ruby 1.8- and 1.9-compatible way
-* load will_paginate view helpers even if ActiveRecord is not loaded
-
-== 2.3.8, released 2009-03-09
-
-* Rails 2.3 compat: query parameter parsing with Rack
-
-== 2.3.7, released 2009-02-09
-
-* Removed all unnecessary &block variables since they cause serious memory damage and lots of subsequent gc runs.
-
-== 2.3.6, released 2008-10-26
-
-* Rails 2.2 fix: stop using `extract_attribute_names_from_match` inernal AR method, it no longer exists
-
-== 2.3.5, released 2008-10-07
-
-* update the backported named_scope implementation for Rails versions older than 2.1
-* break out of scope of paginated_each() yielded block when used on named scopes
-* fix paginate(:from)
-
-== 2.3.4, released 2008-09-16
-
-* Removed gem dependency to Active Support (causes trouble with vendored rails).
-* Rails 2.1: fix a failing test and a deprecation warning.
-* Cope with scoped :select when counting.
-
-== 2.3.3, released 2008-08-29
-
-* Ensure that paginate_by_sql doesn't change the original SQL query.
-* RDoc love (now live at http://gitrdoc.com/mislav/will_paginate/tree/master)
-* Rename :prev_label to :previous_label for consistency. old name still functions but is deprecated
-* ActiveRecord 2.1: Remove :include option from count_all query when it's possible.
-
-== 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
+== "agnostic" branch
+
+* added Sequel support
+* added an initialization hook for Merb
+* refactored URL generation
+* BACKWARDS INCOMPATIBLE: refactored LinkRenderer; also markup changes
+ <span class="current">1</span> is now <em>1</em>
+ a.prev_page -> a.previous_page (for consistency)
+* "prev_label" -> "previous_label"
+* ported view tests to specs
+* setup Autotest
+* added per_page=(limit) attribute writer to set default per_page
+* Remove :include option from count_all query when possible (Rails 2.1)
+* added WP::ViewHelpers::ActionView and LinkRenderer
+* specs for ViewHelpers::Base and LinkRendererBase
+* created LinkRendererBase that implements windowed visible page numbers logic
+* created WP::ViewHelpers::Base abstract module that implements generic view helpers
+* ported finder tests to specs
+* added WP::Finders::DataMapper
+* added WP::Finders::ActiveRecord mixin for ActiveRecord::Base
+* created WP::Finders::Base abstract module that implements generic pagination logic
+* removed dependency to ActiveSupport
== 2.3.1, released 2008-05-04
@@ -84,14 +50,14 @@
gem install mislav-will_paginate
* extract reusable pagination testing stuff into WillPaginate::View
-* rethink the page URL construction mechanizm to be more bulletproof when
+* rethink the page URL construction mechanism 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
+* Change output of "page_entries_info" on single-page collection and erroneous
output with empty collection as reported by Tim Chater
== 2.2.1, released 2008-04-08
@@ -0,0 +1,14 @@
+git 'git://github.com/rails/rails.git'
+source :gemcutter
+
+gem 'activerecord', '~> 3.0.0.beta3'
+gem 'activeresource', '~> 3.0.0.beta3'
+gem 'actionpack', '~> 3.0.0.beta3'
+gem 'sequel', '~> 3.8.0'
+gem 'rspec', '~> 1.3.0'
+gem 'mocha', '~> 0.9.8'
+gem 'sqlite3-ruby', '~> 1.2.5'
+gem 'dm-core', '~> 0.10.2'
+gem 'do_sqlite3', '~> 0.10.1.1'
+gem 'mysql', '~> 2.8.1'
+gem 'pg', '~> 0.8.0'
@@ -1,4 +1,4 @@
-Copyright (c) 2007 PJ Hyett and Mislav Marohnić
+Copyright (c) 2009 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
@@ -1,64 +1,90 @@
-= WillPaginate
+= The will_paginate Ruby library
-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:
+Pagination is just limiting the number of records loaded and displayed. Why should you let it get in
+your way while developing?
+
+This is how you paginate on an ActiveRecord model:
Post.paginate :page => 1, :order => 'created_at DESC'
-... and then render the page links with a single view helper? Well, now you
-can.
+Most of the time it's as simple as replacing "find" with "paginate" and specifying the page you want.
Some resources to get you started:
-* {Installation instructions}[http://github.com/mislav/will_paginate/wikis/installation]
- on {the wiki}[http://github.com/mislav/will_paginate/wikis]
-* Your mind reels with questions? Join our
- {Google group}[http://groups.google.com/group/will_paginate].
-* {How to report bugs}[http://github.com/mislav/will_paginate/wikis/report-bugs]
+* The {will_paginate project page}[http://mislav.github.com/will_paginate/];
+* Your mind reels with questions? Join our {Google group}[http://groups.google.com/group/will_paginate];
+* {How to report bugs}[http://github.com/mislav/will_paginate/wikis/report-bugs];
+* {Watch the will_paginate screencast}[http://railscasts.com/episodes/51] by Ryan Bates.
+== I'm not using Rails; can I still use will_paginate?
-== Example usage
+Absolutely -- although will_paginate started off as a Rails plugin, now it is a <em>completely
+framework-agnostic</em> library with support for Rails and Merb built-in. The core library doesn't
+have any dependences and you can safely use it in any Ruby code.
-Use a paginate finder in the controller:
+When will_paginate is loaded in an environment where ActiveRecord and ActionView are present, it
+automatically hooks into these frameworks to provide easy pagination on your models and in your
+views. The same mechanism works for Merb applications, too. But, if no known framework is present
+then you have absolute control over what parts of will_paginate do you want to load and where you want
+them mixed in.
- @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.
+== Installation
-Render the posts in your view like you would normally do. When you need to render
-pagination, just stick this in:
+The recommended way is that you get the gem hosted on {gems.github.com}[http://gems.github.com/]:
- <%= will_paginate @posts %>
+ gem install mislav-will_paginate
-You're done. (You can find the option list at WillPaginate::ViewHelpers.)
+In <b>Rails 2.1</b>, add a gem dependency:
-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:
+ # for Rails 2.1 and newer
+ config.gem 'mislav-will_paginate', :lib => 'will_paginate', :version => '~> 3.0'
- class Post < ActiveRecord::Base
- cattr_reader :per_page
- @@per_page = 50
- end
+If you're using Rails 2.0 or older, or any other Ruby framework, just add a simple require to a file
+that initializes your application. For example, in Rails you would put this at the end of
+"config/environment.rb".
+
+ gem 'mislav-will_paginate', '~> 3.0'
+ require 'will_paginate'
+
+That's it. Remember to install the gem on <strong>all</strong> 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
+
+Typical usage involves a paginating find in the controller:
+
+ @posts = Post.paginate :page => params[:page], :order => 'updated_at DESC'
+
+It's true: +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 in WillPaginate::Finders.
+
+Render the posts in your view like you would normally do, and when you need to render pagination,
+just stick this in:
+
+ <%= will_paginate @posts %>
+
+You're done. Read more in WillPaginate::ViewHelpers::Base.
-... or like this:
+How does it know how much items to fetch per page? It asks your model by calling its
++per_page+ class method. You can define it like this:
class Post < ActiveRecord::Base
- def self.per_page
- 50
- end
+ self.per_page = 50
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+:
+... or don't worry about it at all. WillPaginate defines it to be <strong>30</strong> by default. You can
+always specify the count explicitly when calling +paginate+:
- @posts = Post.paginate :page => params[:page], :per_page => 50
+ 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:
+The +paginate+ finder wraps the original finder and returns your result set that now has some new
+properties. You can use the collection as you would use any other array. WillPaginate view helpers
+also need that collection object to be able to render pagination:
<ol>
<% for post in @posts -%>
@@ -69,39 +95,31 @@ resultset. WillPaginate view helpers also need that object to be able to render
<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
+The original author of will_paginate was PJ Hyett, who later handed over development to Mislav
+Marohnić. (The library was completely rewritten since then.)
-All these people helped making will_paginate what it is now with their code
-contributions or just simply awesome ideas:
+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,
-Denis Barushev, Ben Pickles.
+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, Brandon Arbini, Denis Barushev, Paul Barry, Ben Pickles, Ken Collins, Lida Tang and Pieter
+Noordhuis.
== Usable pagination in the UI
-There are some CSS styles to get you started in the "examples/" directory. They
-are {showcased online here}[http://mislav.uniqpath.com/will_paginate/].
+There are example CSS styles to get you started on the will_paginate project page.
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].
+* {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/] featured on Smashing Magazine;
+* {Pagination design pattern}[http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination] on Yahoo Design Pattern Library.
+Want to discuss, request features, ask questions? Join the {Google
+group}[http://groups.google.com/group/will_paginate].
Oops, something went wrong.

0 comments on commit 6f3bedf

Please sign in to comment.