dweinand-will_paginate 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. data/CHANGELOG.rdoc +100 -0
  2. data/LICENSE +18 -0
  3. data/README.rdoc +196 -0
  4. data/Rakefile +62 -0
  5. data/examples/apple-circle.gif +0 -0
  6. data/examples/index.haml +69 -0
  7. data/examples/index.html +92 -0
  8. data/examples/pagination.css +90 -0
  9. data/examples/pagination.sass +91 -0
  10. data/init.rb +1 -0
  11. data/lib/will_paginate/array.rb +16 -0
  12. data/lib/will_paginate/collection.rb +175 -0
  13. data/lib/will_paginate/core_ext.rb +32 -0
  14. data/lib/will_paginate/deserializer.rb +97 -0
  15. data/lib/will_paginate/finder.rb +256 -0
  16. data/lib/will_paginate/named_scope.rb +132 -0
  17. data/lib/will_paginate/named_scope_patch.rb +39 -0
  18. data/lib/will_paginate/version.rb +9 -0
  19. data/lib/will_paginate/view_helpers.rb +383 -0
  20. data/lib/will_paginate.rb +94 -0
  21. data/test/boot.rb +22 -0
  22. data/test/collection_test.rb +161 -0
  23. data/test/console +8 -0
  24. data/test/database.yml +22 -0
  25. data/test/finder_test.rb +448 -0
  26. data/test/fixtures/admin.rb +3 -0
  27. data/test/fixtures/developer.rb +14 -0
  28. data/test/fixtures/developers_projects.yml +13 -0
  29. data/test/fixtures/project.rb +15 -0
  30. data/test/fixtures/projects.yml +6 -0
  31. data/test/fixtures/replies.yml +29 -0
  32. data/test/fixtures/reply.rb +7 -0
  33. data/test/fixtures/schema.rb +38 -0
  34. data/test/fixtures/topic.rb +6 -0
  35. data/test/fixtures/topics.yml +30 -0
  36. data/test/fixtures/user.rb +2 -0
  37. data/test/fixtures/users.yml +35 -0
  38. data/test/helper.rb +42 -0
  39. data/test/lib/activerecord_test_case.rb +36 -0
  40. data/test/lib/activerecord_test_connector.rb +73 -0
  41. data/test/lib/load_fixtures.rb +11 -0
  42. data/test/lib/view_test_process.rb +165 -0
  43. data/test/tasks.rake +59 -0
  44. data/test/view_test.rb +363 -0
  45. metadata +133 -0
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,100 @@
1
+ == 2.3.4, released 2008-09-16
2
+
3
+ * Removed gem dependency to Active Support (causes trouble with vendored rails).
4
+ * Rails 2.1: fix a failing test and a deprecation warning.
5
+ * Cope with scoped :select when counting.
6
+
7
+ == 2.3.3, released 2008-08-29
8
+
9
+ * Ensure that paginate_by_sql doesn't change the original SQL query.
10
+ * RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/)
11
+ * Rename :prev_label to :previous_label for consistency. old name still functions but is deprecated
12
+ * ActiveRecord 2.1: Remove :include option from count_all query when it's possible.
13
+
14
+ == 2.3.2, released 2008-05-16
15
+
16
+ * Fixed LinkRenderer#stringified_merge by removing "return" from iterator block
17
+ * Ensure that 'href' values in pagination links are escaped URLs
18
+
19
+ == 2.3.1, released 2008-05-04
20
+
21
+ * Fixed page numbers not showing with custom routes and implicit first page
22
+ * Try to use Hanna for documentation (falls back to default RDoc template if not)
23
+
24
+ == 2.3.0, released 2008-04-29
25
+
26
+ * Changed LinkRenderer to receive collection, options and reference to view template NOT in
27
+ constructor, but with the #prepare method. This is a step towards supporting passing of
28
+ LinkRenderer (or subclass) instances that may be preconfigured in some way
29
+ * LinkRenderer now has #page_link and #page_span methods for easier customization of output in
30
+ subclasses
31
+ * Changed page_entries_info() method to adjust its output according to humanized class name of
32
+ collection items. Override this with :entry_name parameter (singular).
33
+
34
+ page_entries_info(@posts)
35
+ #-> "Displaying all 12 posts"
36
+ page_entries_info(@posts, :entry_name => 'item')
37
+ #-> "Displaying all 12 items"
38
+
39
+ == 2.2.3, released 2008-04-26
40
+
41
+ * will_paginate gem is no longer published on RubyForge, but on
42
+ gems.github.com:
43
+
44
+ gem sources -a http://gems.github.com/ (you only need to do this once)
45
+ gem install mislav-will_paginate
46
+
47
+ * extract reusable pagination testing stuff into WillPaginate::View
48
+ * rethink the page URL construction mechanizm to be more bulletproof when
49
+ combined with custom routing for page parameter
50
+ * test that anchor parameter can be used in pagination links
51
+
52
+ == 2.2.2, released 2008-04-21
53
+
54
+ * Add support for page parameter in custom routes like "/foo/page/2"
55
+ * Change output of "page_entries_info" on single-page collection and erraneous
56
+ output with empty collection as reported by Tim Chater
57
+
58
+ == 2.2.1, released 2008-04-08
59
+
60
+ * take less risky path when monkeypatching named_scope; fix that it no longer
61
+ requires ActiveRecord::VERSION
62
+ * use strings in "respond_to?" calls to work around a bug in acts_as_ferret
63
+ stable (ugh)
64
+ * add rake release task
65
+
66
+
67
+ == 2.2.0, released 2008-04-07
68
+
69
+ === API changes
70
+ * Rename WillPaginate::Collection#page_count to "total_pages" for consistency.
71
+ If you implemented this interface, change your implementation accordingly.
72
+ * Remove old, deprecated style of calling Array#paginate as "paginate(page,
73
+ per_page)". If you want to specify :page, :per_page or :total_entries, use a
74
+ parameter hash.
75
+ * Rename LinkRenderer#url_options to "url_for" and drastically optimize it
76
+
77
+ === View changes
78
+ * Added "prev_page" and "next_page" CSS classes on previous/next page buttons
79
+ * Add examples of pagination links styling in "examples/index.html"
80
+ * Change gap in pagination links from "..." to
81
+ "<span class="gap">&hellip;</span>".
82
+ * Add "paginated_section", a block helper that renders pagination both above and
83
+ below content in the block
84
+ * Add rel="prev|next|start" to page links
85
+
86
+ === Other
87
+
88
+ * Add ability to opt-in for Rails 2.1 feature "named_scope" by calling
89
+ WillPaginate.enable_named_scope (tested in Rails 1.2.6 and 2.0.2)
90
+ * Support complex page parameters like "developers[page]"
91
+ * Move Array#paginate definition to will_paginate/array.rb. You can now easily
92
+ use pagination on arrays outside of Rails:
93
+
94
+ gem 'will_paginate'
95
+ require 'will_paginate/array'
96
+
97
+ * Add "paginated_each" method for iterating through every record by loading only
98
+ one page of records at the time
99
+ * Rails 2: Rescue from WillPaginate::InvalidPage error with 404 Not Found by
100
+ default
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2007 PJ Hyett and Mislav Marohnić
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,196 @@
1
+ = WillPaginate
2
+
3
+ Pagination is just limiting the number of records displayed. Why should you let
4
+ it get in your way while developing, then? This plugin makes magic happen. Did
5
+ you ever want to be able to do just this on an ActiveRecord model:
6
+
7
+ Post.paginate :page => 1, :order => 'created_at DESC'
8
+
9
+ ... or this on an ActiveResource model:
10
+
11
+ Post.paginate :params => {:page => 1, :order => 'created_at DESC'}
12
+
13
+ ... and then render the page links with a single view helper? Well, now you
14
+ can.
15
+
16
+ Some resources to get you started:
17
+
18
+ * {Installation instructions}[http://github.com/mislav/will_paginate/wikis/installation]
19
+ on {the wiki}[http://github.com/mislav/will_paginate/wikis]
20
+ * Your mind reels with questions? Join our
21
+ {Google group}[http://groups.google.com/group/will_paginate].
22
+ * {How to report bugs}[http://github.com/mislav/will_paginate/wikis/report-bugs]
23
+
24
+
25
+ == Example usage
26
+
27
+ === ActiveRecord
28
+
29
+ Use a paginate finder in the controller:
30
+
31
+ @posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC'
32
+
33
+ Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the
34
+ records. Don't forget to tell it which page you want, or it will complain!
35
+ Read more on WillPaginate::Finder::ClassMethods.
36
+
37
+ Render the posts in your view like you would normally do. When you need to render
38
+ pagination, just stick this in:
39
+
40
+ <%= will_paginate @posts %>
41
+
42
+ You're done. (You can find the option list at WillPaginate::ViewHelpers.)
43
+
44
+ How does it know how much items to fetch per page? It asks your model by calling
45
+ its <tt>per_page</tt> class method. You can define it like this:
46
+
47
+ class Post < ActiveRecord::Base
48
+ cattr_reader :per_page
49
+ @@per_page = 50
50
+ end
51
+
52
+ ... or like this:
53
+
54
+ class Post < ActiveRecord::Base
55
+ def self.per_page
56
+ 50
57
+ end
58
+ end
59
+
60
+ ... or don't worry about it at all. WillPaginate defines it to be <b>30</b> by default.
61
+ But you can always specify the count explicitly when calling +paginate+:
62
+
63
+ @posts = Post.paginate :page => params[:page], :per_page => 50
64
+
65
+ The +paginate+ finder wraps the original finder and returns your resultset that now has
66
+ some new properties. You can use the collection as you would with any ActiveRecord
67
+ resultset. WillPaginate view helpers also need that object to be able to render pagination:
68
+
69
+ <ol>
70
+ <% for post in @posts -%>
71
+ <li>Render `post` in some nice way.</li>
72
+ <% end -%>
73
+ </ol>
74
+
75
+ <p>Now let's render us some pagination!</p>
76
+ <%= will_paginate @posts %>
77
+
78
+ More detailed documentation:
79
+
80
+ * WillPaginate::Finder::ClassMethods for pagination on your models;
81
+ * WillPaginate::ViewHelpers for your views.
82
+
83
+ === ActiveResource
84
+
85
+ Use an +ActiveResource+ paginate finder in the client controller:
86
+
87
+ @posts = Post.paginate :params => {:board_id => @board.id, :page => params[:page]}
88
+
89
+ Yeah, +paginate+ works just like +find+ -- it just will paginate the results. If your server returns a standard +to_xml+ from a +find+ on ActiveRecord, then the result will be paginated as an Array. However, querying for all records and only picking out what you want is inefficient. If your server uses WillPaginate, and returns a +to_xml+ from a +paginate+ on ActiveRecord then you will only get what you ask for without doing another "paginate" call on a client-side Array. Don't forget to tell it which page you want, or it will complain!
90
+ Read more on WillPaginate::Deserializer::ClassMethods.
91
+
92
+ Use an +ActiveRecord+ paginate finder in the server controller:
93
+
94
+ @posts = Post.paginate_by_board_id @board.id, :page => params[:page], :per_page => params[:per_page]}
95
+ respond_to do |format|
96
+ format.xml { render :xml => @posts.to_xml }
97
+ end
98
+
99
+ Behind the scenes, the XML generated will be something like:
100
+
101
+ <posts type="collection">
102
+ <current-page>1</current-page>
103
+ <per-page>30</per-page>
104
+ <total-entries>1337</total-entries>
105
+ ...
106
+ </posts>
107
+ instead of the traditional:
108
+
109
+ <posts type="array">
110
+ ...
111
+ </posts>
112
+
113
+ And once again, even if your server does not use WillPaginate your client-side call will still fallback to paginating on the complete resultset +Array+.
114
+
115
+ Render the posts in your view like you would normally do. When you need to render
116
+ pagination, just stick this in:
117
+
118
+ <%= will_paginate @posts %>
119
+
120
+ You're done. (Copy and paste the example fancy CSS styles from the bottom.) You
121
+ can find the option list at WillPaginate::ViewHelpers.
122
+
123
+ How does it know how much items to fetch per page? It asks your model by calling
124
+ its <tt>per_page</tt> class method. You can define it like this:
125
+
126
+ class Post < ActiveResource::Base
127
+ self.site = "http://api.forum.com:3000/"
128
+
129
+ cattr_reader :per_page
130
+ @@per_page = 50
131
+ end
132
+
133
+ ... or like this:
134
+
135
+ class Post < ActiveResource::Base
136
+ self.site = "http://api.forum.com:3000/"
137
+
138
+ def self.per_page
139
+ 50
140
+ end
141
+ end
142
+
143
+ ... or don't worry about it at all. WillPaginate defines it to be <b>30</b> by default.
144
+ But you can always specify the count explicitly when calling +paginate+:
145
+
146
+ @posts = Post.paginate :params => {:page => params[:page], :per_page => 50}
147
+
148
+ The +paginate+ finder wraps the original finder and returns your resultset that now has
149
+ some new properties. You can use the collection as you would with any ActiveResource
150
+ resultset. WillPaginate view helpers also need that object to be able to render pagination:
151
+
152
+ <ol>
153
+ <% for post in @posts -%>
154
+ <li>Render `post` in some nice way.</li>
155
+ <% end -%>
156
+ </ol>
157
+
158
+ <p>Now let's render us some pagination!</p>
159
+ <%= will_paginate @posts %>
160
+
161
+ More detailed documentation:
162
+
163
+ * WillPaginate::Deserializer::ClassMethods for pagination on your models;
164
+ * WillPaginate::ViewHelpers for your views.
165
+
166
+
167
+ == Authors and credits
168
+
169
+ Authors:: Mislav Marohnić, PJ Hyett
170
+ Original announcement:: http://errtheblog.com/post/929
171
+ Original PHP source:: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php
172
+
173
+ All these people helped making will_paginate what it is now with their code
174
+ contributions or just simply awesome ideas:
175
+
176
+ Chris Wanstrath, Dr. Nic Williams, K. Adam Christensen, Mike Garey, Bence
177
+ Golda, Matt Aimonetti, Charles Brian Quinn, Desi McAdam, James Coglan, Matijs
178
+ van Zuijlen, Maria, Brendan Ribera, Todd Willey, Bryan Helmkamp, Jan Berkel,
179
+ Lourens Naudé, Rick Olson, Russell Norris, Piotr Usewicz, Chris Eppstein,
180
+ Denis Barushev, Ben Pickles.
181
+
182
+
183
+ == Usable pagination in the UI
184
+
185
+ There are some CSS styles to get you started in the "examples/" directory. They
186
+ are {showcased online here}[http://mislav.caboo.se/static/will_paginate/].
187
+
188
+ More reading about pagination as design pattern:
189
+
190
+ * {Pagination 101}[http://kurafire.net/log/archive/2007/06/22/pagination-101]
191
+ * {Pagination gallery}[http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/]
192
+ * {Pagination on Yahoo Design Pattern Library}[http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination]
193
+
194
+ Want to discuss, request features, ask questions? Join the
195
+ {Google group}[http://groups.google.com/group/will_paginate].
196
+
data/Rakefile ADDED
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ begin
3
+ hanna_dir = '/Users/mislav/Projects/Hanna/lib'
4
+ $:.unshift hanna_dir if File.exists? hanna_dir
5
+ require 'hanna/rdoctask'
6
+ rescue LoadError
7
+ require 'rake'
8
+ require 'rake/rdoctask'
9
+ end
10
+ load 'test/tasks.rake'
11
+
12
+ desc 'Default: run unit tests.'
13
+ task :default => :test
14
+
15
+ desc 'Generate RDoc documentation for the will_paginate plugin.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG.rdoc').
18
+ include('lib/**/*.rb').
19
+ exclude('lib/will_paginate/named_scope*').
20
+ exclude('lib/will_paginate/array.rb').
21
+ exclude('lib/will_paginate/version.rb')
22
+
23
+ rdoc.main = "README.rdoc" # page to start on
24
+ rdoc.title = "will_paginate documentation"
25
+
26
+ rdoc.rdoc_dir = 'doc' # rdoc output folder
27
+ rdoc.options << '--inline-source' << '--charset=UTF-8'
28
+ rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/'
29
+ end
30
+
31
+ desc %{Update ".manifest" with the latest list of project filenames. Respect\
32
+ .gitignore by excluding everything that git ignores. Update `files` and\
33
+ `test_files` arrays in "*.gemspec" file if it's present.}
34
+ task :manifest do
35
+ list = Dir['**/*'].sort
36
+ spec_file = Dir['*.gemspec'].first
37
+ list -= [spec_file] if spec_file
38
+
39
+ File.read('.gitignore').each_line do |glob|
40
+ glob = glob.chomp.sub(/^\//, '')
41
+ list -= Dir[glob]
42
+ list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob)
43
+ puts "excluding #{glob}"
44
+ end
45
+
46
+ if spec_file
47
+ spec = File.read spec_file
48
+ spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do
49
+ assignment = $1
50
+ bunch = $2 ? list.grep(/^test\//) : list
51
+ '%s%%w(%s)' % [assignment, bunch.join(' ')]
52
+ end
53
+
54
+ File.open(spec_file, 'w') {|f| f << spec }
55
+ end
56
+ File.open('.manifest', 'w') {|f| f << list.join("\n") }
57
+ end
58
+
59
+ task :examples do
60
+ %x(haml examples/index.haml examples/index.html)
61
+ %x(sass examples/pagination.sass examples/pagination.css)
62
+ end
Binary file
@@ -0,0 +1,69 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title Samples of pagination styling for will_paginate
5
+ %link{ :rel => 'stylesheet', :type => 'text/css', :href => 'pagination.css' }
6
+ %style{ :type => 'text/css' }
7
+ :sass
8
+ html
9
+ :margin 0
10
+ :padding 0
11
+ :background #999
12
+ :font normal 76% "Lucida Grande", Verdana, Helvetica, sans-serif
13
+ body
14
+ :margin 2em
15
+ :padding 2em
16
+ :border 2px solid gray
17
+ :background white
18
+ :color #222
19
+ h1
20
+ :font-size 2em
21
+ :font-weight normal
22
+ :margin 0 0 1em 0
23
+ h2
24
+ :font-size 1.4em
25
+ :margin 1em 0 .5em 0
26
+ pre
27
+ :font-size 13px
28
+ :font-family Monaco, "DejaVu Sans Mono", "Bitstream Vera Mono", "Courier New", monospace
29
+
30
+ - pagination = '<span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>'
31
+ - pagination_no_page_links = '<span class="disabled prev_page">&laquo; Previous</span> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>'
32
+
33
+ %body
34
+ %h1 Samples of pagination styling for will_paginate
35
+ %p
36
+ Find these styles in <b>"examples/pagination.css"</b> of <i>will_paginate</i> library.
37
+ There is a Sass version of it for all you sassy people.
38
+ %p
39
+ Read about good rules for pagination:
40
+ %a{ :href => 'http://kurafire.net/log/archive/2007/06/22/pagination-101' } Pagination 101
41
+ %p
42
+ %em Warning:
43
+ page links below don't lead anywhere (so don't click on them).
44
+
45
+ %h2 Unstyled pagination <span style="font-weight:normal">(<i>ewww!</i>)</span>
46
+ %div= pagination
47
+
48
+ %h2 Digg.com
49
+ .digg_pagination= pagination
50
+
51
+ %h2 Digg-style, no page links
52
+ .digg_pagination= pagination_no_page_links
53
+ %p Code that renders this:
54
+ %pre= '<code>%s</code>' % %[<%= will_paginate @posts, :page_links => false %>].gsub('<', '&lt;').gsub('>', '&gt;')
55
+
56
+ %h2 Digg-style, extra content
57
+ .digg_pagination
58
+ .page_info Displaying entries <b>1&nbsp;-&nbsp;6</b> of <b>180</b> in total
59
+ = pagination
60
+ %p Code that renders this:
61
+ %pre= '<code>%s</code>' % %[<div class="digg_pagination">\n <div clas="page_info">\n <%= page_entries_info @posts %>\n </div>\n <%= will_paginate @posts, :container => false %>\n</div>].gsub('<', '&lt;').gsub('>', '&gt;')
62
+
63
+ %h2 Apple.com store
64
+ .apple_pagination= pagination
65
+
66
+ %h2 Flickr.com
67
+ .flickr_pagination
68
+ = pagination
69
+ .page_info (118 photos)
@@ -0,0 +1,92 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ </html>
4
+ <head>
5
+ <title>Samples of pagination styling for will_paginate</title>
6
+ <link href='pagination.css' rel='stylesheet' type='text/css' />
7
+ <style type='text/css'>
8
+ html {
9
+ margin: 0;
10
+ padding: 0;
11
+ background: #999;
12
+ font: normal 76% "Lucida Grande", Verdana, Helvetica, sans-serif; }
13
+
14
+ body {
15
+ margin: 2em;
16
+ padding: 2em;
17
+ border: 2px solid gray;
18
+ background: white;
19
+ color: #222; }
20
+
21
+ h1 {
22
+ font-size: 2em;
23
+ font-weight: normal;
24
+ margin: 0 0 1em 0; }
25
+
26
+ h2 {
27
+ font-size: 1.4em;
28
+ margin: 1em 0 .5em 0; }
29
+
30
+ pre {
31
+ font-size: 13px;
32
+ font-family: Monaco, "DejaVu Sans Mono", "Bitstream Vera Mono", "Courier New", monospace; }
33
+ </style>
34
+ </head>
35
+ <body>
36
+ <h1>Samples of pagination styling for will_paginate</h1>
37
+ <p>
38
+ Find these styles in <b>"examples/pagination.css"</b> of <i>will_paginate</i> library.
39
+ There is a Sass version of it for all you sassy people.
40
+ </p>
41
+ <p>
42
+ Read about good rules for pagination:
43
+ <a href='http://kurafire.net/log/archive/2007/06/22/pagination-101'>Pagination 101</a>
44
+ </p>
45
+ <p>
46
+ <em>Warning:</em>
47
+ page links below don't lead anywhere (so don't click on them).
48
+ </p>
49
+ <h2>
50
+ Unstyled pagination <span style="font-weight:normal">(<i>ewww!</i>)</span>
51
+ </h2>
52
+ <div>
53
+ <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
54
+ </div>
55
+ <h2>Digg.com</h2>
56
+ <div class='digg_pagination'>
57
+ <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
58
+ </div>
59
+ <h2>Digg-style, no page links</h2>
60
+ <div class='digg_pagination'>
61
+ <span class="disabled prev_page">&laquo; Previous</span> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
62
+ </div>
63
+ <p>Code that renders this:</p>
64
+ <pre>
65
+ <code>&lt;%= will_paginate @posts, :page_links =&gt; false %&gt;</code>
66
+ </pre>
67
+ <h2>Digg-style, extra content</h2>
68
+ <div class='digg_pagination'>
69
+ <div class='page_info'>
70
+ Displaying entries <b>1&nbsp;-&nbsp;6</b> of <b>180</b> in total
71
+ </div>
72
+ <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
73
+ </div>
74
+ <p>Code that renders this:</p>
75
+ <pre>
76
+ <code>&lt;div class="digg_pagination"&gt;
77
+ &lt;div clas="page_info"&gt;
78
+ &lt;%= page_entries_info @posts %&gt;
79
+ &lt;/div&gt;
80
+ &lt;%= will_paginate @posts, :container =&gt; false %&gt;
81
+ &lt;/div&gt;</code>
82
+ </pre>
83
+ <h2>Apple.com store</h2>
84
+ <div class='apple_pagination'>
85
+ <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
86
+ </div>
87
+ <h2>Flickr.com</h2>
88
+ <div class='flickr_pagination'>
89
+ <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
90
+ <div class='page_info'>(118 photos)</div>
91
+ </div>
92
+ </body>
@@ -0,0 +1,90 @@
1
+ .digg_pagination {
2
+ background: white;
3
+ /* self-clearing method: */ }
4
+ .digg_pagination a, .digg_pagination span {
5
+ padding: .2em .5em;
6
+ display: block;
7
+ float: left;
8
+ margin-right: 1px; }
9
+ .digg_pagination span.disabled {
10
+ color: #999;
11
+ border: 1px solid #DDD; }
12
+ .digg_pagination span.current {
13
+ font-weight: bold;
14
+ background: #2E6AB1;
15
+ color: white;
16
+ border: 1px solid #2E6AB1; }
17
+ .digg_pagination a {
18
+ text-decoration: none;
19
+ color: #105CB6;
20
+ border: 1px solid #9AAFE5; }
21
+ .digg_pagination a:hover, .digg_pagination a:focus {
22
+ color: #003;
23
+ border-color: #003; }
24
+ .digg_pagination .page_info {
25
+ background: #2E6AB1;
26
+ color: white;
27
+ padding: .4em .6em;
28
+ width: 22em;
29
+ margin-bottom: .3em;
30
+ text-align: center; }
31
+ .digg_pagination .page_info b {
32
+ color: #003;
33
+ background: #6aa6ed;
34
+ padding: .1em .25em; }
35
+ .digg_pagination:after {
36
+ content: ".";
37
+ display: block;
38
+ height: 0;
39
+ clear: both;
40
+ visibility: hidden; }
41
+ * html .digg_pagination {
42
+ height: 1%; }
43
+ *:first-child+html .digg_pagination {
44
+ overflow: hidden; }
45
+
46
+ .apple_pagination {
47
+ background: #F1F1F1;
48
+ border: 1px solid #E5E5E5;
49
+ text-align: center;
50
+ padding: 1em; }
51
+ .apple_pagination a, .apple_pagination span {
52
+ padding: .2em .3em; }
53
+ .apple_pagination span.disabled {
54
+ color: #AAA; }
55
+ .apple_pagination span.current {
56
+ font-weight: bold;
57
+ background: transparent url(apple-circle.gif) no-repeat 50% 50%; }
58
+ .apple_pagination a {
59
+ text-decoration: none;
60
+ color: black; }
61
+ .apple_pagination a:hover, .apple_pagination a:focus {
62
+ text-decoration: underline; }
63
+
64
+ .flickr_pagination {
65
+ text-align: center;
66
+ padding: .3em; }
67
+ .flickr_pagination a, .flickr_pagination span {
68
+ padding: .2em .5em; }
69
+ .flickr_pagination span.disabled {
70
+ color: #AAA; }
71
+ .flickr_pagination span.current {
72
+ font-weight: bold;
73
+ color: #FF0084; }
74
+ .flickr_pagination a {
75
+ border: 1px solid #DDDDDD;
76
+ color: #0063DC;
77
+ text-decoration: none; }
78
+ .flickr_pagination a:hover, .flickr_pagination a:focus {
79
+ border-color: #003366;
80
+ background: #0063DC;
81
+ color: white; }
82
+ .flickr_pagination .page_info {
83
+ color: #aaa;
84
+ padding-top: .8em; }
85
+ .flickr_pagination .prev_page, .flickr_pagination .next_page {
86
+ border-width: 2px; }
87
+ .flickr_pagination .prev_page {
88
+ margin-right: 1em; }
89
+ .flickr_pagination .next_page {
90
+ margin-left: 1em; }