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,887 +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>File: README.rdoc</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="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>Mon Jan 10 21:26:22 +0100 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><a href="../classes/Capcode.html">Capcode</a></h1>
|
73
|
-
<p>
|
74
|
-
Copyright (C) 2009, 2010 Gregoire Lejeune
|
75
|
-
</p>
|
76
|
-
<ul>
|
77
|
-
<li>home : <a href="http://capcode.rubyforge.org">capcode.rubyforge.org</a>
|
78
|
-
|
79
|
-
</li>
|
80
|
-
<li>doc : <a
|
81
|
-
href="http://rdoc.info/projects/glejeune/Capcode">rdoc.info/projects/glejeune/Capcode</a>
|
82
|
-
|
83
|
-
</li>
|
84
|
-
<li>book (fr) : <a
|
85
|
-
href="http://www.algorithmique.net/capcode">www.algorithmique.net/capcode</a>/
|
86
|
-
|
87
|
-
</li>
|
88
|
-
</ul>
|
89
|
-
<h2>DESCRIPTION:</h2>
|
90
|
-
<p>
|
91
|
-
<a href="../classes/Capcode.html">Capcode</a> is a web microframework
|
92
|
-
</p>
|
93
|
-
<h2>FEATURES/PROBLEMS:</h2>
|
94
|
-
<h3>0.9.9</h3>
|
95
|
-
<ul>
|
96
|
-
<li>Better static files support <a
|
97
|
-
href="http://github.com/glejeune/Capcode/tree/master/examples/static.rb">See
|
98
|
-
example static.rb</a>
|
99
|
-
|
100
|
-
</li>
|
101
|
-
<li>Rewrite routes loader
|
102
|
-
|
103
|
-
</li>
|
104
|
-
</ul>
|
105
|
-
<h3>0.9.8</h3>
|
106
|
-
<ul>
|
107
|
-
<li>Add "any" to easly replace an <tt>alias_method :post, :get</tt>
|
108
|
-
|
109
|
-
</li>
|
110
|
-
<li>Bug correction in Filter : actions are now executed in the order they are
|
111
|
-
declared
|
112
|
-
|
113
|
-
</li>
|
114
|
-
<li>Filters execution stop at the first non nul response
|
115
|
-
|
116
|
-
</li>
|
117
|
-
<li>Add "log" helper
|
118
|
-
|
119
|
-
</li>
|
120
|
-
<li>Add <a href="http://unicorn.bogomips.org/">Unicorn</a> and <a
|
121
|
-
href="http://rainbows.rubyforge.org/">Rainbows</a> supports
|
122
|
-
(<b>EXPERIMENTAL</b>)
|
123
|
-
|
124
|
-
</li>
|
125
|
-
<li>Add —server option
|
126
|
-
|
127
|
-
</li>
|
128
|
-
</ul>
|
129
|
-
<h3>0.9.7</h3>
|
130
|
-
<ul>
|
131
|
-
<li>Major bug correction in Capcode.URL
|
132
|
-
|
133
|
-
</li>
|
134
|
-
</ul>
|
135
|
-
<h3>0.9.6</h3>
|
136
|
-
<ul>
|
137
|
-
<li>More debug trace
|
138
|
-
|
139
|
-
</li>
|
140
|
-
<li>Bug correction in the custom version of Rack::URLmap
|
141
|
-
|
142
|
-
</li>
|
143
|
-
</ul>
|
144
|
-
<h3>0.9.5</h3>
|
145
|
-
<ul>
|
146
|
-
<li>Major bug correction
|
147
|
-
|
148
|
-
</li>
|
149
|
-
</ul>
|
150
|
-
<h3>0.9.4</h3>
|
151
|
-
<ul>
|
152
|
-
<li>You can now create a controler without specifying the root name. If so the
|
153
|
-
name of the class will be used. <a
|
154
|
-
href="http://github.com/glejeune/Capcode/tree/master/examples/route.rb">see
|
155
|
-
example route.rb</a>.
|
156
|
-
|
157
|
-
</li>
|
158
|
-
<li>Major bug correction in Route
|
159
|
-
|
160
|
-
</li>
|
161
|
-
<li>render :text => … now really render text
|
162
|
-
|
163
|
-
</li>
|
164
|
-
<li>rXXX methods in HTTPError can now receive a second optional parameter
|
165
|
-
corresponding to headers
|
166
|
-
|
167
|
-
</li>
|
168
|
-
<li>Huge bug correction in Capcode::Helpers.URL
|
169
|
-
|
170
|
-
</li>
|
171
|
-
<li>Use a custom version of Rack::URLmap
|
172
|
-
|
173
|
-
</li>
|
174
|
-
</ul>
|
175
|
-
<h3>0.9.3</h3>
|
176
|
-
<ul>
|
177
|
-
<li>Major bug correction
|
178
|
-
|
179
|
-
</li>
|
180
|
-
</ul>
|
181
|
-
<h3>0.9.2</h3>
|
182
|
-
<ul>
|
183
|
-
<li>Remove JSON dependency
|
184
|
-
|
185
|
-
</li>
|
186
|
-
<li>Add the "HTTP code" renderer, so you can now use something like
|
187
|
-
this : render 200 => "OK", :server => "<a
|
188
|
-
href="../classes/Capcode.html">Capcode</a>", …
|
189
|
-
|
190
|
-
</li>
|
191
|
-
<li>Reintroduce before_filter. <a
|
192
|
-
href="http://github.com/glejeune/Capcode/tree/master/examples/filter.rb">See
|
193
|
-
example filter.rb</a>.
|
194
|
-
|
195
|
-
</li>
|
196
|
-
<li>Remove mime-types dependency
|
197
|
-
|
198
|
-
</li>
|
199
|
-
</ul>
|
200
|
-
<h3>0.9.1</h3>
|
201
|
-
<ul>
|
202
|
-
<li>You don‘t need to require the renderers. This will be done by <a
|
203
|
-
href="../classes/Capcode.html">Capcode</a> at use time.
|
204
|
-
|
205
|
-
</li>
|
206
|
-
<li>Major bug correction for jRuby
|
207
|
-
|
208
|
-
</li>
|
209
|
-
</ul>
|
210
|
-
<h3>0.9.0</h3>
|
211
|
-
<ul>
|
212
|
-
<li><b>IMPORTANT</b>
|
213
|
-
|
214
|
-
<ul>
|
215
|
-
<li>THIS VERSION IS A MAJOR ENHANCEMENT : YOU MUST UNINSTALL ALL PREVIOUS
|
216
|
-
VERSIONS !!!
|
217
|
-
|
218
|
-
<pre>
|
219
|
-
gem uninstall Capode --version '< 0.9.0'
|
220
|
-
</pre>
|
221
|
-
</li>
|
222
|
-
<li>Renderers and database accessors have been extracted and are now in the <a
|
223
|
-
href="http://github.com/glejeune/Capcode.more">plugins repository</a>. Each
|
224
|
-
plugin is a gem that‘s can be installed separately.
|
225
|
-
|
226
|
-
</li>
|
227
|
-
</ul>
|
228
|
-
</li>
|
229
|
-
<li><b>Important, but less!</b>
|
230
|
-
|
231
|
-
<ul>
|
232
|
-
<li>Add <a href="http://jashkenas.github.com/coffee-script/">Coffee-Script</a>
|
233
|
-
renderer
|
234
|
-
|
235
|
-
</li>
|
236
|
-
<li>Update renderers options
|
237
|
-
|
238
|
-
</li>
|
239
|
-
<li>Rewrite configuration
|
240
|
-
|
241
|
-
</li>
|
242
|
-
<li>Bug corrections in all DB modules
|
243
|
-
|
244
|
-
</li>
|
245
|
-
</ul>
|
246
|
-
</li>
|
247
|
-
</ul>
|
248
|
-
<h3>0.8.9</h3>
|
249
|
-
<ul>
|
250
|
-
<li>Add Thin support
|
251
|
-
|
252
|
-
</li>
|
253
|
-
<li>Add MongoDB support
|
254
|
-
|
255
|
-
</li>
|
256
|
-
<li>Major bug correction in Markaby renderer
|
257
|
-
|
258
|
-
</li>
|
259
|
-
</ul>
|
260
|
-
<h3>0.8.8</h3>
|
261
|
-
<ul>
|
262
|
-
<li>Add mustache renderer
|
263
|
-
|
264
|
-
</li>
|
265
|
-
<li>Add AcriveRecord support (see example blog-ar.rb)
|
266
|
-
|
267
|
-
</li>
|
268
|
-
<li>Add Sequel support (see example blog-sq.rb)
|
269
|
-
|
270
|
-
</li>
|
271
|
-
<li>Add Binary renderer (see example render-binary.rb)
|
272
|
-
|
273
|
-
</li>
|
274
|
-
<li>Add Mail renderer (see example render-mail.rb)
|
275
|
-
|
276
|
-
</li>
|
277
|
-
<li>Add Redirect renderer (see examples render-redirect.rb and render-mail.rb)
|
278
|
-
|
279
|
-
</li>
|
280
|
-
<li>Add "none" renderer (return a 204 status code)
|
281
|
-
|
282
|
-
</li>
|
283
|
-
</ul>
|
284
|
-
<h3>0.8.7</h3>
|
285
|
-
<ul>
|
286
|
-
<li>Route‘s captures are now passed to all methods in a controller
|
287
|
-
|
288
|
-
</li>
|
289
|
-
<li>Add :content_type option to renderers (see render-image.rb)
|
290
|
-
|
291
|
-
</li>
|
292
|
-
<li>Add <a href="../classes/Capcode.html#M000013">Capcode.set</a> for
|
293
|
-
configuration. So Capcode::Herpers#erb_path=, Capcode::Herpers#sass_path=
|
294
|
-
and Capcode::Herpers#haml_path= are deprecated, you must now use `set :erb,
|
295
|
-
…’, `set :sass, …’ and `set :haml, …’
|
296
|
-
(see render-erb.rb and render-haml_sass.rb)
|
297
|
-
|
298
|
-
</li>
|
299
|
-
<li>Add <a href="../classes/Capcode.html#M000008">Capcode.use</a> to allow
|
300
|
-
usage of Rack middlewares (see render-use.rb)
|
301
|
-
|
302
|
-
</li>
|
303
|
-
</ul>
|
304
|
-
<h3>0.8.6</h3>
|
305
|
-
<ul>
|
306
|
-
<li>HUGE bug correction
|
307
|
-
|
308
|
-
</li>
|
309
|
-
</ul>
|
310
|
-
<h3>0.8.5</h3>
|
311
|
-
<ul>
|
312
|
-
<li><a href="../classes/Capcode.html">Capcode</a> now work with Phusion
|
313
|
-
Passenger \o/
|
314
|
-
|
315
|
-
</li>
|
316
|
-
<li>Add WebDAV renderer (need rack_dav) (see examples render-webdav.rb and
|
317
|
-
auth-webdav.rb)
|
318
|
-
|
319
|
-
</li>
|
320
|
-
<li>Change default listen host from localhost to 0.0.0.0
|
321
|
-
|
322
|
-
</li>
|
323
|
-
<li>Add require_auth helper for basic or digest HTTP Authentication (see
|
324
|
-
examples auth-basic.rb and auth-digest.rb)
|
325
|
-
|
326
|
-
</li>
|
327
|
-
</ul>
|
328
|
-
<h3>0.8.4</h3>
|
329
|
-
<ul>
|
330
|
-
<li>Major (really MAJOR) bugs corrections in renderers
|
331
|
-
|
332
|
-
</li>
|
333
|
-
<li>Add many renderer’ examples
|
334
|
-
|
335
|
-
</li>
|
336
|
-
<li>The static rendere now accept a new option : :exact_path. If :exact_path is
|
337
|
-
set to true, the static rendere redirect you to the exact static url of the
|
338
|
-
file. Else it just give the content of the file. Default is true. (see
|
339
|
-
example render-static.rb)
|
340
|
-
|
341
|
-
</li>
|
342
|
-
<li>redirect now accept an optional HTTP status code as first parameter
|
343
|
-
|
344
|
-
</li>
|
345
|
-
</ul>
|
346
|
-
<h3>0.8.3</h3>
|
347
|
-
<ul>
|
348
|
-
<li>Add PUT and DELETE actions (see rest example)
|
349
|
-
|
350
|
-
</li>
|
351
|
-
</ul>
|
352
|
-
<h3>0.8.2</h3>
|
353
|
-
<ul>
|
354
|
-
<li>Add XML renderer (see rss example)
|
355
|
-
|
356
|
-
</li>
|
357
|
-
<li>Major bug corrections
|
358
|
-
|
359
|
-
</li>
|
360
|
-
<li>Add Helpers.static
|
361
|
-
|
362
|
-
</li>
|
363
|
-
<li>New example : upload.rb
|
364
|
-
|
365
|
-
</li>
|
366
|
-
<li>The database’ configuration file is no more relative to the root
|
367
|
-
directory but to the main file
|
368
|
-
|
369
|
-
</li>
|
370
|
-
</ul>
|
371
|
-
<h3>0.8.1</h3>
|
372
|
-
<ul>
|
373
|
-
<li>Sorry for 0.8.0 !!
|
374
|
-
|
375
|
-
</li>
|
376
|
-
</ul>
|
377
|
-
<h3>0.8.0</h3>
|
378
|
-
<ul>
|
379
|
-
<li>Bugs corrections in haml and text renderer
|
380
|
-
|
381
|
-
</li>
|
382
|
-
<li>Text renderer is now automaticaly included
|
383
|
-
|
384
|
-
</li>
|
385
|
-
<li>Add sass renderer
|
386
|
-
|
387
|
-
</li>
|
388
|
-
<li>:working_directory is no more available
|
389
|
-
|
390
|
-
</li>
|
391
|
-
<li>:root is now the real root directory
|
392
|
-
|
393
|
-
</li>
|
394
|
-
<li>Add :static option to set the directory for static files
|
395
|
-
|
396
|
-
</li>
|
397
|
-
<li>Add -r and -s (for root and static directories) options
|
398
|
-
|
399
|
-
</li>
|
400
|
-
<li>Add static renderer
|
401
|
-
|
402
|
-
</li>
|
403
|
-
</ul>
|
404
|
-
<h3>0.7.1</h3>
|
405
|
-
<ul>
|
406
|
-
<li>You need to include <a
|
407
|
-
href="../classes/Capcode/Resource.html">Capcode::Resource</a> in your
|
408
|
-
models !!!!
|
409
|
-
|
410
|
-
</li>
|
411
|
-
<li>Add option —version
|
412
|
-
|
413
|
-
</li>
|
414
|
-
</ul>
|
415
|
-
<h3>0.7.0</h3>
|
416
|
-
<ul>
|
417
|
-
<li>You no more need to include <a
|
418
|
-
href="../classes/Capcode/Resource.html">Capcode::Resource</a> in your
|
419
|
-
models
|
420
|
-
|
421
|
-
</li>
|
422
|
-
<li><a href="../classes/Capcode.html#M000011">Capcode.run</a> now accept a
|
423
|
-
block. The content of the block is executed just before the server start.
|
424
|
-
|
425
|
-
</li>
|
426
|
-
<li>Add options support : you can now change the defaults port and host,
|
427
|
-
daemonize or not and run in console mode.
|
428
|
-
|
429
|
-
</li>
|
430
|
-
</ul>
|
431
|
-
<h3>0.6.2</h3>
|
432
|
-
<ul>
|
433
|
-
<li>Add Markaby, Erb and Haml layout see Capcode::Helpers.render for more
|
434
|
-
informations
|
435
|
-
|
436
|
-
</li>
|
437
|
-
<li>Add content_for…
|
438
|
-
|
439
|
-
</li>
|
440
|
-
<li>Major bugs corrections
|
441
|
-
|
442
|
-
</li>
|
443
|
-
</ul>
|
444
|
-
<h3>0.6.1</h3>
|
445
|
-
<ul>
|
446
|
-
<li>Major bugs corrections in haml and erb renderer ($%&! Windows)
|
447
|
-
|
448
|
-
</li>
|
449
|
-
<li>Major bugs corrections in Route.call
|
450
|
-
|
451
|
-
</li>
|
452
|
-
<li>Add Markaby layout support
|
453
|
-
|
454
|
-
</li>
|
455
|
-
<li>Rewrite blog-couchdb example (based on the very sympatic camping example :
|
456
|
-
<a
|
457
|
-
href="http://github.com/judofyr/camping/blob/master/examples/blog.rb">github.com/judofyr/camping/blob/master/examples/blog.rb</a>)
|
458
|
-
|
459
|
-
</li>
|
460
|
-
</ul>
|
461
|
-
<h3>0.6.0</h3>
|
462
|
-
<ul>
|
463
|
-
<li>Add :root option to <a
|
464
|
-
href="../classes/Capcode.html#M000011">Capcode.run</a>. This option allow
|
465
|
-
you to specify the root directory for static files
|
466
|
-
|
467
|
-
</li>
|
468
|
-
<li>Add :working_directory option to <a
|
469
|
-
href="../classes/Capcode.html#M000011">Capcode.run</a>. This option allow
|
470
|
-
you to specify the working directory
|
471
|
-
|
472
|
-
</li>
|
473
|
-
<li>If ’/’ route is not defined but /index.html exist, display
|
474
|
-
index
|
475
|
-
|
476
|
-
</li>
|
477
|
-
<li>add mime-types dependency
|
478
|
-
|
479
|
-
</li>
|
480
|
-
<li>Bug correction in erb and haml renderer
|
481
|
-
|
482
|
-
</li>
|
483
|
-
</ul>
|
484
|
-
<h3>0.5.0</h3>
|
485
|
-
<ul>
|
486
|
-
<li>Add Haml and Markaby renderer
|
487
|
-
|
488
|
-
</li>
|
489
|
-
<li>json is deprecated and replaced by render( :json => … )
|
490
|
-
|
491
|
-
</li>
|
492
|
-
</ul>
|
493
|
-
<h3>0.4.0</h3>
|
494
|
-
<ul>
|
495
|
-
<li>Major bug correction !
|
496
|
-
|
497
|
-
</li>
|
498
|
-
<li>Add views…
|
499
|
-
|
500
|
-
</li>
|
501
|
-
</ul>
|
502
|
-
<h3>0.3.0</h3>
|
503
|
-
<ul>
|
504
|
-
<li>Work with Rack 1.0.0
|
505
|
-
|
506
|
-
</li>
|
507
|
-
</ul>
|
508
|
-
<h3>0.2.0</h3>
|
509
|
-
<ul>
|
510
|
-
<li>Add models with DataMapper and couch_foo
|
511
|
-
|
512
|
-
</li>
|
513
|
-
<li>Add two new options : :daemonize and :pid
|
514
|
-
|
515
|
-
</li>
|
516
|
-
<li>Bug correction in Route.
|
517
|
-
|
518
|
-
</li>
|
519
|
-
</ul>
|
520
|
-
<h3>0.1.0</h3>
|
521
|
-
<ul>
|
522
|
-
<li>First public release
|
523
|
-
|
524
|
-
</li>
|
525
|
-
<li>No models !!!
|
526
|
-
|
527
|
-
</li>
|
528
|
-
</ul>
|
529
|
-
<h2>SYNOPSIS:</h2>
|
530
|
-
<pre>
|
531
|
-
# file: sample.rb
|
532
|
-
require 'rubygems'
|
533
|
-
require 'capcode'
|
534
|
-
|
535
|
-
module Capcode
|
536
|
-
class Hello < Route '/hello'
|
537
|
-
def get
|
538
|
-
"Hello World #{Time.now} !"
|
539
|
-
end
|
540
|
-
end
|
541
|
-
end
|
542
|
-
|
543
|
-
Capcode.run( )
|
544
|
-
</pre>
|
545
|
-
<h3>Running <a href="../classes/Capcode.html">Capcode</a> Apps</h3>
|
546
|
-
<ul>
|
547
|
-
<li>Run: <tt>ruby sample.rb</tt>
|
548
|
-
|
549
|
-
</li>
|
550
|
-
<li>Visit <a href="http://localhost:3000">localhost:3000</a>/
|
551
|
-
|
552
|
-
</li>
|
553
|
-
</ul>
|
554
|
-
<h3>Create model</h3>
|
555
|
-
<pre>
|
556
|
-
require 'rubygems'
|
557
|
-
require 'capcode'
|
558
|
-
require 'capcode/base/dm' # or require 'capcode/base/couchdb'
|
559
|
-
|
560
|
-
class Story < Capcode::Base
|
561
|
-
include Capcode::Resource
|
562
|
-
|
563
|
-
property :id, Integer, :serial => true # only with DataMapper !
|
564
|
-
property :title, String
|
565
|
-
property :body, String
|
566
|
-
property :date, String
|
567
|
-
end
|
568
|
-
</pre>
|
569
|
-
<p>
|
570
|
-
See <tt>examples/blog-dm.rb</tt> and/or <tt>examples/blog-couchdb.rb</tt>
|
571
|
-
for complete examples.
|
572
|
-
</p>
|
573
|
-
<h3>Create View</h3>
|
574
|
-
<pre>
|
575
|
-
# file: sample.rb
|
576
|
-
require 'rubygems'
|
577
|
-
require 'capcode'
|
578
|
-
|
579
|
-
module Capcode
|
580
|
-
class Hello < Route '/hello'
|
581
|
-
def get
|
582
|
-
@t = Time.now
|
583
|
-
render :time
|
584
|
-
end
|
585
|
-
end
|
586
|
-
end
|
587
|
-
|
588
|
-
module Capcode::Views
|
589
|
-
def time
|
590
|
-
"Hello world #{@t}"
|
591
|
-
end
|
592
|
-
end
|
593
|
-
|
594
|
-
Capcode.run( )
|
595
|
-
</pre>
|
596
|
-
<h3>Create Helper</h3>
|
597
|
-
<pre>
|
598
|
-
# file: sample.rb
|
599
|
-
require 'rubygems'
|
600
|
-
require 'capcode'
|
601
|
-
|
602
|
-
module Capcode
|
603
|
-
class Hello < Route '/hello'
|
604
|
-
def get
|
605
|
-
@t = Time.now
|
606
|
-
render :time
|
607
|
-
end
|
608
|
-
end
|
609
|
-
end
|
610
|
-
|
611
|
-
module Capcode::Helpers
|
612
|
-
def bold( &b )
|
613
|
-
"<b>"+yield+"</b>"
|
614
|
-
end
|
615
|
-
end
|
616
|
-
|
617
|
-
module Capcode::Views
|
618
|
-
def time
|
619
|
-
"Hello world " + bold { @t }
|
620
|
-
end
|
621
|
-
end
|
622
|
-
|
623
|
-
Capcode.run( )
|
624
|
-
</pre>
|
625
|
-
<h3>Render with Markaby</h3>
|
626
|
-
<pre>
|
627
|
-
# file: sample.rb
|
628
|
-
require 'rubygems'
|
629
|
-
require 'capcode'
|
630
|
-
|
631
|
-
module Capcode
|
632
|
-
class Hello < Route '/hello'
|
633
|
-
def get
|
634
|
-
@t = Time.now
|
635
|
-
|
636
|
-
# This implies that capcode-render-markaby is installed !
|
637
|
-
render :markaby => :time
|
638
|
-
end
|
639
|
-
end
|
640
|
-
end
|
641
|
-
|
642
|
-
module Capcode::Views
|
643
|
-
def time
|
644
|
-
# We use Markaby in Capcode::Views.time
|
645
|
-
html do
|
646
|
-
body do
|
647
|
-
p {
|
648
|
-
text "Hello World "
|
649
|
-
b @t
|
650
|
-
}
|
651
|
-
end
|
652
|
-
end
|
653
|
-
end
|
654
|
-
end
|
655
|
-
|
656
|
-
Capcode.run( )
|
657
|
-
</pre>
|
658
|
-
<h3>Render with Haml</h3>
|
659
|
-
<pre>
|
660
|
-
# file: sample.rb
|
661
|
-
require 'rubygems'
|
662
|
-
require 'capcode'
|
663
|
-
|
664
|
-
module Capcode
|
665
|
-
set :haml, "./my_haml_views"
|
666
|
-
|
667
|
-
class Hello < Route '/hello'
|
668
|
-
def get
|
669
|
-
@t = Time.now
|
670
|
-
|
671
|
-
# This implies that capcode-render-haml is installed !
|
672
|
-
render :haml => :time
|
673
|
-
end
|
674
|
-
end
|
675
|
-
end
|
676
|
-
|
677
|
-
Capcode.run( )
|
678
|
-
|
679
|
-
# ./my_haml_views/time.haml
|
680
|
-
%html
|
681
|
-
%body
|
682
|
-
%p
|
683
|
-
Hello World
|
684
|
-
= @t
|
685
|
-
</pre>
|
686
|
-
<h3>Render with JSON</h3>
|
687
|
-
<pre>
|
688
|
-
# file: sample.rb
|
689
|
-
require 'rubygems'
|
690
|
-
require 'capcode'
|
691
|
-
|
692
|
-
module Capcode
|
693
|
-
class Hello < Route '/hello'
|
694
|
-
def get
|
695
|
-
@t = Time.now
|
696
|
-
|
697
|
-
# This implies that capcode-render-json is installed !
|
698
|
-
render :json => { :time => @t }
|
699
|
-
end
|
700
|
-
end
|
701
|
-
end
|
702
|
-
|
703
|
-
Capcode.run( )
|
704
|
-
</pre>
|
705
|
-
<h3>Render with WebDAV</h3>
|
706
|
-
<pre>
|
707
|
-
# file: sample.rb
|
708
|
-
require 'rubygems'
|
709
|
-
require 'capcode'
|
710
|
-
|
711
|
-
module Capcode
|
712
|
-
|
713
|
-
# !!! Render file from /Users/greg/temp !!!
|
714
|
-
class WebDav < Route '/temp'
|
715
|
-
def get
|
716
|
-
# This implies that capcode-render-webdav is installed !
|
717
|
-
render :webdav => "/Users/greg/temp"
|
718
|
-
end
|
719
|
-
|
720
|
-
def method_missing(id, *a, &b)
|
721
|
-
get
|
722
|
-
end
|
723
|
-
end
|
724
|
-
|
725
|
-
class Index < Route '/'
|
726
|
-
def get
|
727
|
-
render "WebDav server acces : <a href='#{URL(Capcode::WebDav)}'>#{URL(Capcode::WebDav)}</a>"
|
728
|
-
end
|
729
|
-
end
|
730
|
-
|
731
|
-
end
|
732
|
-
|
733
|
-
Capcode.run( )
|
734
|
-
</pre>
|
735
|
-
<h3>HTTP Authentication</h3>
|
736
|
-
<pre>
|
737
|
-
# file: sample.rb
|
738
|
-
require 'rubygems'
|
739
|
-
require 'capcode'
|
740
|
-
|
741
|
-
module Capcode
|
742
|
-
class Public < Route '/public'
|
743
|
-
def get
|
744
|
-
render "This page is not protected"
|
745
|
-
end
|
746
|
-
end
|
747
|
-
|
748
|
-
class Private < Route '/private'
|
749
|
-
def get
|
750
|
-
http_authentication( :type => :digest, :realm => "Private part" ) {
|
751
|
-
{ "greg" => "p4ssw0rd" }
|
752
|
-
}
|
753
|
-
|
754
|
-
render "This page is private - Hello #{request.env['REMOTE_USER']}"
|
755
|
-
end
|
756
|
-
end
|
757
|
-
end
|
758
|
-
|
759
|
-
Capcode.run( )
|
760
|
-
</pre>
|
761
|
-
<p>
|
762
|
-
Second example :
|
763
|
-
</p>
|
764
|
-
<pre>
|
765
|
-
# file: sample.rb
|
766
|
-
require 'rubygems'
|
767
|
-
require 'capcode'
|
768
|
-
|
769
|
-
module Capcode
|
770
|
-
|
771
|
-
http_authentication( :type => :digest, :realm => "Private part", :routes => ['/admin', '/private'] ) {
|
772
|
-
{ "greg" => "p4ssw0rd" }
|
773
|
-
}
|
774
|
-
|
775
|
-
class Public < Route '/public'
|
776
|
-
def get
|
777
|
-
render "This page is not protected"
|
778
|
-
end
|
779
|
-
end
|
780
|
-
|
781
|
-
class Private < Route '/private'
|
782
|
-
def get
|
783
|
-
render "This page is private - Hello #{request.env['REMOTE_USER']}"
|
784
|
-
end
|
785
|
-
end
|
786
|
-
|
787
|
-
class PrivateAgain < Route '/private/again'
|
788
|
-
def get
|
789
|
-
render "This page is also private - Hello #{request.env['REMOTE_USER']}"
|
790
|
-
end
|
791
|
-
end
|
792
|
-
|
793
|
-
class Admin < Route '/admin'
|
794
|
-
def get
|
795
|
-
render "This page is private - Hello #{request.env['REMOTE_USER']}"
|
796
|
-
end
|
797
|
-
end
|
798
|
-
end
|
799
|
-
|
800
|
-
Capcode.run( )
|
801
|
-
</pre>
|
802
|
-
<h2>DEPLOYMENT</h2>
|
803
|
-
<h3>With Passenger</h3>
|
804
|
-
<p>
|
805
|
-
First create the directory structure :
|
806
|
-
</p>
|
807
|
-
<pre>
|
808
|
-
my_app/
|
809
|
-
my_app/tmp
|
810
|
-
my_app/public
|
811
|
-
</pre>
|
812
|
-
<p>
|
813
|
-
Then put your app in <tt>my_app/</tt> and comment or remove the line with
|
814
|
-
<tt><a href="../classes/Capcode.html#M000011">Capcode.run</a></tt>
|
815
|
-
</p>
|
816
|
-
<p>
|
817
|
-
Create a rack configuration file (<tt>config.ru</tt>) in <tt>my_app/</tt>
|
818
|
-
</p>
|
819
|
-
<pre>
|
820
|
-
require 'app'
|
821
|
-
run Capcode.application()
|
822
|
-
</pre>
|
823
|
-
<p>
|
824
|
-
<tt><a href="../classes/Capcode.html#M000010">Capcode.application</a></tt>
|
825
|
-
take the same parameters as <tt><a
|
826
|
-
href="../classes/Capcode.html#M000011">Capcode.run</a></tt> (and block
|
827
|
-
too). Be carefull, if you use static files (with the static renderer) you
|
828
|
-
must set the <tt>:root</tt> option (<tt>:root =>
|
829
|
-
File.expand_path(File.dirname(<em>FILE</em>))</tt> is probably good)
|
830
|
-
</p>
|
831
|
-
<p>
|
832
|
-
You can now deploy your application like a <a
|
833
|
-
href="http://www.modrails.com/documentation/Users%20guide.html#_deploying_a_rack_based_ruby_application">"Rack-based
|
834
|
-
Ruby application"</a>
|
835
|
-
</p>
|
836
|
-
<h2>REQUIREMENTS:</h2>
|
837
|
-
<ul>
|
838
|
-
<li>rack
|
839
|
-
|
840
|
-
</li>
|
841
|
-
</ul>
|
842
|
-
<h2>INSTALL:</h2>
|
843
|
-
<pre>
|
844
|
-
sudo gem install capcode
|
845
|
-
</pre>
|
846
|
-
<h2>LICENSE:</h2>
|
847
|
-
<p>
|
848
|
-
<a href="../classes/Capcode.html">Capcode</a> is freely distributable
|
849
|
-
according to the terms of the GNU General Public License.
|
850
|
-
</p>
|
851
|
-
<p>
|
852
|
-
This program is distributed without any warranty. See the file
|
853
|
-
‘COPYING’ for details.
|
854
|
-
</p>
|
855
|
-
|
856
|
-
</div>
|
857
|
-
|
858
|
-
|
859
|
-
</div>
|
860
|
-
|
861
|
-
|
862
|
-
</div>
|
863
|
-
|
864
|
-
|
865
|
-
<!-- if includes -->
|
866
|
-
|
867
|
-
<div id="section">
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
<!-- if method_list -->
|
877
|
-
|
878
|
-
|
879
|
-
</div>
|
880
|
-
|
881
|
-
|
882
|
-
<div id="validator-badges">
|
883
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
884
|
-
</div>
|
885
|
-
|
886
|
-
</body>
|
887
|
-
</html>
|