Capcode 0.8.2 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/{README → README.rdoc} +12 -1
- data/examples/haml/cf_layout.haml +1 -0
- data/examples/haml/style.sass +2 -0
- data/examples/render-erb.rb +14 -0
- data/examples/render-haml_sass.rb +22 -0
- data/examples/render-json.rb +13 -0
- data/examples/render-markaby.rb +27 -0
- data/examples/render-static.rb +18 -0
- data/examples/render-text.rb +12 -0
- data/examples/render-xml.rb +24 -0
- data/examples/rest.rb +77 -0
- data/examples/upload.rb +4 -4
- data/lib/capcode.rb +118 -44
- data/lib/capcode/base/db.rb +23 -0
- data/lib/capcode/base/dm.rb +11 -11
- data/lib/capcode/render/erb.rb +5 -3
- data/lib/capcode/render/haml.rb +3 -2
- data/lib/capcode/render/json.rb +1 -1
- data/lib/capcode/render/markaby.rb +5 -5
- data/lib/capcode/render/sass.rb +4 -2
- data/lib/capcode/render/static.rb +6 -2
- data/lib/capcode/render/text.rb +1 -1
- data/lib/capcode/render/xml.rb +3 -5
- data/lib/capcode/version.rb +1 -1
- metadata +25 -55
- data/doc/rdoc/classes/Capcode.html +0 -605
- data/doc/rdoc/classes/Capcode/HTTPError.html +0 -129
- data/doc/rdoc/classes/Capcode/Helpers.html +0 -342
- data/doc/rdoc/classes/Capcode/RenderError.html +0 -129
- data/doc/rdoc/classes/Capcode/Views.html +0 -108
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/AUTHORS.html +0 -103
- data/doc/rdoc/files/COPYING.html +0 -527
- data/doc/rdoc/files/README.html +0 -478
- data/doc/rdoc/files/lib/capcode_rb.html +0 -541
- data/doc/rdoc/index.html +0 -10
- data/doc/rdoc/permalink.gif +0 -0
- data/doc/rdoc/rdoc-style.css +0 -106
- data/doc/rdoc/rubyfr.png +0 -0
- data/doc/rdoc_iphone/classes/Capcode.html +0 -175
- data/doc/rdoc_iphone/classes/Capcode/HTTPError.html +0 -21
- data/doc/rdoc_iphone/classes/Capcode/Helpers.html +0 -153
- data/doc/rdoc_iphone/classes/Capcode/RenderError.html +0 -21
- data/doc/rdoc_iphone/classes/Capcode/Views.html +0 -21
- data/doc/rdoc_iphone/classes_index.html +0 -10
- data/doc/rdoc_iphone/created.rid +0 -1
- data/doc/rdoc_iphone/files/AUTHORS.html +0 -11
- data/doc/rdoc_iphone/files/COPYING.html +0 -435
- data/doc/rdoc_iphone/files/README.html +0 -325
- data/doc/rdoc_iphone/files/lib/capcode_rb.html +0 -435
- data/doc/rdoc_iphone/files_index.html +0 -7
- data/doc/rdoc_iphone/index.html +0 -51
- data/doc/rdoc_iphone/iui/backButton.png +0 -0
- data/doc/rdoc_iphone/iui/blueButton.png +0 -0
- data/doc/rdoc_iphone/iui/cancel.png +0 -0
- data/doc/rdoc_iphone/iui/grayButton.png +0 -0
- data/doc/rdoc_iphone/iui/iui-logo-touch-icon.png +0 -0
- data/doc/rdoc_iphone/iui/iui.css +0 -386
- data/doc/rdoc_iphone/iui/iui.js +0 -442
- data/doc/rdoc_iphone/iui/iuix.css +0 -1
- data/doc/rdoc_iphone/iui/iuix.js +0 -1
- data/doc/rdoc_iphone/iui/listArrow.png +0 -0
- data/doc/rdoc_iphone/iui/listArrowSel.png +0 -0
- data/doc/rdoc_iphone/iui/listGroup.png +0 -0
- data/doc/rdoc_iphone/iui/loading.gif +0 -0
- data/doc/rdoc_iphone/iui/pinstripes.png +0 -0
- data/doc/rdoc_iphone/iui/selection.png +0 -0
- data/doc/rdoc_iphone/iui/thumb.png +0 -0
- data/doc/rdoc_iphone/iui/toggle.png +0 -0
- data/doc/rdoc_iphone/iui/toggleOn.png +0 -0
- data/doc/rdoc_iphone/iui/toolButton.png +0 -0
- data/doc/rdoc_iphone/iui/toolbar.png +0 -0
- data/doc/rdoc_iphone/iui/whiteButton.png +0 -0
- data/doc/rdoc_iphone/rdoc-style.css +0 -0
data/doc/rdoc/files/README.html
DELETED
@@ -1,478 +0,0 @@
|
|
1
|
-
|
2
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<title>
|
6
|
-
Capcode, the Documentation » File: README
|
7
|
-
</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
<script language="JavaScript" type="text/javascript">
|
11
|
-
// <![CDATA[
|
12
|
-
|
13
|
-
function toggleSource( id )
|
14
|
-
{
|
15
|
-
var elem
|
16
|
-
var link
|
17
|
-
|
18
|
-
if( document.getElementById )
|
19
|
-
{
|
20
|
-
elem = document.getElementById( id )
|
21
|
-
link = document.getElementById( "l_" + id )
|
22
|
-
}
|
23
|
-
else if ( document.all )
|
24
|
-
{
|
25
|
-
elem = eval( "document.all." + id )
|
26
|
-
link = eval( "document.all.l_" + id )
|
27
|
-
}
|
28
|
-
else
|
29
|
-
return false;
|
30
|
-
|
31
|
-
if( elem.style.display == "block" )
|
32
|
-
{
|
33
|
-
elem.style.display = "none"
|
34
|
-
link.innerHTML = "show source"
|
35
|
-
}
|
36
|
-
else
|
37
|
-
{
|
38
|
-
elem.style.display = "block"
|
39
|
-
link.innerHTML = "hide source"
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
function openCode( url )
|
44
|
-
{
|
45
|
-
window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
|
46
|
-
}
|
47
|
-
// ]]>
|
48
|
-
</script>
|
49
|
-
</head>
|
50
|
-
<body>
|
51
|
-
<!--
|
52
|
-
<div id="menu">
|
53
|
-
<h3 class="title">File: README</h3>
|
54
|
-
</div>
|
55
|
-
-->
|
56
|
-
<div id="fullpage">
|
57
|
-
<div id="pager">
|
58
|
-
<table>
|
59
|
-
<tr><td><img src="../rubyfr.png" /></td>
|
60
|
-
<td id="pagertd">
|
61
|
-
<strong># File: README<br />
|
62
|
-
[
|
63
|
-
"<a href="../files/README.html" value="File: README">README</a>",
|
64
|
-
"<a href="../files/AUTHORS.html" value="File: AUTHORS">AUTHORS</a>",
|
65
|
-
"<a href="../files/COPYING.html" value="File: COPYING">COPYING</a>",
|
66
|
-
"<a href="../files/lib/capcode_rb.html" value="File: capcode.rb">lib/capcode.rb</a>",
|
67
|
-
<a href="http://greg.rubyfr.net">nil</a>].each do<br />
|
68
|
-
<a href="../classes/Capcode.html" title="Module: Capcode">Capcode</a>.view_html<br />
|
69
|
-
<a href="../classes/Capcode/Views.html" title="Module: Capcode::Views">Capcode::Views</a>.view_html<br />
|
70
|
-
<a href="../classes/Capcode/Helpers.html" title="Module: Capcode::Helpers">Capcode::Helpers</a>.view_html<br />
|
71
|
-
<a href="../classes/Capcode/HTTPError.html" title="Class: Capcode::HTTPError">Capcode::HTTPError</a>.view_html<br />
|
72
|
-
<a href="../classes/Capcode/RenderError.html" title="Class: Capcode::RenderError">Capcode::RenderError</a>.view_html<br />
|
73
|
-
<a href="../classes/Capcode/RouteError.html" title="Class: Capcode::RouteError">Capcode::RouteError</a>.view_html<br />
|
74
|
-
<a href="../classes/Capcode/ParameterError.html" title="Class: Capcode::ParameterError">Capcode::ParameterError</a>.view_html<br />
|
75
|
-
end</strong>
|
76
|
-
</td></tr>
|
77
|
-
</table>
|
78
|
-
</ul>
|
79
|
-
</div>
|
80
|
-
|
81
|
-
<div id="README" class="page_shade">
|
82
|
-
<div class="page">
|
83
|
-
<div class="header">
|
84
|
-
<div class="path">README / Fri Jul 17 18:22:38 +0200 2009</div>
|
85
|
-
</div>
|
86
|
-
|
87
|
-
<h1><a href="../classes/Capcode.html">Capcode</a></h1>
|
88
|
-
<p>
|
89
|
-
Copyright (C) 2009 Gregoire Lejeune
|
90
|
-
</p>
|
91
|
-
<ul>
|
92
|
-
<li><a href="http://capcode.rubyforge.org">capcode.rubyforge.org</a>
|
93
|
-
|
94
|
-
</li>
|
95
|
-
</ul>
|
96
|
-
<h2>DESCRIPTION:</h2>
|
97
|
-
<p>
|
98
|
-
<a href="../classes/Capcode.html">Capcode</a> is a web microframework
|
99
|
-
</p>
|
100
|
-
<h2>FEATURES/PROBLEMS:</h2>
|
101
|
-
<h3>0.8.2</h3>
|
102
|
-
<ul>
|
103
|
-
<li>Add XML renderer (see rss example)
|
104
|
-
|
105
|
-
</li>
|
106
|
-
<li>Major bug corrections
|
107
|
-
|
108
|
-
</li>
|
109
|
-
<li>Add Helpers.static
|
110
|
-
|
111
|
-
</li>
|
112
|
-
<li>New example : upload.rb
|
113
|
-
|
114
|
-
</li>
|
115
|
-
<li>The database’ configuration file is no more relative to the root
|
116
|
-
directory but to the main file
|
117
|
-
|
118
|
-
</li>
|
119
|
-
</ul>
|
120
|
-
<h3>0.8.1</h3>
|
121
|
-
<ul>
|
122
|
-
<li>Sorry for 0.8.0 !!
|
123
|
-
|
124
|
-
</li>
|
125
|
-
</ul>
|
126
|
-
<h3>0.8.0</h3>
|
127
|
-
<ul>
|
128
|
-
<li>Bugs corrections in haml and text renderer
|
129
|
-
|
130
|
-
</li>
|
131
|
-
<li>Text renderer is now automaticaly included
|
132
|
-
|
133
|
-
</li>
|
134
|
-
<li>Add sass renderer
|
135
|
-
|
136
|
-
</li>
|
137
|
-
<li>:working_directory is no more available
|
138
|
-
|
139
|
-
</li>
|
140
|
-
<li>:root is now the real root directory
|
141
|
-
|
142
|
-
</li>
|
143
|
-
<li>Add :static option to set the directory for static files
|
144
|
-
|
145
|
-
</li>
|
146
|
-
<li>Add -r and -s (for root and static directories) options
|
147
|
-
|
148
|
-
</li>
|
149
|
-
<li>Add static renderer
|
150
|
-
|
151
|
-
</li>
|
152
|
-
</ul>
|
153
|
-
<h3>0.7.1</h3>
|
154
|
-
<ul>
|
155
|
-
<li>You need to include Capcode::Resource in your models !!!!
|
156
|
-
|
157
|
-
</li>
|
158
|
-
<li>Add option —version
|
159
|
-
|
160
|
-
</li>
|
161
|
-
</ul>
|
162
|
-
<h3>0.7.0</h3>
|
163
|
-
<ul>
|
164
|
-
<li>You no more need to include Capcode::Resource in your models
|
165
|
-
|
166
|
-
</li>
|
167
|
-
<li><a href="../classes/Capcode.html#M000008">Capcode.run</a> now accept a
|
168
|
-
block. The content of the block is executed just before the server start.
|
169
|
-
|
170
|
-
</li>
|
171
|
-
<li>Add options support : you can now change the defaults port and host,
|
172
|
-
daemonize or not and run in console mode.
|
173
|
-
|
174
|
-
</li>
|
175
|
-
</ul>
|
176
|
-
<h3>0.6.2</h3>
|
177
|
-
<ul>
|
178
|
-
<li>Add Markaby, Erb and Haml layout see Capcode::Helpers.render for more
|
179
|
-
informations
|
180
|
-
|
181
|
-
</li>
|
182
|
-
<li>Add content_for…
|
183
|
-
|
184
|
-
</li>
|
185
|
-
<li>Major bugs corrections
|
186
|
-
|
187
|
-
</li>
|
188
|
-
</ul>
|
189
|
-
<h3>0.6.1</h3>
|
190
|
-
<ul>
|
191
|
-
<li>Major bugs corrections in haml and erb renderer ($%&! Windows)
|
192
|
-
|
193
|
-
</li>
|
194
|
-
<li>Major bugs corrections in Route.call
|
195
|
-
|
196
|
-
</li>
|
197
|
-
<li>Add Markaby layout support
|
198
|
-
|
199
|
-
</li>
|
200
|
-
<li>Rewrite blog-couchdb example (based on the very sympatic camping example :
|
201
|
-
<a
|
202
|
-
href="http://github.com/judofyr/camping/blob/master/examples/blog.rb">github.com/judofyr/camping/blob/master/examples/blog.rb</a>)
|
203
|
-
|
204
|
-
</li>
|
205
|
-
</ul>
|
206
|
-
<h3>0.6.0</h3>
|
207
|
-
<ul>
|
208
|
-
<li>Add :root option to <a
|
209
|
-
href="../classes/Capcode.html#M000008">Capcode.run</a>. This option allow
|
210
|
-
you to specify the root directory for static files
|
211
|
-
|
212
|
-
</li>
|
213
|
-
<li>Add :working_directory option to <a
|
214
|
-
href="../classes/Capcode.html#M000008">Capcode.run</a>. This option allow
|
215
|
-
you to specify the working directory
|
216
|
-
|
217
|
-
</li>
|
218
|
-
<li>If ’/’ route is not defined but /index.html exist, display
|
219
|
-
index
|
220
|
-
|
221
|
-
</li>
|
222
|
-
<li>add mime-types dependency
|
223
|
-
|
224
|
-
</li>
|
225
|
-
<li>Bug correction in erb and haml renderer
|
226
|
-
|
227
|
-
</li>
|
228
|
-
</ul>
|
229
|
-
<h3>0.5.0</h3>
|
230
|
-
<ul>
|
231
|
-
<li>Add Haml and Markaby renderer
|
232
|
-
|
233
|
-
</li>
|
234
|
-
<li>json is deprecated and replaced by render( :json => … )
|
235
|
-
|
236
|
-
</li>
|
237
|
-
</ul>
|
238
|
-
<h3>0.4.0</h3>
|
239
|
-
<ul>
|
240
|
-
<li>Major bug correction !
|
241
|
-
|
242
|
-
</li>
|
243
|
-
<li>Add views…
|
244
|
-
|
245
|
-
</li>
|
246
|
-
</ul>
|
247
|
-
<h3>0.3.0</h3>
|
248
|
-
<ul>
|
249
|
-
<li>Work with Rack 1.0.0
|
250
|
-
|
251
|
-
</li>
|
252
|
-
</ul>
|
253
|
-
<h3>0.2.0</h3>
|
254
|
-
<ul>
|
255
|
-
<li>Add models with DataMapper and couch_foo
|
256
|
-
|
257
|
-
</li>
|
258
|
-
<li>Add two new options : :daemonize and :pid
|
259
|
-
|
260
|
-
</li>
|
261
|
-
<li>Bug correction in Route.
|
262
|
-
|
263
|
-
</li>
|
264
|
-
</ul>
|
265
|
-
<h3>0.1.0</h3>
|
266
|
-
<ul>
|
267
|
-
<li>First public release
|
268
|
-
|
269
|
-
</li>
|
270
|
-
<li>No models !!!
|
271
|
-
|
272
|
-
</li>
|
273
|
-
</ul>
|
274
|
-
<h2>SYNOPSIS:</h2>
|
275
|
-
<pre>
|
276
|
-
# file: sample.rb
|
277
|
-
require 'rubygems'
|
278
|
-
require 'capcode'
|
279
|
-
|
280
|
-
module Capcode
|
281
|
-
class Hello < Route '/hello'
|
282
|
-
def get
|
283
|
-
"Hello World #{Time.now} !"
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
Capcode.run( )
|
289
|
-
</pre>
|
290
|
-
<h3>Running <a href="../classes/Capcode.html">Capcode</a> Apps</h3>
|
291
|
-
<ul>
|
292
|
-
<li>Run: <tt>ruby sample.rb</tt>
|
293
|
-
|
294
|
-
</li>
|
295
|
-
<li>Visit <a href="http://localhost:3000">localhost:3000</a>/
|
296
|
-
|
297
|
-
</li>
|
298
|
-
</ul>
|
299
|
-
<h3>Create model</h3>
|
300
|
-
<pre>
|
301
|
-
require 'rubygems'
|
302
|
-
require 'capcode'
|
303
|
-
require 'capcode/base/dm' # or require 'capcode/base/couchdb'
|
304
|
-
|
305
|
-
class Story < Capcode::Base
|
306
|
-
include Capcode::Resource
|
307
|
-
|
308
|
-
property :id, Integer, :serial => true # only with DataMapper !
|
309
|
-
property :title, String
|
310
|
-
property :body, String
|
311
|
-
property :date, String
|
312
|
-
end
|
313
|
-
</pre>
|
314
|
-
<p>
|
315
|
-
See <tt>examples/blog-dm.rb</tt> and/or <tt>examples/blog-couchdb.rb</tt>
|
316
|
-
for complete examples.
|
317
|
-
</p>
|
318
|
-
<h3>Create View</h3>
|
319
|
-
<pre>
|
320
|
-
# file: sample.rb
|
321
|
-
require 'rubygems'
|
322
|
-
require 'capcode'
|
323
|
-
|
324
|
-
module Capcode
|
325
|
-
class Hello < Route '/hello'
|
326
|
-
def get
|
327
|
-
@t = Time.now
|
328
|
-
render :time
|
329
|
-
end
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
module Capcode::Views
|
334
|
-
def time
|
335
|
-
"Hello world #{@t}"
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
Capcode.run( )
|
340
|
-
</pre>
|
341
|
-
<h3>Create Helper</h3>
|
342
|
-
<pre>
|
343
|
-
# file: sample.rb
|
344
|
-
require 'rubygems'
|
345
|
-
require 'capcode'
|
346
|
-
|
347
|
-
module Capcode
|
348
|
-
class Hello < Route '/hello'
|
349
|
-
def get
|
350
|
-
@t = Time.now
|
351
|
-
render :time
|
352
|
-
end
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
module Capcode::Helpers
|
357
|
-
def bold( &b )
|
358
|
-
"<b>"+yield+"</b>"
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
module Capcode::Views
|
363
|
-
def time
|
364
|
-
"Hello world " + bold { @t }
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
Capcode.run( )
|
369
|
-
</pre>
|
370
|
-
<h3>Render with Markaby</h3>
|
371
|
-
<pre>
|
372
|
-
# file: sample.rb
|
373
|
-
require 'rubygems'
|
374
|
-
require 'capcode'
|
375
|
-
require 'capcode/render/markaby'
|
376
|
-
|
377
|
-
module Capcode
|
378
|
-
class Hello < Route '/hello'
|
379
|
-
def get
|
380
|
-
@t = Time.now
|
381
|
-
render :markaby => :time
|
382
|
-
end
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
module Capcode::Views
|
387
|
-
def time
|
388
|
-
# We use Markaby in Capcode::Views.time
|
389
|
-
html do
|
390
|
-
body do
|
391
|
-
p {
|
392
|
-
text "Hello World "
|
393
|
-
b @t
|
394
|
-
}
|
395
|
-
end
|
396
|
-
end
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
Capcode.run( )
|
401
|
-
</pre>
|
402
|
-
<h3>Render with Haml</h3>
|
403
|
-
<pre>
|
404
|
-
# file: sample.rb
|
405
|
-
require 'rubygems'
|
406
|
-
require 'capcode'
|
407
|
-
require 'capcode/render/haml'
|
408
|
-
Capcode::Helpers.haml_path = "./my_haml_views"
|
409
|
-
|
410
|
-
module Capcode
|
411
|
-
class Hello < Route '/hello'
|
412
|
-
def get
|
413
|
-
@t = Time.now
|
414
|
-
render :haml => :time
|
415
|
-
end
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
419
|
-
Capcode.run( )
|
420
|
-
|
421
|
-
# ./my_haml_views/time.haml
|
422
|
-
%html
|
423
|
-
%body
|
424
|
-
%p
|
425
|
-
Hello World
|
426
|
-
= @t
|
427
|
-
</pre>
|
428
|
-
<h3>Render with JSON</h3>
|
429
|
-
<pre>
|
430
|
-
# file: sample.rb
|
431
|
-
require 'rubygems'
|
432
|
-
require 'capcode'
|
433
|
-
require 'capcode/render/json'
|
434
|
-
|
435
|
-
module Capcode
|
436
|
-
class Hello < Route '/hello'
|
437
|
-
def get
|
438
|
-
@t = Time.now
|
439
|
-
render :json => { :time => @t }
|
440
|
-
end
|
441
|
-
end
|
442
|
-
end
|
443
|
-
|
444
|
-
Capcode.run( )
|
445
|
-
</pre>
|
446
|
-
<h2>REQUIREMENTS:</h2>
|
447
|
-
<ul>
|
448
|
-
<li>rack
|
449
|
-
|
450
|
-
</li>
|
451
|
-
</ul>
|
452
|
-
<h2>INSTALL:</h2>
|
453
|
-
<pre>
|
454
|
-
sudo gem install capcode
|
455
|
-
</pre>
|
456
|
-
<h2>LICENSE:</h2>
|
457
|
-
<p>
|
458
|
-
<a href="../classes/Capcode.html">Capcode</a> is freely distributable
|
459
|
-
according to the terms of the GNU General Public License.
|
460
|
-
</p>
|
461
|
-
<p>
|
462
|
-
This program is distributed without any warranty. See the file
|
463
|
-
‘COPYING’ for details.
|
464
|
-
</p>
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
</div>
|
473
|
-
</div>
|
474
|
-
|
475
|
-
|
476
|
-
</div>
|
477
|
-
</body>
|
478
|
-
</html>
|