Capcode 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/README.rdoc +58 -0
  2. data/doc/rdoc/classes/Capcode.html +938 -0
  3. data/doc/rdoc/classes/Capcode/Base.html +136 -0
  4. data/doc/rdoc/classes/Capcode/HTTPError.html +134 -0
  5. data/doc/rdoc/classes/Capcode/Helpers.html +608 -0
  6. data/doc/rdoc/classes/Capcode/Helpers/Authorization.html +188 -0
  7. data/doc/rdoc/classes/Capcode/Mab.html +118 -0
  8. data/doc/rdoc/classes/Capcode/Resource.html +111 -0
  9. data/doc/rdoc/classes/Capcode/Views.html +112 -0
  10. data/doc/rdoc/created.rid +1 -0
  11. data/doc/rdoc/files/AUTHORS.html +107 -0
  12. data/doc/rdoc/files/COPYING.html +531 -0
  13. data/doc/rdoc/files/README_rdoc.html +601 -0
  14. data/doc/rdoc/files/lib/capcode/base/db_rb.html +101 -0
  15. data/doc/rdoc/files/lib/capcode/helpers/auth_rb.html +132 -0
  16. data/doc/rdoc/files/lib/capcode/render/erb_rb.html +108 -0
  17. data/doc/rdoc/files/lib/capcode/render/haml_rb.html +108 -0
  18. data/doc/rdoc/files/lib/capcode/render/json_rb.html +108 -0
  19. data/doc/rdoc/files/lib/capcode/render/markaby_rb.html +108 -0
  20. data/doc/rdoc/files/lib/capcode/render/sass_rb.html +108 -0
  21. data/doc/rdoc/files/lib/capcode/render/static_rb.html +101 -0
  22. data/doc/rdoc/files/lib/capcode/render/text_rb.html +101 -0
  23. data/doc/rdoc/files/lib/capcode/render/webdav_rb.html +124 -0
  24. data/doc/rdoc/files/lib/capcode/render/xml_rb.html +101 -0
  25. data/doc/rdoc/files/lib/capcode_rb.html +119 -0
  26. data/doc/rdoc/fr_class_index.html +34 -0
  27. data/doc/rdoc/fr_file_index.html +41 -0
  28. data/doc/rdoc/fr_method_index.html +44 -0
  29. data/doc/rdoc/index.html +24 -0
  30. data/doc/rdoc/rdoc-style.css +208 -0
  31. data/examples/auth-basic.rb +46 -0
  32. data/examples/auth-digest.rb +47 -0
  33. data/examples/auth-webdav.rb +29 -0
  34. data/examples/blog-couchdb-run.rb +10 -0
  35. data/examples/blog-couchdb.rb +8 -8
  36. data/examples/blog-couchdb.ru +12 -0
  37. data/examples/render-static.rb +1 -1
  38. data/examples/render-static.ru +21 -0
  39. data/examples/render-webdav.rb +26 -0
  40. data/examples/rest-run.rb +3 -0
  41. data/examples/rest.rb +1 -1
  42. data/examples/rest.ru +3 -0
  43. data/lib/capcode.rb +196 -100
  44. data/lib/capcode/helpers/auth.rb +130 -0
  45. data/lib/capcode/render/webdav.rb +45 -0
  46. data/lib/capcode/version.rb +1 -1
  47. metadata +45 -3
@@ -0,0 +1,601 @@
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>Thu Oct 08 19:57:54 +0200 2009</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 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.8.5</h3>
95
+ <ul>
96
+ <li><a href="../classes/Capcode.html">Capcode</a> now work with Phusion
97
+ Passenger \o/
98
+
99
+ </li>
100
+ <li>Add WebDAV renderer (need rack_dav) (see examples render-webdav.rb and
101
+ auth-webdav.rb)
102
+
103
+ </li>
104
+ <li>Change default listen host from localhost to 0.0.0.0
105
+
106
+ </li>
107
+ <li>Add require_auth helper for basic or digest HTTP Authentication (see
108
+ examples auth-basic.rb and auth-digest.rb)
109
+
110
+ </li>
111
+ </ul>
112
+ <h3>0.8.4</h3>
113
+ <ul>
114
+ <li>Major (really MAJOR) bugs corrections in renderers
115
+
116
+ </li>
117
+ <li>Add many renderer&#8217; examples
118
+
119
+ </li>
120
+ <li>The static rendere now accept a new option : :exact_path. If :exact_path is
121
+ set to true, the static rendere redirect you to the exact static url of the
122
+ file. Else it just give the content of the file. Default is true. (see
123
+ example render-static.rb)
124
+
125
+ </li>
126
+ <li>redirect now accept an optional HTTP status code as first parameter
127
+
128
+ </li>
129
+ </ul>
130
+ <h3>0.8.3</h3>
131
+ <ul>
132
+ <li>Add PUT and DELETE actions (see rest example)
133
+
134
+ </li>
135
+ </ul>
136
+ <h3>0.8.2</h3>
137
+ <ul>
138
+ <li>Add XML renderer (see rss example)
139
+
140
+ </li>
141
+ <li>Major bug corrections
142
+
143
+ </li>
144
+ <li>Add Helpers.static
145
+
146
+ </li>
147
+ <li>New example : upload.rb
148
+
149
+ </li>
150
+ <li>The database&#8217; configuration file is no more relative to the root
151
+ directory but to the main file
152
+
153
+ </li>
154
+ </ul>
155
+ <h3>0.8.1</h3>
156
+ <ul>
157
+ <li>Sorry for 0.8.0 !!
158
+
159
+ </li>
160
+ </ul>
161
+ <h3>0.8.0</h3>
162
+ <ul>
163
+ <li>Bugs corrections in haml and text renderer
164
+
165
+ </li>
166
+ <li>Text renderer is now automaticaly included
167
+
168
+ </li>
169
+ <li>Add sass renderer
170
+
171
+ </li>
172
+ <li>:working_directory is no more available
173
+
174
+ </li>
175
+ <li>:root is now the real root directory
176
+
177
+ </li>
178
+ <li>Add :static option to set the directory for static files
179
+
180
+ </li>
181
+ <li>Add -r and -s (for root and static directories) options
182
+
183
+ </li>
184
+ <li>Add static renderer
185
+
186
+ </li>
187
+ </ul>
188
+ <h3>0.7.1</h3>
189
+ <ul>
190
+ <li>You need to include <a
191
+ href="../classes/Capcode/Resource.html">Capcode::Resource</a> in your
192
+ models !!!!
193
+
194
+ </li>
195
+ <li>Add option &#8212;version
196
+
197
+ </li>
198
+ </ul>
199
+ <h3>0.7.0</h3>
200
+ <ul>
201
+ <li>You no more need to include <a
202
+ href="../classes/Capcode/Resource.html">Capcode::Resource</a> in your
203
+ models
204
+
205
+ </li>
206
+ <li><a href="../classes/Capcode.html#M000010">Capcode.run</a> now accept a
207
+ block. The content of the block is executed just before the server start.
208
+
209
+ </li>
210
+ <li>Add options support : you can now change the defaults port and host,
211
+ daemonize or not and run in console mode.
212
+
213
+ </li>
214
+ </ul>
215
+ <h3>0.6.2</h3>
216
+ <ul>
217
+ <li>Add Markaby, Erb and Haml layout see Capcode::Helpers.render for more
218
+ informations
219
+
220
+ </li>
221
+ <li>Add content_for&#8230;
222
+
223
+ </li>
224
+ <li>Major bugs corrections
225
+
226
+ </li>
227
+ </ul>
228
+ <h3>0.6.1</h3>
229
+ <ul>
230
+ <li>Major bugs corrections in haml and erb renderer ($%&amp;! Windows)
231
+
232
+ </li>
233
+ <li>Major bugs corrections in Route.call
234
+
235
+ </li>
236
+ <li>Add Markaby layout support
237
+
238
+ </li>
239
+ <li>Rewrite blog-couchdb example (based on the very sympatic camping example :
240
+ <a
241
+ href="http://github.com/judofyr/camping/blob/master/examples/blog.rb">github.com/judofyr/camping/blob/master/examples/blog.rb</a>)
242
+
243
+ </li>
244
+ </ul>
245
+ <h3>0.6.0</h3>
246
+ <ul>
247
+ <li>Add :root option to <a
248
+ href="../classes/Capcode.html#M000010">Capcode.run</a>. This option allow
249
+ you to specify the root directory for static files
250
+
251
+ </li>
252
+ <li>Add :working_directory option to <a
253
+ href="../classes/Capcode.html#M000010">Capcode.run</a>. This option allow
254
+ you to specify the working directory
255
+
256
+ </li>
257
+ <li>If &#8217;/&#8217; route is not defined but /index.html exist, display
258
+ index
259
+
260
+ </li>
261
+ <li>add mime-types dependency
262
+
263
+ </li>
264
+ <li>Bug correction in erb and haml renderer
265
+
266
+ </li>
267
+ </ul>
268
+ <h3>0.5.0</h3>
269
+ <ul>
270
+ <li>Add Haml and Markaby renderer
271
+
272
+ </li>
273
+ <li>json is deprecated and replaced by render( :json =&gt; &#8230; )
274
+
275
+ </li>
276
+ </ul>
277
+ <h3>0.4.0</h3>
278
+ <ul>
279
+ <li>Major bug correction !
280
+
281
+ </li>
282
+ <li>Add views&#8230;
283
+
284
+ </li>
285
+ </ul>
286
+ <h3>0.3.0</h3>
287
+ <ul>
288
+ <li>Work with Rack 1.0.0
289
+
290
+ </li>
291
+ </ul>
292
+ <h3>0.2.0</h3>
293
+ <ul>
294
+ <li>Add models with DataMapper and couch_foo
295
+
296
+ </li>
297
+ <li>Add two new options : :daemonize and :pid
298
+
299
+ </li>
300
+ <li>Bug correction in Route.
301
+
302
+ </li>
303
+ </ul>
304
+ <h3>0.1.0</h3>
305
+ <ul>
306
+ <li>First public release
307
+
308
+ </li>
309
+ <li>No models !!!
310
+
311
+ </li>
312
+ </ul>
313
+ <h2>SYNOPSIS:</h2>
314
+ <pre>
315
+ # file: sample.rb
316
+ require 'rubygems'
317
+ require 'capcode'
318
+
319
+ module Capcode
320
+ class Hello &lt; Route '/hello'
321
+ def get
322
+ &quot;Hello World #{Time.now} !&quot;
323
+ end
324
+ end
325
+ end
326
+
327
+ Capcode.run( )
328
+ </pre>
329
+ <h3>Running <a href="../classes/Capcode.html">Capcode</a> Apps</h3>
330
+ <ul>
331
+ <li>Run: <tt>ruby sample.rb</tt>
332
+
333
+ </li>
334
+ <li>Visit <a href="http://localhost:3000">localhost:3000</a>/
335
+
336
+ </li>
337
+ </ul>
338
+ <h3>Create model</h3>
339
+ <pre>
340
+ require 'rubygems'
341
+ require 'capcode'
342
+ require 'capcode/base/dm' # or require 'capcode/base/couchdb'
343
+
344
+ class Story &lt; Capcode::Base
345
+ include Capcode::Resource
346
+
347
+ property :id, Integer, :serial =&gt; true # only with DataMapper !
348
+ property :title, String
349
+ property :body, String
350
+ property :date, String
351
+ end
352
+ </pre>
353
+ <p>
354
+ See <tt>examples/blog-dm.rb</tt> and/or <tt>examples/blog-couchdb.rb</tt>
355
+ for complete examples.
356
+ </p>
357
+ <h3>Create View</h3>
358
+ <pre>
359
+ # file: sample.rb
360
+ require 'rubygems'
361
+ require 'capcode'
362
+
363
+ module Capcode
364
+ class Hello &lt; Route '/hello'
365
+ def get
366
+ @t = Time.now
367
+ render :time
368
+ end
369
+ end
370
+ end
371
+
372
+ module Capcode::Views
373
+ def time
374
+ &quot;Hello world #{@t}&quot;
375
+ end
376
+ end
377
+
378
+ Capcode.run( )
379
+ </pre>
380
+ <h3>Create Helper</h3>
381
+ <pre>
382
+ # file: sample.rb
383
+ require 'rubygems'
384
+ require 'capcode'
385
+
386
+ module Capcode
387
+ class Hello &lt; Route '/hello'
388
+ def get
389
+ @t = Time.now
390
+ render :time
391
+ end
392
+ end
393
+ end
394
+
395
+ module Capcode::Helpers
396
+ def bold( &amp;b )
397
+ &quot;&lt;b&gt;&quot;+yield+&quot;&lt;/b&gt;&quot;
398
+ end
399
+ end
400
+
401
+ module Capcode::Views
402
+ def time
403
+ &quot;Hello world &quot; + bold { @t }
404
+ end
405
+ end
406
+
407
+ Capcode.run( )
408
+ </pre>
409
+ <h3>Render with Markaby</h3>
410
+ <pre>
411
+ # file: sample.rb
412
+ require 'rubygems'
413
+ require 'capcode'
414
+ require 'capcode/render/markaby'
415
+
416
+ module Capcode
417
+ class Hello &lt; Route '/hello'
418
+ def get
419
+ @t = Time.now
420
+ render :markaby =&gt; :time
421
+ end
422
+ end
423
+ end
424
+
425
+ module Capcode::Views
426
+ def time
427
+ # We use Markaby in Capcode::Views.time
428
+ html do
429
+ body do
430
+ p {
431
+ text &quot;Hello World &quot;
432
+ b @t
433
+ }
434
+ end
435
+ end
436
+ end
437
+ end
438
+
439
+ Capcode.run( )
440
+ </pre>
441
+ <h3>Render with Haml</h3>
442
+ <pre>
443
+ # file: sample.rb
444
+ require 'rubygems'
445
+ require 'capcode'
446
+ require 'capcode/render/haml'
447
+ Capcode::Helpers.haml_path = &quot;./my_haml_views&quot;
448
+
449
+ module Capcode
450
+ class Hello &lt; Route '/hello'
451
+ def get
452
+ @t = Time.now
453
+ render :haml =&gt; :time
454
+ end
455
+ end
456
+ end
457
+
458
+ Capcode.run( )
459
+
460
+ # ./my_haml_views/time.haml
461
+ %html
462
+ %body
463
+ %p
464
+ Hello World
465
+ = @t
466
+ </pre>
467
+ <h3>Render with JSON</h3>
468
+ <pre>
469
+ # file: sample.rb
470
+ require 'rubygems'
471
+ require 'capcode'
472
+ require 'capcode/render/json'
473
+
474
+ module Capcode
475
+ class Hello &lt; Route '/hello'
476
+ def get
477
+ @t = Time.now
478
+ render :json =&gt; { :time =&gt; @t }
479
+ end
480
+ end
481
+ end
482
+
483
+ Capcode.run( )
484
+ </pre>
485
+ <h3>Render with WebDAV</h3>
486
+ <pre>
487
+ # file: sample.rb
488
+ require 'rubygems'
489
+ require 'capcode'
490
+ require 'capcode/render/webdav'
491
+
492
+ module Capcode
493
+
494
+ # !!! Render file from /Users/greg/temp !!!
495
+ class WebDav &lt; Route '/temp'
496
+ def get
497
+ render :webdav =&gt; &quot;/Users/greg&quot;
498
+ end
499
+
500
+ def method_missing(id, *a, &amp;b)
501
+ get
502
+ end
503
+ end
504
+
505
+ class Index &lt; Route '/'
506
+ def get
507
+ render &quot;WebDav server acces : &lt;a href='#{URL(Capcode::WebDav)}'&gt;#{URL(Capcode::WebDav)}&lt;/a&gt;&quot;
508
+ end
509
+ end
510
+
511
+ end
512
+ </pre>
513
+ <p>
514
+ <a href="../classes/Capcode.html#M000010">Capcode.run</a>( )
515
+ </p>
516
+ <h2>DEPLOYMENT</h2>
517
+ <h3>With Passenger</h3>
518
+ <p>
519
+ First create the directory structure :
520
+ </p>
521
+ <pre>
522
+ my_app/
523
+ my_app/tmp
524
+ my_app/public
525
+ </pre>
526
+ <p>
527
+ Then put your app in <tt>my_app/</tt> and comment or remove the line with
528
+ <tt><a href="../classes/Capcode.html#M000010">Capcode.run</a></tt>
529
+ </p>
530
+ <p>
531
+ Create a rack configuration file (<tt>config.ru</tt>) in <tt>my_app/</tt>
532
+ </p>
533
+ <pre>
534
+ require 'app'
535
+ run Capcode.application()
536
+ </pre>
537
+ <p>
538
+ <tt><a href="../classes/Capcode.html#M000009">Capcode.application</a></tt>
539
+ take the same parameters as <tt><a
540
+ href="../classes/Capcode.html#M000010">Capcode.run</a></tt> (and block
541
+ too). Be carefull, if you use static files (with the static renderer) you
542
+ must set the <tt>:root</tt> option (<tt>:root =&gt;
543
+ File.expand_path(File.dirname(<em>FILE</em>))</tt> is probably good)
544
+ </p>
545
+ <p>
546
+ You can now deploy your application like a <a
547
+ href="http://www.modrails.com/documentation/Users%20guide.html#_deploying_a_rack_based_ruby_application">"Rack-based
548
+ Ruby application"</a>
549
+ </p>
550
+ <h2>REQUIREMENTS:</h2>
551
+ <ul>
552
+ <li>rack
553
+
554
+ </li>
555
+ </ul>
556
+ <h2>INSTALL:</h2>
557
+ <pre>
558
+ sudo gem install capcode
559
+ </pre>
560
+ <h2>LICENSE:</h2>
561
+ <p>
562
+ <a href="../classes/Capcode.html">Capcode</a> is freely distributable
563
+ according to the terms of the GNU General Public License.
564
+ </p>
565
+ <p>
566
+ This program is distributed without any warranty. See the file
567
+ &#8216;COPYING&#8217; for details.
568
+ </p>
569
+
570
+ </div>
571
+
572
+
573
+ </div>
574
+
575
+
576
+ </div>
577
+
578
+
579
+ <!-- if includes -->
580
+
581
+ <div id="section">
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+ <!-- if method_list -->
591
+
592
+
593
+ </div>
594
+
595
+
596
+ <div id="validator-badges">
597
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
598
+ </div>
599
+
600
+ </body>
601
+ </html>