From eb38f317f2733f0b59ad469fdd533f2df692179a Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 22 Apr 2011 12:52:25 +0900 Subject: [PATCH] documentation --- CHANGELOG | 21 +++++++++++++++++++++ README.rdoc | 29 +++++++++++++++++++---------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6f74c70..515973a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,24 @@ +== 0.12.0 + +* General configuration options #41 #62 [javierv, iain] + You can now globally override some default values such as default_per_page, + window, etc. via configuration file. + Also, here comes a generator command that generates the default + configuration file into your app's config/initilizers directory. + +* Generic pagination support for Array object #47 #68 #74 [lda ened jianlin] + You can now paginate through any kind of Arrayish object in this way: + Kaminari.paginate_array(my_array_object).page(params[:page]).per(10) + +* Fixed a serious performance regression in 0.11.0 [ankane] + There was a critical performance issue on #count method in 0.11.0 gem. + +* Bugfix: Pass the real @params to url_for #90 [utkarshkukreti] + +* Fixed a gem packaging problem (circular dependency) + There was a packaging problem with Kaminari 0.11.0 that the gem depends on + Kaminari gem. Maybe Jeweler + "gemspec" method didn't work well... + == 0.11.0 This release contains several backward incompatibilities on template API. diff --git a/README.rdoc b/README.rdoc index 83afa6c..2e291d5 100644 --- a/README.rdoc +++ b/README.rdoc @@ -43,6 +43,7 @@ Put this line in your Gemfile: Then bundle: % bundle + == Usage === Query Basics @@ -103,24 +104,24 @@ Run the following generator command, then edit the generated file. <%= paginate @users, :window => 2 %> This would output something like ... 5 6 7 8 9 ... when 7 is the current page. -* specifing the "outer window" size (1 by default) +* specifing the "outer window" size (0 by default) <%= paginate @users, :outer_window => 3 %> This would output something like 1 2 3 4 ...(snip)... 17 18 19 20 while having 20 pages in total. -* outer window can be separetely specified by +left+, +right+ (1 by default) +* outer window can be separetely specified by +left+, +right+ (0 by default) - <%= paginate @users, :left => 0, :right => 2 %> + <%= paginate @users, :left => 1, :right => 3 %> This would output something like 1 ...(snip)... 18 19 20 while having 20 pages in total. * changing the parameter name (:+param_name+) for the links - <%= paginate @users, :param_name => :pagina + <%= paginate @users, :param_name => :pagina %> This would modify the query parameter name on each links. * extra parameters (:+params+) for the links - <%= paginate @users, :params => {:controller => 'foo', :action => 'bar'} + <%= paginate @users, :params => {:controller => 'foo', :action => 'bar'} %> This would modify each link's +url_option+. :+controller+ and :+action+ might be the keys in common. * Ajax links (crazy simple, but works perfectly!) @@ -172,25 +173,33 @@ Kaminari includes a handy template generator. * multiple themes To utilize multiple themes from within a single application, create a directory within the app/views/kaminari/ and move your custom template files into that directory. - rails g kaminari:views default (skip if you have existing kaminari views) - cd app/views/kaminari - mkdir my_custom_theme - cp _*.html.* my_custom_theme/ + % rails g kaminari:views default (skip if you have existing kaminari views) + % cd app/views/kaminari + % mkdir my_custom_theme + % cp _*.html.* my_custom_theme/ Next reference that directory when calling the paginate method: - % paginate @users, :theme => 'my_custom_theme' + <%= paginate @users, :theme => 'my_custom_theme' %> Customize away! Note: if the theme isn't present or none is specified, kaminari will default back to the views included within the gem. +=== Paginating a generic Array object + +Kaminari provides an Array wrapper class that adapts a generic Array object to the paginate view helper. +However, the paginate helper doesn't automatically handle your Array object (this is an intensional design). +Kaminari::paginate_array method converts your Array object into a paginatable Array that accepts page method. + Kaminari.paginate_array(my_array_object).page(params[:page]).per(10) + == For more information Check out Kaminari recipes on the GitHub Wiki for more advanced tips and techniques. https://github.com/amatsuda/kaminari/wiki/Kaminari-recipes + == Questions, Feedback Feel free to message me on Github (amatsuda) or Twitter (@a_matsuda) ☇☇☇ :)