Permalink
Browse files

Switching will_paginate to use plugin instead of gem

  • Loading branch information...
1 parent a58cce3 commit 5c1fd1d6ce327f734875b1e91775384553d9b292 @pat pat committed Oct 7, 2008
Showing with 3,453 additions and 4 deletions.
  1. +1 −4 config/environment.rb
  2. +4 −0 vendor/plugins/will_paginate/.gitignore
  3. +49 −0 vendor/plugins/will_paginate/.manifest
  4. +100 −0 vendor/plugins/will_paginate/CHANGELOG.rdoc
  5. +18 −0 vendor/plugins/will_paginate/LICENSE
  6. +107 −0 vendor/plugins/will_paginate/README.rdoc
  7. +62 −0 vendor/plugins/will_paginate/Rakefile
  8. BIN vendor/plugins/will_paginate/examples/apple-circle.gif
  9. +69 −0 vendor/plugins/will_paginate/examples/index.haml
  10. +92 −0 vendor/plugins/will_paginate/examples/index.html
  11. +90 −0 vendor/plugins/will_paginate/examples/pagination.css
  12. +91 −0 vendor/plugins/will_paginate/examples/pagination.sass
  13. +1 −0 vendor/plugins/will_paginate/init.rb
  14. +82 −0 vendor/plugins/will_paginate/lib/will_paginate.rb
  15. +16 −0 vendor/plugins/will_paginate/lib/will_paginate/array.rb
  16. +146 −0 vendor/plugins/will_paginate/lib/will_paginate/collection.rb
  17. +32 −0 vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb
  18. +260 −0 vendor/plugins/will_paginate/lib/will_paginate/finder.rb
  19. +170 −0 vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb
  20. +54 −0 vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch_1.2.6.rb
  21. +24 −0 vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch_2.0.rb
  22. +9 −0 vendor/plugins/will_paginate/lib/will_paginate/version.rb
  23. +383 −0 vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb
  24. +21 −0 vendor/plugins/will_paginate/test/boot.rb
  25. +143 −0 vendor/plugins/will_paginate/test/collection_test.rb
  26. +8 −0 vendor/plugins/will_paginate/test/console
  27. +459 −0 vendor/plugins/will_paginate/test/finder_test.rb
  28. +3 −0 vendor/plugins/will_paginate/test/fixtures/admin.rb
  29. +14 −0 vendor/plugins/will_paginate/test/fixtures/developer.rb
  30. +13 −0 vendor/plugins/will_paginate/test/fixtures/developers_projects.yml
  31. +15 −0 vendor/plugins/will_paginate/test/fixtures/project.rb
  32. +6 −0 vendor/plugins/will_paginate/test/fixtures/projects.yml
  33. +29 −0 vendor/plugins/will_paginate/test/fixtures/replies.yml
  34. +7 −0 vendor/plugins/will_paginate/test/fixtures/reply.rb
  35. +38 −0 vendor/plugins/will_paginate/test/fixtures/schema.rb
  36. +6 −0 vendor/plugins/will_paginate/test/fixtures/topic.rb
  37. +30 −0 vendor/plugins/will_paginate/test/fixtures/topics.yml
  38. +2 −0 vendor/plugins/will_paginate/test/fixtures/user.rb
  39. +35 −0 vendor/plugins/will_paginate/test/fixtures/users.yml
  40. +37 −0 vendor/plugins/will_paginate/test/helper.rb
  41. +36 −0 vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb
  42. +73 −0 vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb
  43. +11 −0 vendor/plugins/will_paginate/test/lib/load_fixtures.rb
  44. +165 −0 vendor/plugins/will_paginate/test/lib/view_test_process.rb
  45. +59 −0 vendor/plugins/will_paginate/test/tasks.rake
  46. +363 −0 vendor/plugins/will_paginate/test/view_test.rb
  47. +20 −0 vendor/plugins/will_paginate/will_paginate.gemspec
View
@@ -64,7 +64,4 @@
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector
-end
-
-gem 'mislav-will_paginate', '~> 2.2'
-require 'will_paginate'
+end
@@ -0,0 +1,4 @@
+/doc
+/rails
+*.gem
+/coverage
@@ -0,0 +1,49 @@
+CHANGELOG.rdoc
+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
@@ -0,0 +1,100 @@
+== 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://mislav.caboo.se/static/will_paginate/doc/)
+* 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
+
+== 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
@@ -0,0 +1,18 @@
+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.
@@ -0,0 +1,107 @@
+= 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:
+
+* {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]
+
+
+== 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. (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,
+Denis Barushev, Ben Pickles.
+
+
+== 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.caboo.se/static/will_paginate/].
+
+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].
+
@@ -0,0 +1,62 @@
+require 'rubygems'
+begin
+ hanna_dir = '/Users/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.rdoc').
+ 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit 5c1fd1d

Please sign in to comment.