Capcode 0.9.9 → 1.0.0
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.
- data/README.rdoc +3 -0
- data/examples/rest.log +15 -0
- data/examples/static.rb +12 -0
- data/examples/static/static-index.html +1 -0
- data/lib/capcode.rb +14 -344
- data/lib/capcode/filters.rb +1 -0
- data/lib/capcode/helpers.rb +246 -0
- data/lib/capcode/http_error.rb +49 -0
- data/lib/capcode/static_files.rb +68 -0
- data/lib/capcode/version.rb +1 -1
- metadata +46 -61
- data/doc/rdoc/classes/Capcode.html +0 -1076
- data/doc/rdoc/classes/Capcode/Base.html +0 -136
- data/doc/rdoc/classes/Capcode/Configuration.html +0 -290
- data/doc/rdoc/classes/Capcode/HTTPError.html +0 -148
- data/doc/rdoc/classes/Capcode/Helpers.html +0 -674
- data/doc/rdoc/classes/Capcode/Helpers/Authorization.html +0 -219
- data/doc/rdoc/classes/Capcode/Resource.html +0 -111
- data/doc/rdoc/classes/Capcode/StaticFiles.html +0 -199
- data/doc/rdoc/classes/Capcode/Views.html +0 -112
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/AUTHORS.html +0 -107
- data/doc/rdoc/files/COPYING.html +0 -531
- data/doc/rdoc/files/README_rdoc.html +0 -887
- data/doc/rdoc/files/lib/capcode/base/db_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/configuration_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/filters_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/helpers/auth_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/render/text_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode_rb.html +0 -144
- data/doc/rdoc/fr_class_index.html +0 -35
- data/doc/rdoc/fr_file_index.html +0 -35
- data/doc/rdoc/fr_method_index.html +0 -56
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/lib/capcode.rbSAVE +0 -881
@@ -1,136 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
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>Class: Capcode::Base</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
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="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Capcode::Base</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/capcode/base/db_rb.html">
|
59
|
-
lib/capcode/base/db.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
<div id="description">
|
82
|
-
<p>
|
83
|
-
This class allow you to define models
|
84
|
-
</p>
|
85
|
-
<pre>
|
86
|
-
class Story < Capcode::Base
|
87
|
-
include Capcode::Resource
|
88
|
-
|
89
|
-
property :id, Integer, :serial => true
|
90
|
-
property :title, String
|
91
|
-
property :body, String
|
92
|
-
property :date, String
|
93
|
-
end
|
94
|
-
</pre>
|
95
|
-
<p>
|
96
|
-
If you want to use DataMapper, you need to require
|
97
|
-
"capcode/base/dm", if you want to use CouchDB (via couch_foo),
|
98
|
-
you need to require "capcode/base/couchdb".
|
99
|
-
</p>
|
100
|
-
<p>
|
101
|
-
Please, refer to the DataMapper or couch_foo documentation for more
|
102
|
-
information.
|
103
|
-
</p>
|
104
|
-
|
105
|
-
</div>
|
106
|
-
|
107
|
-
|
108
|
-
</div>
|
109
|
-
|
110
|
-
|
111
|
-
</div>
|
112
|
-
|
113
|
-
|
114
|
-
<!-- if includes -->
|
115
|
-
|
116
|
-
<div id="section">
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
<!-- if method_list -->
|
126
|
-
|
127
|
-
|
128
|
-
</div>
|
129
|
-
|
130
|
-
|
131
|
-
<div id="validator-badges">
|
132
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
133
|
-
</div>
|
134
|
-
|
135
|
-
</body>
|
136
|
-
</html>
|
@@ -1,290 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
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>Class: Capcode::Configuration</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
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="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Capcode::Configuration</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/capcode/configuration_rb.html">
|
59
|
-
lib/capcode/configuration.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
</div>
|
84
|
-
|
85
|
-
<div id="method-list">
|
86
|
-
<h3 class="section-bar">Methods</h3>
|
87
|
-
|
88
|
-
<div class="name-list">
|
89
|
-
<a href="#M000029">get</a>
|
90
|
-
<a href="#M000030">options</a>
|
91
|
-
<a href="#M000027">print_debug</a>
|
92
|
-
<a href="#M000028">set</a>
|
93
|
-
</div>
|
94
|
-
</div>
|
95
|
-
|
96
|
-
</div>
|
97
|
-
|
98
|
-
|
99
|
-
<!-- if includes -->
|
100
|
-
|
101
|
-
<div id="section">
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
<!-- if method_list -->
|
111
|
-
<div id="methods">
|
112
|
-
<h3 class="section-bar">Public Class methods</h3>
|
113
|
-
|
114
|
-
<div id="method-M000029" class="method-detail">
|
115
|
-
<a name="M000029"></a>
|
116
|
-
|
117
|
-
<div class="method-heading">
|
118
|
-
<a href="#M000029" class="method-signature">
|
119
|
-
<span class="method-name">get</span><span class="method-args">( key = nil )</span>
|
120
|
-
</a>
|
121
|
-
</div>
|
122
|
-
|
123
|
-
<div class="method-description">
|
124
|
-
<p><a class="source-toggle" href="#"
|
125
|
-
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
126
|
-
<div class="method-source-code" id="M000029-source">
|
127
|
-
<pre>
|
128
|
-
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 67</span>
|
129
|
-
67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>( <span class="ruby-identifier">key</span> = <span class="ruby-keyword kw">nil</span> )
|
130
|
-
68: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">nil?</span>
|
131
|
-
69: <span class="ruby-identifier">config</span>
|
132
|
-
70: <span class="ruby-keyword kw">else</span>
|
133
|
-
71: <span class="ruby-identifier">config</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span>
|
134
|
-
72: <span class="ruby-keyword kw">end</span>
|
135
|
-
73: <span class="ruby-keyword kw">end</span>
|
136
|
-
</pre>
|
137
|
-
</div>
|
138
|
-
</div>
|
139
|
-
</div>
|
140
|
-
|
141
|
-
<div id="method-M000030" class="method-detail">
|
142
|
-
<a name="M000030"></a>
|
143
|
-
|
144
|
-
<div class="method-heading">
|
145
|
-
<a href="#M000030" class="method-signature">
|
146
|
-
<span class="method-name">options</span><span class="method-args">()</span>
|
147
|
-
</a>
|
148
|
-
</div>
|
149
|
-
|
150
|
-
<div class="method-description">
|
151
|
-
<p><a class="source-toggle" href="#"
|
152
|
-
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
153
|
-
<div class="method-source-code" id="M000030-source">
|
154
|
-
<pre>
|
155
|
-
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 75</span>
|
156
|
-
75: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options</span>
|
157
|
-
76: <span class="ruby-ivar">@options</span> <span class="ruby-operator">||=</span> {}
|
158
|
-
77: <span class="ruby-keyword kw">end</span>
|
159
|
-
</pre>
|
160
|
-
</div>
|
161
|
-
</div>
|
162
|
-
</div>
|
163
|
-
|
164
|
-
<div id="method-M000027" class="method-detail">
|
165
|
-
<a name="M000027"></a>
|
166
|
-
|
167
|
-
<div class="method-heading">
|
168
|
-
<a href="#M000027" class="method-signature">
|
169
|
-
<span class="method-name">print_debug</span><span class="method-args">()</span>
|
170
|
-
</a>
|
171
|
-
</div>
|
172
|
-
|
173
|
-
<div class="method-description">
|
174
|
-
<p><a class="source-toggle" href="#"
|
175
|
-
onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
|
176
|
-
<div class="method-source-code" id="M000027-source">
|
177
|
-
<pre>
|
178
|
-
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 28</span>
|
179
|
-
28: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_debug</span>
|
180
|
-
29: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">config</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
181
|
-
30: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** [CONFIG] : #{k} = #{v}"</span>
|
182
|
-
31: <span class="ruby-keyword kw">end</span>
|
183
|
-
32: <span class="ruby-keyword kw">end</span>
|
184
|
-
</pre>
|
185
|
-
</div>
|
186
|
-
</div>
|
187
|
-
</div>
|
188
|
-
|
189
|
-
<div id="method-M000028" class="method-detail">
|
190
|
-
<a name="M000028"></a>
|
191
|
-
|
192
|
-
<div class="method-heading">
|
193
|
-
<a href="#M000028" class="method-signature">
|
194
|
-
<span class="method-name">set</span><span class="method-args">( key, value, opts = {} )</span>
|
195
|
-
</a>
|
196
|
-
</div>
|
197
|
-
|
198
|
-
<div class="method-description">
|
199
|
-
<p>
|
200
|
-
Set global configuration <a href="Configuration.html#M000030">options</a>
|
201
|
-
</p>
|
202
|
-
<p>
|
203
|
-
Options :
|
204
|
-
</p>
|
205
|
-
<ul>
|
206
|
-
<li><tt>:port</tt> = Listen port (default: 3000)
|
207
|
-
|
208
|
-
</li>
|
209
|
-
<li><tt>:host</tt> = Listen host (default: 0.0.0.0)
|
210
|
-
|
211
|
-
</li>
|
212
|
-
<li><tt>:server</tt> = Server type (webrick, mongrel, thin, unicorn, rainbow or
|
213
|
-
control_tower)
|
214
|
-
|
215
|
-
</li>
|
216
|
-
<li><tt>:log</tt> = Output logfile (default: STDOUT)
|
217
|
-
|
218
|
-
</li>
|
219
|
-
<li><tt>:session</tt> = Session parameters. See Rack::Session for more
|
220
|
-
informations
|
221
|
-
|
222
|
-
</li>
|
223
|
-
<li><tt>:pid</tt> = PID file (default: $0.pid)
|
224
|
-
|
225
|
-
</li>
|
226
|
-
<li><tt>:daemonize</tt> = Daemonize application (default: false)
|
227
|
-
|
228
|
-
</li>
|
229
|
-
<li><tt>:db_config</tt> = database configuration file (default: database.yml)
|
230
|
-
|
231
|
-
</li>
|
232
|
-
<li><tt>:static</tt> = Static directory (default: the working directory)
|
233
|
-
|
234
|
-
</li>
|
235
|
-
<li><tt>:root</tt> = Root directory (default: directory of the main.rb) —
|
236
|
-
This is also the working directory !
|
237
|
-
|
238
|
-
</li>
|
239
|
-
<li><tt>:verbose</tt> = run in verbose mode
|
240
|
-
|
241
|
-
</li>
|
242
|
-
<li><tt>:auth</tt> = HTTP Basic Authentication <a
|
243
|
-
href="Configuration.html#M000030">options</a>
|
244
|
-
|
245
|
-
</li>
|
246
|
-
</ul>
|
247
|
-
<p>
|
248
|
-
It can exist specifics <a href="Configuration.html#M000030">options</a>
|
249
|
-
depending on a renderer, a helper, …
|
250
|
-
</p>
|
251
|
-
<p>
|
252
|
-
Example :
|
253
|
-
</p>
|
254
|
-
<pre>
|
255
|
-
module Capcode
|
256
|
-
set :erb, "/path/to/erb/files"
|
257
|
-
...
|
258
|
-
end
|
259
|
-
</pre>
|
260
|
-
<p><a class="source-toggle" href="#"
|
261
|
-
onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
|
262
|
-
<div class="method-source-code" id="M000028-source">
|
263
|
-
<pre>
|
264
|
-
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 58</span>
|
265
|
-
58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set</span>( <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">opts</span> = {} )
|
266
|
-
59: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">value</span>
|
267
|
-
60: <span class="ruby-identifier">opts</span> = <span class="ruby-identifier">value</span>
|
268
|
-
61: <span class="ruby-identifier">value</span> = <span class="ruby-keyword kw">nil</span>
|
269
|
-
62: <span class="ruby-keyword kw">end</span>
|
270
|
-
63: <span class="ruby-identifier">config</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
271
|
-
64: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">opts</span>
|
272
|
-
65: <span class="ruby-keyword kw">end</span>
|
273
|
-
</pre>
|
274
|
-
</div>
|
275
|
-
</div>
|
276
|
-
</div>
|
277
|
-
|
278
|
-
|
279
|
-
</div>
|
280
|
-
|
281
|
-
|
282
|
-
</div>
|
283
|
-
|
284
|
-
|
285
|
-
<div id="validator-badges">
|
286
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
287
|
-
</div>
|
288
|
-
|
289
|
-
</body>
|
290
|
-
</html>
|
@@ -1,148 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
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>Class: Capcode::HTTPError</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
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="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Capcode::HTTPError</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/capcode_rb.html">
|
59
|
-
lib/capcode.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
<div id="description">
|
82
|
-
<p>
|
83
|
-
<a href="HTTPError.html">HTTPError</a> help you to create your own 404, 500
|
84
|
-
and/or 501 response
|
85
|
-
</p>
|
86
|
-
<p>
|
87
|
-
To create a custom 404 reponse, create a fonction HTTPError.r404 in your
|
88
|
-
application :
|
89
|
-
</p>
|
90
|
-
<pre>
|
91
|
-
module Capcode
|
92
|
-
class HTTPError
|
93
|
-
def r404(f)
|
94
|
-
"#{f} not found :("
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
</pre>
|
99
|
-
<p>
|
100
|
-
the rXXX method can also receive a second optional parameter corresponding
|
101
|
-
of the header‘s Hash :
|
102
|
-
</p>
|
103
|
-
<pre>
|
104
|
-
module Capcode
|
105
|
-
class HTTPError
|
106
|
-
def r404(f, h)
|
107
|
-
h['Content-Type'] = 'text/plain'
|
108
|
-
"You are here ---> X (#{f} point)"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
</pre>
|
113
|
-
<p>
|
114
|
-
Do the same (r500, r501, r403) to customize 500, 501, 403 errors
|
115
|
-
</p>
|
116
|
-
|
117
|
-
</div>
|
118
|
-
|
119
|
-
|
120
|
-
</div>
|
121
|
-
|
122
|
-
|
123
|
-
</div>
|
124
|
-
|
125
|
-
|
126
|
-
<!-- if includes -->
|
127
|
-
|
128
|
-
<div id="section">
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
<!-- if method_list -->
|
138
|
-
|
139
|
-
|
140
|
-
</div>
|
141
|
-
|
142
|
-
|
143
|
-
<div id="validator-badges">
|
144
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
145
|
-
</div>
|
146
|
-
|
147
|
-
</body>
|
148
|
-
</html>
|