peiji-san 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +22 -0
- data/Rakefile +7 -21
- data/init.rb +2 -1
- data/lib/peiji_san.rb +2 -1
- data/lib/peiji_san/view_helper.rb +36 -4
- data/test/peiji_san_test.rb +35 -34
- data/test/sinatra_test.rb +43 -0
- data/test/test_helper.rb +13 -9
- data/test/view_helper_test.rb +26 -25
- metadata +159 -34
- data/TODO +0 -1
- data/VERSION.yml +0 -5
- data/peiji-san.gemspec +0 -30
- data/rdoc/classes/PeijiSan.html +0 -306
- data/rdoc/classes/PeijiSan/PaginationMethods.html +0 -344
- data/rdoc/classes/PeijiSan/ViewHelper.html +0 -303
- data/rdoc/created.rid +0 -1
- data/rdoc/files/LICENSE.html +0 -129
- data/rdoc/files/README_rdoc.html +0 -157
- data/rdoc/files/lib/peiji_san/view_helper_rb.html +0 -101
- data/rdoc/files/lib/peiji_san_rb.html +0 -133
- data/rdoc/fr_class_index.html +0 -29
- data/rdoc/fr_file_index.html +0 -30
- data/rdoc/fr_method_index.html +0 -39
- data/rdoc/index.html +0 -24
- data/rdoc/rdoc-style.css +0 -208
data/rdoc/created.rid
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Tue, 05 Apr 2011 13:57:44 +0200
|
data/rdoc/files/LICENSE.html
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: LICENSE</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>LICENSE</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>LICENSE
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Tue Apr 05 12:42:17 +0200 2011</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
<div id="description">
|
72
|
-
<p>
|
73
|
-
Copyright © 2009 Fingertips, Eloy Duran <eloy.de.enige@gmail.com>
|
74
|
-
</p>
|
75
|
-
<p>
|
76
|
-
Permission is hereby granted, free of charge, to any person obtaining a
|
77
|
-
copy of this software and associated documentation files (the
|
78
|
-
"Software"), to deal in the Software without restriction,
|
79
|
-
including without limitation the rights to use, copy, modify, merge,
|
80
|
-
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
81
|
-
permit persons to whom the Software is furnished to do so, subject to the
|
82
|
-
following conditions:
|
83
|
-
</p>
|
84
|
-
<p>
|
85
|
-
The above copyright notice and this permission notice shall be included in
|
86
|
-
all copies or substantial portions of the Software.
|
87
|
-
</p>
|
88
|
-
<p>
|
89
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
90
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
91
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
92
|
-
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
93
|
-
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
94
|
-
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
95
|
-
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
96
|
-
</p>
|
97
|
-
|
98
|
-
</div>
|
99
|
-
|
100
|
-
|
101
|
-
</div>
|
102
|
-
|
103
|
-
|
104
|
-
</div>
|
105
|
-
|
106
|
-
|
107
|
-
<!-- if includes -->
|
108
|
-
|
109
|
-
<div id="section">
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
<!-- if method_list -->
|
119
|
-
|
120
|
-
|
121
|
-
</div>
|
122
|
-
|
123
|
-
|
124
|
-
<div id="validator-badges">
|
125
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
126
|
-
</div>
|
127
|
-
|
128
|
-
</body>
|
129
|
-
</html>
|
data/rdoc/files/README_rdoc.html
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: README.rdoc</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>README.rdoc</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>README.rdoc
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Tue Apr 05 13:56:19 +0200 2011</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
<div id="description">
|
72
|
-
<h1>Peiji-San</h1>
|
73
|
-
<p>
|
74
|
-
Peiji-San uses scopes to create a thin pagination layer.
|
75
|
-
</p>
|
76
|
-
<p>
|
77
|
-
We try to stay out of the way of your application as much as possible.
|
78
|
-
That‘s why you need to include Peiji in the places where you actually
|
79
|
-
use it.
|
80
|
-
</p>
|
81
|
-
<pre>
|
82
|
-
class Member < ActiveRecord::Base
|
83
|
-
extend PeijiSan
|
84
|
-
self.entries_per_page = 32
|
85
|
-
end
|
86
|
-
</pre>
|
87
|
-
<p>
|
88
|
-
After that a special extended scope is defined on the model and you will be
|
89
|
-
able to select a collection that contains only records on that page.
|
90
|
-
</p>
|
91
|
-
<pre>
|
92
|
-
@collection = Member.active.page(2)
|
93
|
-
</pre>
|
94
|
-
<p>
|
95
|
-
In the view you can either build your own links to the pages or you can use
|
96
|
-
the helpers shipped with Peiji. Like with the model extension the view
|
97
|
-
helpers aren‘t defined by default, you will need to include them in
|
98
|
-
another helper class.
|
99
|
-
</p>
|
100
|
-
<pre>
|
101
|
-
class ApplicationHelper
|
102
|
-
include PeijiSan::ViewHelper
|
103
|
-
end
|
104
|
-
</pre>
|
105
|
-
<p>
|
106
|
-
After that the helpers will be usable in your view.
|
107
|
-
</p>
|
108
|
-
<pre>
|
109
|
-
<% if @collection.page_count > 1 %>
|
110
|
-
<% pages_to_link_to(@collection).each do |page| %>
|
111
|
-
<%= page.is_a?(String) ? page : link_to_page(page, @collection) %>
|
112
|
-
<% end %>
|
113
|
-
<% end %>
|
114
|
-
</pre>
|
115
|
-
<h2>Rails 2.3 and earlier</h2>
|
116
|
-
<p>
|
117
|
-
The latest version of Peiji only works in Rails 3 because of extensive
|
118
|
-
changes to the scope API. However, earlier version work just fine in Rails
|
119
|
-
2.3. Rails 3 support starts at version 1.0, so put the following in
|
120
|
-
environment.rb:
|
121
|
-
</p>
|
122
|
-
<pre>
|
123
|
-
config.gem "peiji-san", :lib => "peiji_san", :version => "< 1.0"
|
124
|
-
</pre>
|
125
|
-
|
126
|
-
</div>
|
127
|
-
|
128
|
-
|
129
|
-
</div>
|
130
|
-
|
131
|
-
|
132
|
-
</div>
|
133
|
-
|
134
|
-
|
135
|
-
<!-- if includes -->
|
136
|
-
|
137
|
-
<div id="section">
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
<!-- if method_list -->
|
147
|
-
|
148
|
-
|
149
|
-
</div>
|
150
|
-
|
151
|
-
|
152
|
-
<div id="validator-badges">
|
153
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
154
|
-
</div>
|
155
|
-
|
156
|
-
</body>
|
157
|
-
</html>
|
@@ -1,101 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: view_helper.rb</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>view_helper.rb</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>lib/peiji_san/view_helper.rb
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Tue Apr 05 13:35:26 +0200 2011</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
</div>
|
74
|
-
|
75
|
-
|
76
|
-
</div>
|
77
|
-
|
78
|
-
|
79
|
-
<!-- if includes -->
|
80
|
-
|
81
|
-
<div id="section">
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
<!-- if method_list -->
|
91
|
-
|
92
|
-
|
93
|
-
</div>
|
94
|
-
|
95
|
-
|
96
|
-
<div id="validator-badges">
|
97
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
98
|
-
</div>
|
99
|
-
|
100
|
-
</body>
|
101
|
-
</html>
|
@@ -1,133 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: peiji_san.rb</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>peiji_san.rb</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>lib/peiji_san.rb
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Tue Apr 05 13:57:40 +0200 2011</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
<div id="description">
|
72
|
-
<p>
|
73
|
-
Peiji-San uses named scopes to create a thin pagination layer.
|
74
|
-
</p>
|
75
|
-
<p>
|
76
|
-
Example:
|
77
|
-
</p>
|
78
|
-
<pre>
|
79
|
-
class Member < ActiveRecord::Base
|
80
|
-
extend PeijiSan
|
81
|
-
self.entries_per_page = 32
|
82
|
-
end
|
83
|
-
</pre>
|
84
|
-
<p>
|
85
|
-
Now you can start scoping your queries by `page’:
|
86
|
-
</p>
|
87
|
-
<pre>
|
88
|
-
Member.active.page(2)
|
89
|
-
</pre>
|
90
|
-
<p>
|
91
|
-
Which will return 32 records with an offset of 32, as that‘s the
|
92
|
-
second page.
|
93
|
-
</p>
|
94
|
-
<p>
|
95
|
-
See <a
|
96
|
-
href="../../classes/PeijiSan/PaginationMethods.html">PeijiSan::PaginationMethods</a>
|
97
|
-
and <a
|
98
|
-
href="../../classes/PeijiSan/ViewHelper.html">PeijiSan::ViewHelper</a> for
|
99
|
-
more info.
|
100
|
-
</p>
|
101
|
-
|
102
|
-
</div>
|
103
|
-
|
104
|
-
|
105
|
-
</div>
|
106
|
-
|
107
|
-
|
108
|
-
</div>
|
109
|
-
|
110
|
-
|
111
|
-
<!-- if includes -->
|
112
|
-
|
113
|
-
<div id="section">
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
<!-- if method_list -->
|
123
|
-
|
124
|
-
|
125
|
-
</div>
|
126
|
-
|
127
|
-
|
128
|
-
<div id="validator-badges">
|
129
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
130
|
-
</div>
|
131
|
-
|
132
|
-
</body>
|
133
|
-
</html>
|