mislav-will_paginate 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +62 -0
- data/LICENSE +18 -0
- data/README.rdoc +135 -0
- data/Rakefile +110 -0
- data/examples/apple-circle.gif +0 -0
- data/examples/index.haml +69 -0
- data/examples/index.html +92 -0
- data/examples/pagination.css +90 -0
- data/examples/pagination.sass +91 -0
- data/init.rb +1 -0
- data/lib/will_paginate.rb +86 -0
- data/lib/will_paginate/array.rb +16 -0
- data/lib/will_paginate/collection.rb +145 -0
- data/lib/will_paginate/core_ext.rb +32 -0
- data/lib/will_paginate/finder.rb +239 -0
- data/lib/will_paginate/named_scope.rb +132 -0
- data/lib/will_paginate/named_scope_patch.rb +39 -0
- data/lib/will_paginate/version.rb +9 -0
- data/lib/will_paginate/view_helpers.rb +341 -0
- data/test/boot.rb +21 -0
- data/test/collection_test.rb +140 -0
- data/test/console +8 -0
- data/test/database.yml +22 -0
- data/test/finder_test.rb +416 -0
- data/test/fixtures/admin.rb +3 -0
- data/test/fixtures/developer.rb +13 -0
- data/test/fixtures/developers_projects.yml +13 -0
- data/test/fixtures/project.rb +15 -0
- data/test/fixtures/projects.yml +6 -0
- data/test/fixtures/replies.yml +29 -0
- data/test/fixtures/reply.rb +7 -0
- data/test/fixtures/schema.rb +38 -0
- data/test/fixtures/topic.rb +6 -0
- data/test/fixtures/topics.yml +30 -0
- data/test/fixtures/user.rb +2 -0
- data/test/fixtures/users.yml +35 -0
- data/test/helper.rb +37 -0
- data/test/lib/activerecord_test_case.rb +36 -0
- data/test/lib/activerecord_test_connector.rb +69 -0
- data/test/lib/load_fixtures.rb +11 -0
- data/test/lib/view_test_process.rb +157 -0
- data/test/view_test.rb +278 -0
- metadata +130 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
== 2.2.3, released 2008-04-26
|
2
|
+
|
3
|
+
* will_paginate gem is no longer published on RubyForge, but on
|
4
|
+
gems.github.com:
|
5
|
+
|
6
|
+
gem sources -a http://gems.github.com/ (you only need to do this once)
|
7
|
+
gem install mislav-will_paginate
|
8
|
+
|
9
|
+
* extract reusable pagination testing stuff into WillPaginate::View
|
10
|
+
* rethink the page URL construction mechanizm to be more bulletproof when
|
11
|
+
combined with custom routing for page parameter
|
12
|
+
* test that anchor parameter can be used in pagination links
|
13
|
+
|
14
|
+
== 2.2.2, released 2008-04-21
|
15
|
+
|
16
|
+
* Add support for page parameter in custom routes like "/foo/page/2"
|
17
|
+
* Change output of "page_entries_info" on single-page collection and erraneous
|
18
|
+
output with empty collection as reported by Tim Chater
|
19
|
+
|
20
|
+
== 2.2.1, released 2008-04-08
|
21
|
+
|
22
|
+
* take less risky path when monkeypatching named_scope; fix that it no longer
|
23
|
+
requires ActiveRecord::VERSION
|
24
|
+
* use strings in "respond_to?" calls to work around a bug in acts_as_ferret
|
25
|
+
stable (ugh)
|
26
|
+
* add rake release task
|
27
|
+
|
28
|
+
|
29
|
+
== 2.2.0, released 2008-04-07
|
30
|
+
|
31
|
+
=== API changes
|
32
|
+
* Rename WillPaginate::Collection#page_count to "total_pages" for consistency.
|
33
|
+
If you implemented this interface, change your implementation accordingly.
|
34
|
+
* Remove old, deprecated style of calling Array#paginate as "paginate(page,
|
35
|
+
per_page)". If you want to specify :page, :per_page or :total_entries, use a
|
36
|
+
parameter hash.
|
37
|
+
* Rename LinkRenderer#url_options to "url_for" and drastically optimize it
|
38
|
+
|
39
|
+
=== View changes
|
40
|
+
* Added "prev_page" and "next_page" CSS classes on previous/next page buttons
|
41
|
+
* Add examples of pagination links styling in "examples/index.html"
|
42
|
+
* Change gap in pagination links from "..." to
|
43
|
+
"<span class="gap">…</span>".
|
44
|
+
* Add "paginated_section", a block helper that renders pagination both above and
|
45
|
+
below content in the block
|
46
|
+
* Add rel="prev|next|start" to page links
|
47
|
+
|
48
|
+
=== Other
|
49
|
+
|
50
|
+
* Add ability to opt-in for Rails 2.1 feature "named_scope" by calling
|
51
|
+
WillPaginate.enable_named_scope (tested in Rails 1.2.6 and 2.0.2)
|
52
|
+
* Support complex page parameters like "developers[page]"
|
53
|
+
* Move Array#paginate definition to will_paginate/array.rb. You can now easily
|
54
|
+
use pagination on arrays outside of Rails:
|
55
|
+
|
56
|
+
gem 'will_paginate'
|
57
|
+
require 'will_paginate/array'
|
58
|
+
|
59
|
+
* Add "paginated_each" method for iterating through every record by loading only
|
60
|
+
one page of records at the time
|
61
|
+
* Rails 2: Rescue from WillPaginate::InvalidPage error with 404 Not Found by
|
62
|
+
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,135 @@
|
|
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 a model:
|
6
|
+
|
7
|
+
Post.paginate :page => 1, :order => 'created_at DESC'
|
8
|
+
|
9
|
+
... and then render the page links with a single view helper? Well, now you
|
10
|
+
can.
|
11
|
+
|
12
|
+
Some resources to get you started:
|
13
|
+
|
14
|
+
* Your mind reels with questions? Join our
|
15
|
+
{Google group}[http://groups.google.com/group/will_paginate].
|
16
|
+
* The will_paginate project page: http://github.com/mislav/will_paginate
|
17
|
+
* How to report bugs: http://github.com/mislav/will_paginate/wikis/report-bugs
|
18
|
+
* Ryan Bates made an awesome screencast[http://railscasts.com/episodes/51],
|
19
|
+
check it out.
|
20
|
+
|
21
|
+
== Installation
|
22
|
+
|
23
|
+
The recommended way is that you get the gem:
|
24
|
+
|
25
|
+
# add GitHub to your local list of gem sources:
|
26
|
+
gem sources -a http://gems.github.com/
|
27
|
+
|
28
|
+
# install the gem:
|
29
|
+
gem install mislav-will_paginate
|
30
|
+
|
31
|
+
After that you don't need the will_paginate <i>plugin</i> in your Rails
|
32
|
+
application anymore. Just add a simple require to the end of
|
33
|
+
"config/environment.rb":
|
34
|
+
|
35
|
+
gem 'mislav-will_paginate', '~> 2.2'
|
36
|
+
require 'will_paginate'
|
37
|
+
|
38
|
+
That's it. Remember to install the gem on <b>all</b> machines that you are
|
39
|
+
deploying to.
|
40
|
+
|
41
|
+
<i>There are extensive
|
42
|
+
{installation instructions}[http://github.com/mislav/will_paginate/wikis/installation]
|
43
|
+
on {the wiki}[http://github.com/mislav/will_paginate/wikis].</i>
|
44
|
+
|
45
|
+
|
46
|
+
== Example usage
|
47
|
+
|
48
|
+
Use a paginate finder in the controller:
|
49
|
+
|
50
|
+
@posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC'
|
51
|
+
|
52
|
+
Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the
|
53
|
+
records. Don't forget to tell it which page you want, or it will complain!
|
54
|
+
Read more on WillPaginate::Finder::ClassMethods.
|
55
|
+
|
56
|
+
Render the posts in your view like you would normally do. When you need to render
|
57
|
+
pagination, just stick this in:
|
58
|
+
|
59
|
+
<%= will_paginate @posts %>
|
60
|
+
|
61
|
+
You're done. (Copy and paste the example fancy CSS styles from the bottom.) You
|
62
|
+
can find the option list at WillPaginate::ViewHelpers.
|
63
|
+
|
64
|
+
How does it know how much items to fetch per page? It asks your model by calling
|
65
|
+
its <tt>per_page</tt> class method. You can define it like this:
|
66
|
+
|
67
|
+
class Post < ActiveRecord::Base
|
68
|
+
cattr_reader :per_page
|
69
|
+
@@per_page = 50
|
70
|
+
end
|
71
|
+
|
72
|
+
... or like this:
|
73
|
+
|
74
|
+
class Post < ActiveRecord::Base
|
75
|
+
def self.per_page
|
76
|
+
50
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
... or don't worry about it at all. WillPaginate defines it to be <b>30</b> by default.
|
81
|
+
But you can always specify the count explicitly when calling +paginate+:
|
82
|
+
|
83
|
+
@posts = Post.paginate :page => params[:page], :per_page => 50
|
84
|
+
|
85
|
+
The +paginate+ finder wraps the original finder and returns your resultset that now has
|
86
|
+
some new properties. You can use the collection as you would with any ActiveRecord
|
87
|
+
resultset. WillPaginate view helpers also need that object to be able to render pagination:
|
88
|
+
|
89
|
+
<ol>
|
90
|
+
<% for post in @posts -%>
|
91
|
+
<li>Render `post` in some nice way.</li>
|
92
|
+
<% end -%>
|
93
|
+
</ol>
|
94
|
+
|
95
|
+
<p>Now let's render us some pagination!</p>
|
96
|
+
<%= will_paginate @posts %>
|
97
|
+
|
98
|
+
More detailed documentation:
|
99
|
+
|
100
|
+
* WillPaginate::Finder::ClassMethods for pagination on your models;
|
101
|
+
* WillPaginate::ViewHelpers for your views.
|
102
|
+
|
103
|
+
|
104
|
+
== Authors and credits
|
105
|
+
|
106
|
+
Authors:: Mislav Marohnić, PJ Hyett
|
107
|
+
Original announcement:: http://errtheblog.com/post/929
|
108
|
+
Original PHP source:: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php
|
109
|
+
|
110
|
+
All these people helped making will_paginate what it is now with their code
|
111
|
+
contributions or just simply awesome ideas:
|
112
|
+
|
113
|
+
Chris Wanstrath, Dr. Nic Williams, K. Adam Christensen, Mike Garey, Bence
|
114
|
+
Golda, Matt Aimonetti, Charles Brian Quinn, Desi McAdam, James Coglan, Matijs
|
115
|
+
van Zuijlen, Maria, Brendan Ribera, Todd Willey, Bryan Helmkamp, Jan Berkel,
|
116
|
+
Lourens Naudé, Rick Olson, Russell Norris.
|
117
|
+
|
118
|
+
|
119
|
+
== Usable pagination in the UI
|
120
|
+
|
121
|
+
There are some CSS styles to get you started in the "examples/" directory. They
|
122
|
+
are showcased in the <b>"examples/index.html"</b> file.
|
123
|
+
|
124
|
+
More reading about pagination as design pattern:
|
125
|
+
|
126
|
+
* Pagination 101:
|
127
|
+
http://kurafire.net/log/archive/2007/06/22/pagination-101
|
128
|
+
* Pagination gallery:
|
129
|
+
http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/
|
130
|
+
* Pagination on Yahoo Design Pattern Library:
|
131
|
+
http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination
|
132
|
+
|
133
|
+
Want to discuss, request features, ask questions? Join the
|
134
|
+
{Google group}[http://groups.google.com/group/will_paginate].
|
135
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the will_paginate plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.pattern = 'test/**/*_test.rb'
|
11
|
+
t.verbose = true
|
12
|
+
t.libs << 'test'
|
13
|
+
end
|
14
|
+
|
15
|
+
# I want to specify environment variables at call time
|
16
|
+
class EnvTestTask < Rake::TestTask
|
17
|
+
attr_accessor :env
|
18
|
+
|
19
|
+
def ruby(*args)
|
20
|
+
env.each { |key, value| ENV[key] = value } if env
|
21
|
+
super
|
22
|
+
env.keys.each { |key| ENV.delete key } if env
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
for configuration in %w( sqlite3 mysql postgres )
|
27
|
+
EnvTestTask.new("test_#{configuration}") do |t|
|
28
|
+
t.pattern = 'test/finder_test.rb'
|
29
|
+
t.verbose = true
|
30
|
+
t.env = { 'DB' => configuration }
|
31
|
+
t.libs << 'test'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
task :test_databases => %w(test_mysql test_sqlite3 test_postgres)
|
36
|
+
|
37
|
+
desc %{Test everything on SQLite3, MySQL and PostgreSQL}
|
38
|
+
task :test_full => %w(test test_mysql test_postgres)
|
39
|
+
|
40
|
+
desc %{Test everything with Rails 1.2.x and 2.0.x gems}
|
41
|
+
task :test_all do
|
42
|
+
all = Rake::Task['test_full']
|
43
|
+
ENV['RAILS_VERSION'] = '~>1.2.6'
|
44
|
+
all.invoke
|
45
|
+
# reset the invoked flag
|
46
|
+
%w( test_full test test_mysql test_postgres ).each do |name|
|
47
|
+
Rake::Task[name].instance_variable_set '@already_invoked', false
|
48
|
+
end
|
49
|
+
# do it again
|
50
|
+
ENV['RAILS_VERSION'] = '~>2.0.2'
|
51
|
+
all.invoke
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Generate RDoc documentation for the will_paginate plugin.'
|
55
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
56
|
+
files = ['README.rdoc', 'LICENSE', 'CHANGELOG']
|
57
|
+
files << FileList.new('lib/**/*.rb').
|
58
|
+
exclude('lib/will_paginate/named_scope*').
|
59
|
+
exclude('lib/will_paginate/array.rb').
|
60
|
+
exclude('lib/will_paginate/version.rb')
|
61
|
+
|
62
|
+
rdoc.rdoc_files.add(files)
|
63
|
+
rdoc.main = "README.rdoc" # page to start on
|
64
|
+
rdoc.title = "will_paginate documentation"
|
65
|
+
|
66
|
+
templates = %w[/Users/chris/ruby/projects/err/rock/template.rb /var/www/rock/template.rb]
|
67
|
+
rdoc.template = templates.find { |t| File.exists? t }
|
68
|
+
|
69
|
+
rdoc.rdoc_dir = 'doc' # rdoc output folder
|
70
|
+
rdoc.options << '--inline-source'
|
71
|
+
rdoc.options << '--charset=UTF-8'
|
72
|
+
rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/'
|
73
|
+
end
|
74
|
+
|
75
|
+
task :manifest do
|
76
|
+
list = Dir['**/*'].sort
|
77
|
+
spec_file = Dir['*.gemspec'].first
|
78
|
+
list -= [spec_file]
|
79
|
+
|
80
|
+
File.read('.gitignore').each_line do |glob|
|
81
|
+
glob = glob.chomp.sub(/^\//, '')
|
82
|
+
list -= Dir[glob]
|
83
|
+
list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob)
|
84
|
+
puts "excluding #{glob}"
|
85
|
+
end
|
86
|
+
|
87
|
+
spec = File.read spec_file
|
88
|
+
spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do
|
89
|
+
assignment = $1
|
90
|
+
bunch = $2 ? list.grep(/^test\//) : list
|
91
|
+
'%s%%w(%s)' % [assignment, bunch.join(' ')]
|
92
|
+
end
|
93
|
+
|
94
|
+
File.open(spec_file, 'w') {|f| f << spec }
|
95
|
+
File.open('.manifest', 'w') {|f| f << list.join("\n") }
|
96
|
+
end
|
97
|
+
|
98
|
+
task :examples do
|
99
|
+
%x(haml examples/index.haml examples/index.html)
|
100
|
+
%x(sass examples/pagination.sass examples/pagination.css)
|
101
|
+
end
|
102
|
+
|
103
|
+
task :rcov do
|
104
|
+
excludes = %w( lib/will_paginate/named_scope*
|
105
|
+
lib/will_paginate/core_ext.rb
|
106
|
+
lib/will_paginate.rb
|
107
|
+
rails* )
|
108
|
+
|
109
|
+
system %[rcov -Itest:lib test/*.rb -x #{excludes.join(',')}]
|
110
|
+
end
|
Binary file
|
data/examples/index.haml
ADDED
@@ -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">« 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">…</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next »</a>'
|
31
|
+
- pagination_no_page_links = '<span class="disabled prev_page">« Previous</span> <a href="./?page=2" rel="next" class="next_page">Next »</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('<', '<').gsub('>', '>')
|
55
|
+
|
56
|
+
%h2 Digg-style, extra content
|
57
|
+
.digg_pagination
|
58
|
+
.page_info Displaying entries <b>1 - 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('<', '<').gsub('>', '>')
|
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)
|
data/examples/index.html
ADDED
@@ -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">« 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">…</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next »</a>
|
54
|
+
</div>
|
55
|
+
<h2>Digg.com</h2>
|
56
|
+
<div class='digg_pagination'>
|
57
|
+
<span class="disabled prev_page">« 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">…</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next »</a>
|
58
|
+
</div>
|
59
|
+
<h2>Digg-style, no page links</h2>
|
60
|
+
<div class='digg_pagination'>
|
61
|
+
<span class="disabled prev_page">« Previous</span> <a href="./?page=2" rel="next" class="next_page">Next »</a>
|
62
|
+
</div>
|
63
|
+
<p>Code that renders this:</p>
|
64
|
+
<pre>
|
65
|
+
<code><%= will_paginate @posts, :page_links => false %></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 - 6</b> of <b>180</b> in total
|
71
|
+
</div>
|
72
|
+
<span class="disabled prev_page">« 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">…</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next »</a>
|
73
|
+
</div>
|
74
|
+
<p>Code that renders this:</p>
|
75
|
+
<pre>
|
76
|
+
<code><div class="digg_pagination">
|
77
|
+
<div clas="page_info">
|
78
|
+
<%= page_entries_info @posts %>
|
79
|
+
</div>
|
80
|
+
<%= will_paginate @posts, :container => false %>
|
81
|
+
</div></code>
|
82
|
+
</pre>
|
83
|
+
<h2>Apple.com store</h2>
|
84
|
+
<div class='apple_pagination'>
|
85
|
+
<span class="disabled prev_page">« 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">…</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next »</a>
|
86
|
+
</div>
|
87
|
+
<h2>Flickr.com</h2>
|
88
|
+
<div class='flickr_pagination'>
|
89
|
+
<span class="disabled prev_page">« 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">…</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next »</a>
|
90
|
+
<div class='page_info'>(118 photos)</div>
|
91
|
+
</div>
|
92
|
+
</body>
|