mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
documentation
This commit is contained in:
parent
aaf60cf2ee
commit
eb38f317f2
2 changed files with 40 additions and 10 deletions
21
CHANGELOG
21
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
|
== 0.11.0
|
||||||
|
|
||||||
This release contains several backward incompatibilities on template API.
|
This release contains several backward incompatibilities on template API.
|
||||||
|
|
29
README.rdoc
29
README.rdoc
|
@ -43,6 +43,7 @@ Put this line in your Gemfile:
|
||||||
Then bundle:
|
Then bundle:
|
||||||
% bundle
|
% bundle
|
||||||
|
|
||||||
|
|
||||||
== Usage
|
== Usage
|
||||||
|
|
||||||
=== Query Basics
|
=== Query Basics
|
||||||
|
@ -103,24 +104,24 @@ Run the following generator command, then edit the generated file.
|
||||||
<%= paginate @users, :window => 2 %>
|
<%= paginate @users, :window => 2 %>
|
||||||
This would output something like <tt>... 5 6 7 8 9 ...</tt> when 7 is the current page.
|
This would output something like <tt>... 5 6 7 8 9 ...</tt> 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 %>
|
<%= paginate @users, :outer_window => 3 %>
|
||||||
This would output something like <tt>1 2 3 4 ...(snip)... 17 18 19 20</tt> while having 20 pages in total.
|
This would output something like <tt>1 2 3 4 ...(snip)... 17 18 19 20</tt> 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 <tt>1 ...(snip)... 18 19 20</tt> while having 20 pages in total.
|
This would output something like <tt>1 ...(snip)... 18 19 20</tt> while having 20 pages in total.
|
||||||
|
|
||||||
* changing the parameter name (:+param_name+) for the links
|
* 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.
|
This would modify the query parameter name on each links.
|
||||||
|
|
||||||
* extra parameters (:+params+) for the 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.
|
This would modify each link's +url_option+. :+controller+ and :+action+ might be the keys in common.
|
||||||
|
|
||||||
* Ajax links (crazy simple, but works perfectly!)
|
* Ajax links (crazy simple, but works perfectly!)
|
||||||
|
@ -172,25 +173,33 @@ Kaminari includes a handy template generator.
|
||||||
* multiple themes
|
* 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.
|
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)
|
% rails g kaminari:views default (skip if you have existing kaminari views)
|
||||||
cd app/views/kaminari
|
% cd app/views/kaminari
|
||||||
mkdir my_custom_theme
|
% mkdir my_custom_theme
|
||||||
cp _*.html.* my_custom_theme/
|
% cp _*.html.* my_custom_theme/
|
||||||
|
|
||||||
Next reference that directory when calling the paginate method:
|
Next reference that directory when calling the paginate method:
|
||||||
|
|
||||||
% paginate @users, :theme => 'my_custom_theme'
|
<%= paginate @users, :theme => 'my_custom_theme' %>
|
||||||
|
|
||||||
Customize away!
|
Customize away!
|
||||||
|
|
||||||
Note: if the theme isn't present or none is specified, kaminari will default back to the views included within the gem.
|
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 <tt>paginate</tt> view helper.
|
||||||
|
However, the <tt>paginate</tt> helper doesn't automatically handle your Array object (this is an intensional design).
|
||||||
|
<tt>Kaminari::paginate_array</tt> method converts your Array object into a paginatable Array that accepts <tt>page</tt> method.
|
||||||
|
Kaminari.paginate_array(my_array_object).page(params[:page]).per(10)
|
||||||
|
|
||||||
|
|
||||||
== For more information
|
== For more information
|
||||||
|
|
||||||
Check out Kaminari recipes on the GitHub Wiki for more advanced tips and techniques.
|
Check out Kaminari recipes on the GitHub Wiki for more advanced tips and techniques.
|
||||||
https://github.com/amatsuda/kaminari/wiki/Kaminari-recipes
|
https://github.com/amatsuda/kaminari/wiki/Kaminari-recipes
|
||||||
|
|
||||||
|
|
||||||
== Questions, Feedback
|
== Questions, Feedback
|
||||||
|
|
||||||
Feel free to message me on Github (amatsuda) or Twitter (@a_matsuda) ☇☇☇ :)
|
Feel free to message me on Github (amatsuda) or Twitter (@a_matsuda) ☇☇☇ :)
|
||||||
|
|
Loading…
Reference in a new issue