Capcode 0.8.6 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +72 -1
- data/doc/rdoc/classes/Capcode.html +549 -444
- data/doc/rdoc/classes/Capcode/Helpers.html +293 -133
- data/doc/rdoc/classes/Capcode/Helpers/Authorization.html +60 -29
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README_rdoc.html +94 -8
- data/doc/rdoc/files/lib/capcode/configuration_rb.html +101 -0
- data/doc/rdoc/files/lib/capcode/helpers/auth_rb.html +1 -32
- data/doc/rdoc/files/lib/capcode/render/erb_rb.html +1 -1
- data/doc/rdoc/files/lib/capcode/render/haml_rb.html +1 -1
- data/doc/rdoc/files/lib/capcode/render/markaby_rb.html +1 -1
- data/doc/rdoc/files/lib/capcode/render/sass_rb.html +1 -1
- data/doc/rdoc/files/lib/capcode/render/text_rb.html +1 -1
- data/doc/rdoc/files/lib/capcode_rb.html +8 -1
- data/doc/rdoc/fr_file_index.html +1 -0
- data/doc/rdoc/fr_method_index.html +19 -11
- data/examples/blog-couchdb.rb +4 -3
- data/examples/erb/cf.rhtml +1 -0
- data/examples/haml/cf.haml +4 -1
- data/examples/render-erb.rb +4 -1
- data/examples/render-haml_sass.rb +6 -2
- data/examples/render-image.rb +70 -0
- data/examples/render-static.rb +4 -1
- data/examples/render-static.ru +0 -2
- data/examples/render-use.rb +31 -0
- data/examples/static/coderay.css +131 -0
- data/examples/static/index.html +19 -0
- data/lib/capcode.rb +125 -76
- data/lib/capcode/configuration.rb +39 -0
- data/lib/capcode/helpers/auth.rb +22 -23
- data/lib/capcode/render/erb.rb +25 -18
- data/lib/capcode/render/haml.rb +28 -19
- data/lib/capcode/render/markaby.rb +2 -1
- data/lib/capcode/render/sass.rb +19 -13
- data/lib/capcode/render/text.rb +1 -1
- data/lib/capcode/version.rb +1 -1
- metadata +8 -2
@@ -127,13 +127,18 @@ controllers
|
|
127
127
|
<h3 class="section-bar">Methods</h3>
|
128
128
|
|
129
129
|
<div class="name-list">
|
130
|
-
<a href="#
|
131
|
-
<a href="#
|
132
|
-
<a href="#
|
133
|
-
<a href="#
|
134
|
-
<a href="#
|
135
|
-
<a href="#
|
136
|
-
<a href="#
|
130
|
+
<a href="#M000019">URL</a>
|
131
|
+
<a href="#M000014">args</a>
|
132
|
+
<a href="#M000015">args=</a>
|
133
|
+
<a href="#M000020">content_for</a>
|
134
|
+
<a href="#M000022">erb_path=</a>
|
135
|
+
<a href="#M000023">haml_path=</a>
|
136
|
+
<a href="#M000017">json</a>
|
137
|
+
<a href="#M000018">redirect</a>
|
138
|
+
<a href="#M000016">render</a>
|
139
|
+
<a href="#M000025">render_webdav</a>
|
140
|
+
<a href="#M000024">sass_path=</a>
|
141
|
+
<a href="#M000021">static</a>
|
137
142
|
</div>
|
138
143
|
</div>
|
139
144
|
|
@@ -166,20 +171,161 @@ controllers
|
|
166
171
|
|
167
172
|
<!-- if method_list -->
|
168
173
|
<div id="methods">
|
169
|
-
<h3 class="section-bar">Public
|
174
|
+
<h3 class="section-bar">Public Class methods</h3>
|
170
175
|
|
171
176
|
<div id="method-M000014" class="method-detail">
|
172
177
|
<a name="M000014"></a>
|
173
178
|
|
174
179
|
<div class="method-heading">
|
175
180
|
<a href="#M000014" class="method-signature">
|
181
|
+
<span class="method-name">args</span><span class="method-args">()</span>
|
182
|
+
</a>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
<div class="method-description">
|
186
|
+
<p>
|
187
|
+
@@<em>ARGS</em> = nil
|
188
|
+
</p>
|
189
|
+
<p><a class="source-toggle" href="#"
|
190
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
191
|
+
<div class="method-source-code" id="M000014-source">
|
192
|
+
<pre>
|
193
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 43</span>
|
194
|
+
43: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">args</span>
|
195
|
+
44: <span class="ruby-ivar">@args</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword kw">nil</span>
|
196
|
+
45: <span class="ruby-keyword kw">end</span>
|
197
|
+
</pre>
|
198
|
+
</div>
|
199
|
+
</div>
|
200
|
+
</div>
|
201
|
+
|
202
|
+
<div id="method-M000015" class="method-detail">
|
203
|
+
<a name="M000015"></a>
|
204
|
+
|
205
|
+
<div class="method-heading">
|
206
|
+
<a href="#M000015" class="method-signature">
|
207
|
+
<span class="method-name">args=</span><span class="method-args">(x)</span>
|
208
|
+
</a>
|
209
|
+
</div>
|
210
|
+
|
211
|
+
<div class="method-description">
|
212
|
+
<p><a class="source-toggle" href="#"
|
213
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
214
|
+
<div class="method-source-code" id="M000015-source">
|
215
|
+
<pre>
|
216
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 46</span>
|
217
|
+
46: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">args=</span>(<span class="ruby-identifier">x</span>)
|
218
|
+
47: <span class="ruby-ivar">@args</span> = <span class="ruby-identifier">x</span>
|
219
|
+
48: <span class="ruby-keyword kw">end</span>
|
220
|
+
</pre>
|
221
|
+
</div>
|
222
|
+
</div>
|
223
|
+
</div>
|
224
|
+
|
225
|
+
<div id="method-M000022" class="method-detail">
|
226
|
+
<a name="M000022"></a>
|
227
|
+
|
228
|
+
<div class="method-heading">
|
229
|
+
<a href="#M000022" class="method-signature">
|
230
|
+
<span class="method-name">erb_path=</span><span class="method-args">( p )</span>
|
231
|
+
</a>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
<div class="method-description">
|
235
|
+
<p>
|
236
|
+
Set the path to ERB files. If this path is not set, <a
|
237
|
+
href="../Capcode.html">Capcode</a> will search in the <a
|
238
|
+
href="Helpers.html#M000021">static</a> path. This method is deprecated and
|
239
|
+
will be removed in version 1.0
|
240
|
+
</p>
|
241
|
+
<p><a class="source-toggle" href="#"
|
242
|
+
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
243
|
+
<div class="method-source-code" id="M000022-source">
|
244
|
+
<pre>
|
245
|
+
<span class="ruby-comment cmt"># File lib/capcode/render/erb.rb, line 7</span>
|
246
|
+
7: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">erb_path=</span>( <span class="ruby-identifier">p</span> )
|
247
|
+
8: <span class="ruby-identifier">warn</span> <span class="ruby-value str">"Capcode::Helpers.erb_path is deprecated and will be removed in version 1.0, please use `set :erb'"</span>
|
248
|
+
9: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:erb</span>, <span class="ruby-identifier">p</span>
|
249
|
+
10: <span class="ruby-keyword kw">end</span>
|
250
|
+
</pre>
|
251
|
+
</div>
|
252
|
+
</div>
|
253
|
+
</div>
|
254
|
+
|
255
|
+
<div id="method-M000023" class="method-detail">
|
256
|
+
<a name="M000023"></a>
|
257
|
+
|
258
|
+
<div class="method-heading">
|
259
|
+
<a href="#M000023" class="method-signature">
|
260
|
+
<span class="method-name">haml_path=</span><span class="method-args">( p )</span>
|
261
|
+
</a>
|
262
|
+
</div>
|
263
|
+
|
264
|
+
<div class="method-description">
|
265
|
+
<p>
|
266
|
+
Set the path to Haml files. If this path is not set, <a
|
267
|
+
href="../Capcode.html">Capcode</a> will search in the <a
|
268
|
+
href="Helpers.html#M000021">static</a> path. This method is deprecated and
|
269
|
+
will be removed in version 1.0
|
270
|
+
</p>
|
271
|
+
<p><a class="source-toggle" href="#"
|
272
|
+
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
273
|
+
<div class="method-source-code" id="M000023-source">
|
274
|
+
<pre>
|
275
|
+
<span class="ruby-comment cmt"># File lib/capcode/render/haml.rb, line 7</span>
|
276
|
+
7: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">haml_path=</span>( <span class="ruby-identifier">p</span> )
|
277
|
+
8: <span class="ruby-identifier">warn</span> <span class="ruby-value str">"Capcode::Helpers.haml_path is deprecated and will be removed in version 1.0, please use `set :haml'"</span>
|
278
|
+
9: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:haml</span>, <span class="ruby-identifier">p</span>
|
279
|
+
10: <span class="ruby-keyword kw">end</span>
|
280
|
+
</pre>
|
281
|
+
</div>
|
282
|
+
</div>
|
283
|
+
</div>
|
284
|
+
|
285
|
+
<div id="method-M000024" class="method-detail">
|
286
|
+
<a name="M000024"></a>
|
287
|
+
|
288
|
+
<div class="method-heading">
|
289
|
+
<a href="#M000024" class="method-signature">
|
290
|
+
<span class="method-name">sass_path=</span><span class="method-args">( p )</span>
|
291
|
+
</a>
|
292
|
+
</div>
|
293
|
+
|
294
|
+
<div class="method-description">
|
295
|
+
<p>
|
296
|
+
Set the path to Sass files. If this path is not set, <a
|
297
|
+
href="../Capcode.html">Capcode</a> will search in the <a
|
298
|
+
href="Helpers.html#M000021">static</a> path. This method is deprecated and
|
299
|
+
will be removed in version 1.0
|
300
|
+
</p>
|
301
|
+
<p><a class="source-toggle" href="#"
|
302
|
+
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
303
|
+
<div class="method-source-code" id="M000024-source">
|
304
|
+
<pre>
|
305
|
+
<span class="ruby-comment cmt"># File lib/capcode/render/sass.rb, line 7</span>
|
306
|
+
7: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sass_path=</span>( <span class="ruby-identifier">p</span> )
|
307
|
+
8: <span class="ruby-identifier">warn</span> <span class="ruby-value str">"Capcode::Helpers.sass_path is deprecated and will be removed in version 1.0, please use `set :sass'"</span>
|
308
|
+
9: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:sass</span>, <span class="ruby-identifier">p</span>
|
309
|
+
10: <span class="ruby-keyword kw">end</span>
|
310
|
+
</pre>
|
311
|
+
</div>
|
312
|
+
</div>
|
313
|
+
</div>
|
314
|
+
|
315
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
316
|
+
|
317
|
+
<div id="method-M000019" class="method-detail">
|
318
|
+
<a name="M000019"></a>
|
319
|
+
|
320
|
+
<div class="method-heading">
|
321
|
+
<a href="#M000019" class="method-signature">
|
176
322
|
<span class="method-name">URL</span><span class="method-args">( klass, *a )</span>
|
177
323
|
</a>
|
178
324
|
</div>
|
179
325
|
|
180
326
|
<div class="method-description">
|
181
327
|
<p>
|
182
|
-
Builds an <a href="Helpers.html#
|
328
|
+
Builds an <a href="Helpers.html#M000019">URL</a> route to a controller or a
|
183
329
|
path
|
184
330
|
</p>
|
185
331
|
<p>
|
@@ -199,41 +345,41 @@ then
|
|
199
345
|
URL( Capcode::Hello, "you" ) # => /hello/you
|
200
346
|
</pre>
|
201
347
|
<p><a class="source-toggle" href="#"
|
202
|
-
onclick="toggleCode('
|
203
|
-
<div class="method-source-code" id="
|
348
|
+
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
349
|
+
<div class="method-source-code" id="M000019-source">
|
204
350
|
<pre>
|
205
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
351
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 181</span>
|
352
|
+
181: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">URL</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
|
353
|
+
182: <span class="ruby-identifier">path</span> = <span class="ruby-keyword kw">nil</span>
|
354
|
+
183: <span class="ruby-identifier">a</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">delete_if</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> }
|
355
|
+
184:
|
356
|
+
185: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span>
|
357
|
+
186: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
358
|
+
187: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">p</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">klass</span>
|
359
|
+
188: <span class="ruby-keyword kw">end</span>
|
360
|
+
189: <span class="ruby-keyword kw">else</span>
|
361
|
+
190: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">klass</span>
|
362
|
+
191: <span class="ruby-keyword kw">end</span>
|
363
|
+
192:
|
364
|
+
193: (<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'RACK_BASE_URI'</span>]<span class="ruby-operator">||</span><span class="ruby-value str">''</span>)<span class="ruby-operator">+</span><span class="ruby-identifier">path</span><span class="ruby-operator">+</span>((<span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">></span><span class="ruby-value">0</span>)<span class="ruby-operator">?</span>(<span class="ruby-value str">"/"</span><span class="ruby-operator">+</span><span class="ruby-identifier">a</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"/"</span>))<span class="ruby-operator">:</span>(<span class="ruby-value str">""</span>))
|
365
|
+
194: <span class="ruby-keyword kw">end</span>
|
220
366
|
</pre>
|
221
367
|
</div>
|
222
368
|
</div>
|
223
369
|
</div>
|
224
370
|
|
225
|
-
<div id="method-
|
226
|
-
<a name="
|
371
|
+
<div id="method-M000020" class="method-detail">
|
372
|
+
<a name="M000020"></a>
|
227
373
|
|
228
374
|
<div class="method-heading">
|
229
|
-
<a href="#
|
375
|
+
<a href="#M000020" class="method-signature">
|
230
376
|
<span class="method-name">content_for</span><span class="method-args">( x ) {|| ...}</span>
|
231
377
|
</a>
|
232
378
|
</div>
|
233
379
|
|
234
380
|
<div class="method-description">
|
235
381
|
<p>
|
236
|
-
Calling <a href="Helpers.html#
|
382
|
+
Calling <a href="Helpers.html#M000020">content_for</a> stores a block of
|
237
383
|
markup in an identifier.
|
238
384
|
</p>
|
239
385
|
<pre>
|
@@ -269,25 +415,26 @@ markup in an identifier.
|
|
269
415
|
end
|
270
416
|
</pre>
|
271
417
|
<p><a class="source-toggle" href="#"
|
272
|
-
onclick="toggleCode('
|
273
|
-
<div class="method-source-code" id="
|
418
|
+
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
419
|
+
<div class="method-source-code" id="M000020-source">
|
274
420
|
<pre>
|
275
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
421
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 228</span>
|
422
|
+
228: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_for</span>( <span class="ruby-identifier">x</span> )
|
423
|
+
229: <span class="ruby-comment cmt">#if @@__ARGS__.map{|_| _.to_s }.include?(x.to_s)</span>
|
424
|
+
230: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">_</span>.<span class="ruby-identifier">to_s</span> }.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">x</span>.<span class="ruby-identifier">to_s</span>)
|
425
|
+
231: <span class="ruby-keyword kw">yield</span>
|
426
|
+
232: <span class="ruby-keyword kw">end</span>
|
427
|
+
233: <span class="ruby-keyword kw">end</span>
|
281
428
|
</pre>
|
282
429
|
</div>
|
283
430
|
</div>
|
284
431
|
</div>
|
285
432
|
|
286
|
-
<div id="method-
|
287
|
-
<a name="
|
433
|
+
<div id="method-M000017" class="method-detail">
|
434
|
+
<a name="M000017"></a>
|
288
435
|
|
289
436
|
<div class="method-heading">
|
290
|
-
<a href="#
|
437
|
+
<a href="#M000017" class="method-signature">
|
291
438
|
<span class="method-name">json</span><span class="method-args">( d )</span>
|
292
439
|
</a>
|
293
440
|
</div>
|
@@ -307,36 +454,36 @@ Help you to return a JSON response
|
|
307
454
|
</pre>
|
308
455
|
<p>
|
309
456
|
<b>DEPRECATED</b>, please use <tt><a
|
310
|
-
href="Helpers.html#
|
311
|
-
href="Helpers.html#
|
457
|
+
href="Helpers.html#M000016">render</a>( :<a
|
458
|
+
href="Helpers.html#M000017">json</a> => o )</tt>
|
312
459
|
</p>
|
313
460
|
<p><a class="source-toggle" href="#"
|
314
|
-
onclick="toggleCode('
|
315
|
-
<div class="method-source-code" id="
|
461
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
462
|
+
<div class="method-source-code" id="M000017-source">
|
316
463
|
<pre>
|
317
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
464
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 124</span>
|
465
|
+
124: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">json</span>( <span class="ruby-identifier">d</span> ) <span class="ruby-comment cmt">## DELETE THIS IN 1.0.0</span>
|
466
|
+
125: <span class="ruby-identifier">warn</span>( <span class="ruby-value str">"json is deprecated and will be removed in version 1.0, please use `render( :json => ... )'"</span> )
|
467
|
+
126: <span class="ruby-ivar">@response</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-value str">'application/json'</span>
|
468
|
+
127: <span class="ruby-identifier">d</span>.<span class="ruby-identifier">to_json</span>
|
469
|
+
128: <span class="ruby-keyword kw">end</span>
|
323
470
|
</pre>
|
324
471
|
</div>
|
325
472
|
</div>
|
326
473
|
</div>
|
327
474
|
|
328
|
-
<div id="method-
|
329
|
-
<a name="
|
475
|
+
<div id="method-M000018" class="method-detail">
|
476
|
+
<a name="M000018"></a>
|
330
477
|
|
331
478
|
<div class="method-heading">
|
332
|
-
<a href="#
|
479
|
+
<a href="#M000018" class="method-signature">
|
333
480
|
<span class="method-name">redirect</span><span class="method-args">( klass, *a )</span>
|
334
481
|
</a>
|
335
482
|
</div>
|
336
483
|
|
337
484
|
<div class="method-description">
|
338
485
|
<p>
|
339
|
-
Send a <a href="Helpers.html#
|
486
|
+
Send a <a href="Helpers.html#M000018">redirect</a> response
|
340
487
|
</p>
|
341
488
|
<pre>
|
342
489
|
module Capcode
|
@@ -365,7 +512,7 @@ it can be a string path
|
|
365
512
|
</pre>
|
366
513
|
<p>
|
367
514
|
it can be an http status code (by default <tt><a
|
368
|
-
href="Helpers.html#
|
515
|
+
href="Helpers.html#M000018">redirect</a></tt> use the http status code 302)
|
369
516
|
</p>
|
370
517
|
<pre>
|
371
518
|
redirect( 304, MyController )
|
@@ -375,30 +522,30 @@ For more informations about HTTP status, see <a
|
|
375
522
|
href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection">en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection</a>
|
376
523
|
</p>
|
377
524
|
<p><a class="source-toggle" href="#"
|
378
|
-
onclick="toggleCode('
|
379
|
-
<div class="method-source-code" id="
|
525
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
526
|
+
<div class="method-source-code" id="M000018-source">
|
380
527
|
<pre>
|
381
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
528
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 157</span>
|
529
|
+
157: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">redirect</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
|
530
|
+
158: <span class="ruby-identifier">httpCode</span> = <span class="ruby-value">302</span>
|
531
|
+
159:
|
532
|
+
160: <span class="ruby-keyword kw">if</span>( <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Fixnum</span> )
|
533
|
+
161: <span class="ruby-identifier">httpCode</span> = <span class="ruby-identifier">klass</span>
|
534
|
+
162: <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">shift</span>
|
535
|
+
163: <span class="ruby-keyword kw">end</span>
|
536
|
+
164:
|
537
|
+
165: [<span class="ruby-identifier">httpCode</span>, {<span class="ruby-value str">'Location'</span> =<span class="ruby-operator">></span> <span class="ruby-constant">URL</span>(<span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span>)}, <span class="ruby-value str">''</span>]
|
538
|
+
166: <span class="ruby-keyword kw">end</span>
|
392
539
|
</pre>
|
393
540
|
</div>
|
394
541
|
</div>
|
395
542
|
</div>
|
396
543
|
|
397
|
-
<div id="method-
|
398
|
-
<a name="
|
544
|
+
<div id="method-M000016" class="method-detail">
|
545
|
+
<a name="M000016"></a>
|
399
546
|
|
400
547
|
<div class="method-heading">
|
401
|
-
<a href="#
|
548
|
+
<a href="#M000016" class="method-signature">
|
402
549
|
<span class="method-name">render</span><span class="method-args">( hash )</span>
|
403
550
|
</a>
|
404
551
|
</div>
|
@@ -408,7 +555,7 @@ href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection">en
|
|
408
555
|
Render a view
|
409
556
|
</p>
|
410
557
|
<p>
|
411
|
-
<a href="Helpers.html#
|
558
|
+
<a href="Helpers.html#M000016">render</a>‘s parameter can be a Hash
|
412
559
|
or a string. Passing a string is equivalent to do
|
413
560
|
</p>
|
414
561
|
<pre>
|
@@ -437,13 +584,13 @@ exist in sass_path
|
|
437
584
|
<li>:text => "my text"
|
438
585
|
|
439
586
|
</li>
|
440
|
-
<li>:<a href="Helpers.html#
|
587
|
+
<li>:<a href="Helpers.html#M000017">json</a> => MyObject : this suppose
|
441
588
|
that‘s MyObject respond to .to_json
|
442
589
|
|
443
590
|
</li>
|
444
|
-
<li>:<a href="Helpers.html#
|
591
|
+
<li>:<a href="Helpers.html#M000021">static</a> => "my_file.xxx" :
|
445
592
|
this suppose that‘s my_file.xxx exist in the <a
|
446
|
-
href="Helpers.html#
|
593
|
+
href="Helpers.html#M000021">static</a> directory
|
447
594
|
|
448
595
|
</li>
|
449
596
|
<li>:xml => :my_func : :my_func must be defined in <a
|
@@ -461,66 +608,79 @@ If you want to use a specific layout, you can specify it with option
|
|
461
608
|
:layout
|
462
609
|
</pre>
|
463
610
|
<p>
|
611
|
+
If you want to change the Content-Type, you can specify it with option
|
612
|
+
</p>
|
613
|
+
<pre>
|
614
|
+
:content_type
|
615
|
+
</pre>
|
616
|
+
<p>
|
617
|
+
Note that this will not work with the JSON renderer
|
618
|
+
</p>
|
619
|
+
<p>
|
464
620
|
If you use the WebDav renderer, you can use the option
|
465
621
|
</p>
|
466
622
|
<pre>
|
467
623
|
:resource_class (see http://github.com/georgi/rack_dav for more informations)
|
468
624
|
</pre>
|
469
625
|
<p><a class="source-toggle" href="#"
|
470
|
-
onclick="toggleCode('
|
471
|
-
<div class="method-source-code" id="
|
626
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
627
|
+
<div class="method-source-code" id="M000016-source">
|
472
628
|
<pre>
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
629
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 76</span>
|
630
|
+
76: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>( <span class="ruby-identifier">hash</span> )
|
631
|
+
77: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Hash</span>
|
632
|
+
78: <span class="ruby-identifier">render_type</span> = <span class="ruby-keyword kw">nil</span>
|
633
|
+
79:
|
634
|
+
80: <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
635
|
+
81: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">"render_#{key.to_s}"</span>)
|
636
|
+
82: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span>
|
637
|
+
83: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">"Can't use multiple renderer (`#{render_type}' and `#{key}') !"</span>, <span class="ruby-identifier">caller</span>
|
638
|
+
84: <span class="ruby-keyword kw">end</span>
|
639
|
+
85: <span class="ruby-identifier">render_type</span> = <span class="ruby-identifier">key</span>
|
640
|
+
86: <span class="ruby-keyword kw">end</span>
|
641
|
+
87: <span class="ruby-keyword kw">end</span>
|
642
|
+
88:
|
643
|
+
89: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span>
|
644
|
+
90: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-value str">"Renderer type not specified!"</span>, <span class="ruby-identifier">caller</span>
|
645
|
+
91: <span class="ruby-keyword kw">end</span>
|
646
|
+
92:
|
647
|
+
93: <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">"render_#{render_type.to_s}"</span>)
|
648
|
+
94: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">"#{render_type} renderer not present ! please require 'capcode/render/#{render_type}'"</span>, <span class="ruby-identifier">caller</span>
|
649
|
+
95: <span class="ruby-keyword kw">end</span>
|
650
|
+
96:
|
651
|
+
97: <span class="ruby-identifier">render_name</span> = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">render_type</span>)
|
652
|
+
98: <span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:content_type</span>)
|
653
|
+
99: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">content_type</span>.<span class="ruby-identifier">nil?</span>
|
654
|
+
100: <span class="ruby-ivar">@response</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">content_type</span>
|
655
|
+
101: <span class="ruby-keyword kw">end</span>
|
656
|
+
102:
|
657
|
+
103: <span class="ruby-keyword kw">begin</span>
|
658
|
+
104: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>( <span class="ruby-node">"render_#{render_type.to_s}"</span>, <span class="ruby-identifier">render_name</span>, <span class="ruby-identifier">hash</span> )
|
659
|
+
105: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
660
|
+
106: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">"Error rendering `#{render_type.to_s}' : #{e.message}"</span>, <span class="ruby-identifier">caller</span>
|
661
|
+
107: <span class="ruby-keyword kw">end</span>
|
662
|
+
108: <span class="ruby-keyword kw">else</span>
|
663
|
+
109: <span class="ruby-identifier">render</span>( <span class="ruby-identifier">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">hash</span> )
|
664
|
+
110: <span class="ruby-keyword kw">end</span>
|
665
|
+
111: <span class="ruby-keyword kw">end</span>
|
506
666
|
</pre>
|
507
667
|
</div>
|
508
668
|
</div>
|
509
669
|
</div>
|
510
670
|
|
511
|
-
<div id="method-
|
512
|
-
<a name="
|
671
|
+
<div id="method-M000025" class="method-detail">
|
672
|
+
<a name="M000025"></a>
|
513
673
|
|
514
674
|
<div class="method-heading">
|
515
|
-
<a href="#
|
675
|
+
<a href="#M000025" class="method-signature">
|
516
676
|
<span class="method-name">render_webdav</span><span class="method-args">( f, opts )</span>
|
517
677
|
</a>
|
518
678
|
</div>
|
519
679
|
|
520
680
|
<div class="method-description">
|
521
681
|
<p><a class="source-toggle" href="#"
|
522
|
-
onclick="toggleCode('
|
523
|
-
<div class="method-source-code" id="
|
682
|
+
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
683
|
+
<div class="method-source-code" id="M000025-source">
|
524
684
|
<pre>
|
525
685
|
<span class="ruby-comment cmt"># File lib/capcode/render/webdav.rb, line 19</span>
|
526
686
|
19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render_webdav</span>( <span class="ruby-identifier">f</span>, <span class="ruby-identifier">opts</span> )
|
@@ -553,41 +713,41 @@ If you use the WebDav renderer, you can use the option
|
|
553
713
|
</div>
|
554
714
|
</div>
|
555
715
|
|
556
|
-
<div id="method-
|
557
|
-
<a name="
|
716
|
+
<div id="method-M000021" class="method-detail">
|
717
|
+
<a name="M000021"></a>
|
558
718
|
|
559
719
|
<div class="method-heading">
|
560
|
-
<a href="#
|
720
|
+
<a href="#M000021" class="method-signature">
|
561
721
|
<span class="method-name">static</span><span class="method-args">()</span>
|
562
722
|
</a>
|
563
723
|
</div>
|
564
724
|
|
565
725
|
<div class="method-description">
|
566
726
|
<p>
|
567
|
-
Return information about the <a href="Helpers.html#
|
727
|
+
Return information about the <a href="Helpers.html#M000021">static</a>
|
568
728
|
directory
|
569
729
|
</p>
|
570
730
|
<ul>
|
571
|
-
<li><tt><a href="Helpers.html#
|
572
|
-
href="Helpers.html#
|
731
|
+
<li><tt><a href="Helpers.html#M000021">static</a>[:uri]</tt> give the <a
|
732
|
+
href="Helpers.html#M000021">static</a> URI
|
573
733
|
|
574
734
|
</li>
|
575
|
-
<li><tt><a href="Helpers.html#
|
576
|
-
the <a href="Helpers.html#
|
735
|
+
<li><tt><a href="Helpers.html#M000021">static</a>[:path]</tt> give the path to
|
736
|
+
the <a href="Helpers.html#M000021">static</a> directory on the server
|
577
737
|
|
578
738
|
</li>
|
579
739
|
</ul>
|
580
740
|
<p><a class="source-toggle" href="#"
|
581
|
-
onclick="toggleCode('
|
582
|
-
<div class="method-source-code" id="
|
741
|
+
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
742
|
+
<div class="method-source-code" id="M000021-source">
|
583
743
|
<pre>
|
584
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
744
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 239</span>
|
745
|
+
239: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">static</span>
|
746
|
+
240: {
|
747
|
+
241: <span class="ruby-identifier">:uri</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>,
|
748
|
+
242: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">></span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"."</span>, <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span> ) )
|
749
|
+
243: }
|
750
|
+
244: <span class="ruby-keyword kw">end</span>
|
591
751
|
</pre>
|
592
752
|
</div>
|
593
753
|
</div>
|