Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 828 lines (562 sloc) 20.754 kb
df800b5 Docs are started
Blake Mizerany authored
1 = Sinatra
2
4c91e54 @watchdogtimer Web applications should not be hyphenated
watchdogtimer authored
3 Sinatra is a DSL for quickly creating web applications in Ruby with minimal
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
4 effort:
df800b5 Docs are started
Blake Mizerany authored
5
6 # myapp.rb
7 require 'sinatra'
c37db5c @rkh minor adjustments and fixes for the readme examples
rkh authored
8
df800b5 Docs are started
Blake Mizerany authored
9 get '/' do
10 'Hello world!'
11 end
12
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
13 Install the gem and run with:
df800b5 Docs are started
Blake Mizerany authored
14
8465d49 @rkh Avoid `require "rubygems"` and `sudo` in README.
rkh authored
15 gem install sinatra
16 ruby -rubygems myapp.rb
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
17
18 View at: http://localhost:4567
19
20 == Routes
21
22 In Sinatra, a route is an HTTP method paired with an URL matching pattern.
23 Each route is associated with a block:
df800b5 Docs are started
Blake Mizerany authored
24
25 get '/' do
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
26 .. show something ..
df800b5 Docs are started
Blake Mizerany authored
27 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
28
df800b5 Docs are started
Blake Mizerany authored
29 post '/' do
30 .. create something ..
31 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
32
df800b5 Docs are started
Blake Mizerany authored
33 put '/' do
34 .. update something ..
35 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
36
df800b5 Docs are started
Blake Mizerany authored
37 delete '/' do
38 .. annihilate something ..
39 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
40
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
41 Routes are matched in the order they are defined. The first route that
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
42 matches the request is invoked.
1776a80 Added Version and Docs
Blake Mizerany authored
43
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
44 Route patterns may include named parameters, accessible via the
45 <tt>params</tt> hash:
1776a80 Added Version and Docs
Blake Mizerany authored
46
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
47 get '/hello/:name' do
ce0fe87 @scottj97 fix inaccurate comment in README
scottj97 authored
48 # matches "GET /hello/foo" and "GET /hello/bar"
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
49 # params[:name] is 'foo' or 'bar'
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
50 "Hello #{params[:name]}!"
1776a80 Added Version and Docs
Blake Mizerany authored
51 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
52
6569d1b @bdimcheff Added route block params in routing statements [#140]
bdimcheff authored
53 You can also access named parameters via block parameters:
54
55 get '/hello/:name' do |n|
56 "Hello #{n}!"
57 end
58
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
59 Route patterns may also include splat (or wildcard) parameters, accessible
60 via the <tt>params[:splat]</tt> array.
1776a80 Added Version and Docs
Blake Mizerany authored
61
9c85e99 @vic Specs, documentation and fixes for splat'n routes
vic authored
62 get '/say/*/to/*' do
63 # matches /say/hello/to/world
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
64 params[:splat] # => ["hello", "world"]
9c85e99 @vic Specs, documentation and fixes for splat'n routes
vic authored
65 end
66
67 get '/download/*.*' do
68 # matches /download/path/to/file.xml
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
69 params[:splat] # => ["path/to/file", "xml"]
1776a80 Added Version and Docs
Blake Mizerany authored
70 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
71
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
72 Route matching with Regular Expressions:
73
74 get %r{/hello/([\w]+)} do
75 "Hello, #{params[:captures].first}!"
76 end
77
6569d1b @bdimcheff Added route block params in routing statements [#140]
bdimcheff authored
78 Or with a block parameter:
79
80 get %r{/hello/([\w]+)} do |c|
81 "Hello, #{c}!"
82 end
83
726feeb @rkh Documentation for condition. Fixes GH #15.
rkh authored
84 === Conditions
85
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
86 Routes may include a variety of matching conditions, such as the user agent:
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
87
1776a80 Added Version and Docs
Blake Mizerany authored
88 get '/foo', :agent => /Songbird (\d\.\d)[\d\/]*?/ do
89 "You're using Songbird version #{params[:agent][0]}"
90 end
91
92 get '/foo' do
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
93 # Matches non-songbird browsers
1776a80 Added Version and Docs
Blake Mizerany authored
94 end
df800b5 Docs are started
Blake Mizerany authored
95
fa52709 @rkh fix markup for inline code in README
rkh authored
96 Other available conditions are +host_name+ and +provides+:
726feeb @rkh Documentation for condition. Fixes GH #15.
rkh authored
97
98 get '/', :host_name => /^admin\./ do
99 "Admin Area, Access denied!"
100 end
101
102 get '/', :provides => 'html' do
103 haml :index
104 end
105
106 get '/', :provides => ['rss', 'atom', 'xml'] do
107 builder :feed
108 end
109
110 You can easily define your own conditions:
111
112 set(:probability) { |value| condition { rand <= value } }
113
114 get '/win_a_car', :probability => 0.1 do
115 "You won!"
116 end
117
118 get '/win_a_car' do
119 "Sorry, you lost."
120 end
121
aaeb564 @rkh document route return values, fixes GH #23
rkh authored
122 === Return values
123
124 The return value of a route block determines at least the response body passed
125 on to the HTTP client, or at least the next middleware in the Rack stack.
126 Most commonly this is a string, as in the above examples. But other values are
127 also accepted.
128
c6d0614 @rkh Minor README improvements.
rkh authored
129 You can return any object that would either be a valid Rack response, Rack
130 body object or HTTP status code:
aaeb564 @rkh document route return values, fixes GH #23
rkh authored
131
626f689 @rkh fix markup for multi word inline code in README
rkh authored
132 * An Array with three elements: <tt>[status (Fixnum), headers (Hash), response body (responds to #each)]</tt>
133 * An Array with two elements: <tt>[status (Fixnum), response body (responds to #each)]</tt>
9c73cf7 @rkh fix markup for multi word inline code in README, take two (apparently # ...
rkh authored
134 * An object that responds to <tt>#each</tt> and passes nothing but strings to the given block
aaeb564 @rkh document route return values, fixes GH #23
rkh authored
135 * A Fixnum representing the status code
136
137 That way we can for instance easily implement a streaming example:
138
139 class Stream
140 def each
141 100.times { |i| yield "#{i}\n" }
142 end
143 end
144
8fbd9c2 @rkh Simplify streaming example.
rkh authored
145 get('/') { Stream.new }
aaeb564 @rkh document route return values, fixes GH #23
rkh authored
146
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
147 == Static Files
047edc6 update README with Static help
Blake Mizerany authored
148
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
149 Static files are served from the <tt>./public</tt> directory. You can specify
150 a different location by setting the <tt>:public</tt> option:
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
151
152 set :public, File.dirname(__FILE__) + '/static'
df800b5 Docs are started
Blake Mizerany authored
153
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
154 Note that the public directory name is not included in the URL. A file
85b4462 @rtomayko README: fix formatting on static file note
rtomayko authored
155 <tt>./public/css/style.css</tt> is made available as
156 <tt>http://example.com/css/style.css</tt>.
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
157
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
158 == Views / Templates
df800b5 Docs are started
Blake Mizerany authored
159
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
160 Templates are assumed to be located directly under the <tt>./views</tt>
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
161 directory. To use a different views directory:
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
162
163 set :views, File.dirname(__FILE__) + '/templates'
164
06161bf @cypher Note on passing template symbols vs. strings in README
cypher authored
165 One important thing to remember is that you always have to reference
166 templates with symbols, even if they're in a subdirectory (in this
167 case use <tt>:'subdir/template'</tt>). Rendering methods will render
168 any strings passed to them directly.
169
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
170 === Haml Templates
df800b5 Docs are started
Blake Mizerany authored
171
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
172 The haml gem/library is required to render HAML templates:
173
801163e @bmizerany closes #9779 Auto-require haml/erb/builder/sass
bmizerany authored
174 ## You'll need to require haml in your app
175 require 'haml'
176
df800b5 Docs are started
Blake Mizerany authored
177 get '/' do
178 haml :index
179 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
180
181 Renders <tt>./views/index.haml</tt>.
182
0321ada @dougireton In README docs, fix links to HAML and SASS Options pages.
dougireton authored
183 {Haml's options}[http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#options]
d359dc9 @kematzy Merge app-level haml/sass options with call options [#184]
kematzy authored
184 can be set globally through Sinatra's configurations,
185 see {Options and Configurations}[http://www.sinatrarb.com/configuration.html],
186 and overridden on an individual basis.
187
c37db5c @rkh minor adjustments and fixes for the readme examples
rkh authored
188 set :haml, :format => :html5 # default Haml format is :xhtml
d359dc9 @kematzy Merge app-level haml/sass options with call options [#184]
kematzy authored
189
190 get '/' do
c37db5c @rkh minor adjustments and fixes for the readme examples
rkh authored
191 haml :index, :format => :html4 # overridden
d359dc9 @kematzy Merge app-level haml/sass options with call options [#184]
kematzy authored
192 end
193
194
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
195 === Erb Templates
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
196
801163e @bmizerany closes #9779 Auto-require haml/erb/builder/sass
bmizerany authored
197 ## You'll need to require erb in your app
198 require 'erb'
199
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
200 get '/' do
201 erb :index
202 end
203
204 Renders <tt>./views/index.erb</tt>
205
7c5d693 @sr Doc for erubis
sr authored
206 === Erubis
207
84f2e0c @jstewart Correction to erubis template rendering instructions
jstewart authored
208 The erubis gem/library is required to render erubis templates:
7c5d693 @sr Doc for erubis
sr authored
209
210 ## You'll need to require erubis in your app
211 require 'erubis'
212
213 get '/' do
214 erubis :index
215 end
216
217 Renders <tt>./views/index.erubis</tt>
218
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
219 === Builder Templates
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
220
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
221 The builder gem/library is required to render builder templates:
df800b5 Docs are started
Blake Mizerany authored
222
801163e @bmizerany closes #9779 Auto-require haml/erb/builder/sass
bmizerany authored
223 ## You'll need to require builder in your app
224 require 'builder'
225
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
226 get '/' do
227 content_type 'application/xml', :charset => 'utf-8'
228 builder :index
229 end
230
231 Renders <tt>./views/index.builder</tt>.
232
233 === Sass Templates
234
235 The sass gem/library is required to render Sass templates:
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
236
801163e @bmizerany closes #9779 Auto-require haml/erb/builder/sass
bmizerany authored
237 ## You'll need to require haml or sass in your app
238 require 'sass'
239
4144ac1 @nmeans Added Sass information to documentation.
nmeans authored
240 get '/stylesheet.css' do
ccc19b0 @rtomayko content_type response helper with mime type lookup and parameter support...
rtomayko authored
241 content_type 'text/css', :charset => 'utf-8'
4144ac1 @nmeans Added Sass information to documentation.
nmeans authored
242 sass :stylesheet
243 end
244
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
245 Renders <tt>./views/stylesheet.sass</tt>.
246
0321ada @dougireton In README docs, fix links to HAML and SASS Options pages.
dougireton authored
247 {Sass' options}[http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#options]
d359dc9 @kematzy Merge app-level haml/sass options with call options [#184]
kematzy authored
248 can be set globally through Sinatra's configurations,
249 see {Options and Configurations}[http://www.sinatrarb.com/configuration.html],
250 and overridden on an individual basis.
251
c37db5c @rkh minor adjustments and fixes for the readme examples
rkh authored
252 set :sass, :style => :compact # default Sass style is :nested
d359dc9 @kematzy Merge app-level haml/sass options with call options [#184]
kematzy authored
253
254 get '/stylesheet.css' do
255 content_type 'text/css', :charset => 'utf-8'
b90d00c @sr Update sass example re. options
sr authored
256 sass :stylesheet, :style => :expanded # overridden
d359dc9 @kematzy Merge app-level haml/sass options with call options [#184]
kematzy authored
257 end
258
cf3c218 @pedromenezes Adding scss support through specific command
pedromenezes authored
259 === Scss Templates
260
261 The sass gem/library is required to render Scss templates:
262
263 ## You'll need to require haml or sass in your app
264 require 'sass'
265
266 get '/stylesheet.css' do
267 content_type 'text/css', :charset => 'utf-8'
268 scss :stylesheet
269 end
270
271 Renders <tt>./views/stylesheet.scss</tt>.
272
273 {Scss' options}[http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#options]
274 can be set globally through Sinatra's configurations,
275 see {Options and Configurations}[http://www.sinatrarb.com/configuration.html],
276 and overridden on an individual basis.
277
c37db5c @rkh minor adjustments and fixes for the readme examples
rkh authored
278 set :scss, :style => :compact # default Scss style is :nested
cf3c218 @pedromenezes Adding scss support through specific command
pedromenezes authored
279
280 get '/stylesheet.css' do
281 content_type 'text/css', :charset => 'utf-8'
282 scss :stylesheet, :style => :expanded # overridden
283 end
284
621bfcb @Ptico Added Less support
Ptico authored
285 === Less Templates
286
287 The less gem/library is required to render Less templates:
288
289 ## You'll need to require less in your app
290 require 'less'
291
292 get '/stylesheet.css' do
293 content_type 'text/css', :charset => 'utf-8'
294 less :stylesheet
295 end
296
297 Renders <tt>./views/stylesheet.less</tt>.
298
28a3a35 @rkh Add liquid helper method. Tilt supports liquid for quite some time now, ...
rkh authored
299 === Liquid Templates
300
301 The liquid gem/library is required to render Liquid templates:
302
303 ## You'll need to require liquid in your app
304 require 'liquid'
305
306 get '/' do
307 liquid :index
308 end
309
310 Renders <tt>./views/index.liquid</tt>.
311
312 Since you cannot call Ruby methods (except for +yield+) from a Liquid
313 template, you almost always want to pass locals to it:
314
315 liquid :index, :locals => { :key => 'value' }
316
970169b @rkh Add markdown helper method. Tilt supports markdown for quite some time n...
rkh authored
317 === Markdown Templates
318
319 The rdiscount gem/library is required to render Markdown templates:
320
321 ## You'll need to require rdiscount in your app
322 require "rdiscount"
323
324 get '/' do
325 markdown :index
326 end
327
328 Renders <tt>./views/index.markdown</tt> (+md+ and +mkd+ are also valid file
329 extensions).
330
331 It is not possible to call methods from markdown, nor to pass locals to it. You therefore will usually use it in combination with another rendering engine:
332
333 erb :overview, :locals => { :text => markdown(:introduction) }
334
335 Note that you may also call the markdown method from within other templates:
336
337 %h1 Hello From Haml!
338 %p= markdown(:greetings)
339
b464e02 @rkh Add textile helper method. Tilt supports textile for quite some time now...
rkh authored
340 === Textile Templates
341
342 The RedCloth gem/library is required to render Textile templates:
343
344 ## You'll need to require rdiscount in your app
345 require "redcloth"
346
347 get '/' do
348 textile :index
349 end
350
351 Renders <tt>./views/index.textile</tt>.
352
353 It is not possible to call methods from textile, nor to pass locals to it. You therefore will usually use it in combination with another rendering engine:
354
355 erb :overview, :locals => { :text => textile(:introduction) }
356
357 Note that you may also call the textile method from within other templates:
358
359 %h1 Hello From Haml!
360 %p= textile(:greetings)
361
c248dba @rkh Add rdoc helper method. Tilt supports RDoc for quite some time now, but ...
rkh authored
362 === RDoc Templates
363
364 The RDoc gem/library is required to render RDoc templates:
365
366 ## You'll need to require rdiscount in your app
367 require "rdoc"
368
369 get '/' do
370 rdoc :index
371 end
372
373 Renders <tt>./views/index.rdoc</tt>.
374
375 It is not possible to call methods from rdoc, nor to pass locals to it. You therefore will usually use it in combination with another rendering engine:
376
377 erb :overview, :locals => { :text => rdoc(:introduction) }
378
379 Note that you may also call the rdoc method from within other templates:
380
381 %h1 Hello From Haml!
382 %p= rdoc(:greetings)
383
7cb94f2 @rkh Add radius helper method. Tilt supports radius for quite some time now, ...
rkh authored
384 === Radius Templates
385
386 The radius gem/library is required to render Radius templates:
387
388 ## You'll need to require radius in your app
389 require 'radius'
390
391 get '/' do
392 radius :index
393 end
394
395 Renders <tt>./views/index.radius</tt>.
396
397 Since you cannot call Ruby methods (except for +yield+) from a Radius
398 template, you almost always want to pass locals to it:
399
400 radius :index, :locals => { :key => 'value' }
401
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
402 === Inline Templates
df800b5 Docs are started
Blake Mizerany authored
403
404 get '/' do
405 haml '%div.title Hello World'
406 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
407
408 Renders the inlined template string.
df800b5 Docs are started
Blake Mizerany authored
409
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
410 === Accessing Variables in Templates
df800b5 Docs are started
Blake Mizerany authored
411
5018264 @rtomayko Tidy up README a bit; link to @sinatra on Twitter
rtomayko authored
412 Templates are evaluated within the same context as route handlers. Instance
413 variables set in route handlers are direcly accessible by templates:
df800b5 Docs are started
Blake Mizerany authored
414
415 get '/:id' do
416 @foo = Foo.find(params[:id])
95aca76 @bleything fix documentation of variable interpolation into templates
bleything authored
417 haml '%h1= @foo.name'
df800b5 Docs are started
Blake Mizerany authored
418 end
419
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
420 Or, specify an explicit Hash of local variables:
df800b5 Docs are started
Blake Mizerany authored
421
422 get '/:id' do
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
423 foo = Foo.find(params[:id])
95aca76 @bleything fix documentation of variable interpolation into templates
bleything authored
424 haml '%h1= foo.name', :locals => { :foo => foo }
df800b5 Docs are started
Blake Mizerany authored
425 end
426
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
427 This is typically used when rendering templates as partials from within
428 other templates.
429
3ef8eed @sr Deprecate use_in_file_templates!
sr authored
430 === Inline Templates
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
431
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
432 Templates may be defined at the end of the source file:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
433
eec7d21 @bmizerany In-file-templates are automaticly loaded for you.
bmizerany authored
434 require 'sinatra'
435
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
436 get '/' do
437 haml :index
438 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
439
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
440 __END__
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
441
f71330e @bmizerany quick doc fix
bmizerany authored
442 @@ layout
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
443 %html
444 = yield
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
445
f71330e @bmizerany quick doc fix
bmizerany authored
446 @@ index
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
447 %div.title Hello world!!!!!
448
3ef8eed @sr Deprecate use_in_file_templates!
sr authored
449 NOTE: Inline templates defined in the source file that requires sinatra
fa52709 @rkh fix markup for inline code in README
rkh authored
450 are automatically loaded. Call +enable :inline_templates+ explicitly if you
3ef8eed @sr Deprecate use_in_file_templates!
sr authored
451 have inline templates in other source files.
eec7d21 @bmizerany In-file-templates are automaticly loaded for you.
bmizerany authored
452
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
453 === Named Templates
454
5018264 @rtomayko Tidy up README a bit; link to @sinatra on Twitter
rtomayko authored
455 Templates may also be defined using the top-level <tt>template</tt> method:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
456
457 template :layout do
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
458 "%html\n =yield\n"
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
459 end
460
461 template :index do
462 '%div.title Hello World!'
463 end
464
465 get '/' do
466 haml :index
467 end
468
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
469 If a template named "layout" exists, it will be used each time a template
470 is rendered. You can disable layouts by passing <tt>:layout => false</tt>.
578bbab @djanowski Updating README for :layout => true.
djanowski authored
471
472 get '/' do
473 haml :index, :layout => !request.xhr?
474 end
475
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
476 == Helpers
df800b5 Docs are started
Blake Mizerany authored
477
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
478 Use the top-level <tt>helpers</tt> method to define helper methods for use in
5018264 @rtomayko Tidy up README a bit; link to @sinatra on Twitter
rtomayko authored
479 route handlers and templates:
df800b5 Docs are started
Blake Mizerany authored
480
481 helpers do
482 def bar(name)
483 "#{name}bar"
484 end
485 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
486
1776a80 Added Version and Docs
Blake Mizerany authored
487 get '/:name' do
488 bar(params[:name])
489 end
df800b5 Docs are started
Blake Mizerany authored
490
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
491 == Filters
df800b5 Docs are started
Blake Mizerany authored
492
c6d0614 @rkh Minor README improvements.
rkh authored
493 Before filters are evaluated before each request within the same context as
494 the routes will be and can modify the request and response. Instance variables
495 set in filters are accessible by routes and templates:
1776a80 Added Version and Docs
Blake Mizerany authored
496
df800b5 Docs are started
Blake Mizerany authored
497 before do
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
498 @note = 'Hi!'
499 request.path_info = '/foo/bar/baz'
500 end
501
502 get '/foo/*' do
503 @note #=> 'Hi!'
504 params[:splat] #=> 'bar/baz'
df800b5 Docs are started
Blake Mizerany authored
505 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
506
c6d0614 @rkh Minor README improvements.
rkh authored
507 After filter are evaluated after each request within the same context and can
508 also modify the request and response. Instance variables set in before filters
509 and routes are accessible by after filters:
4e50ddb @jschementi Adds after filters
jschementi authored
510
511 after do
512 puts response.status
513 end
514
c6d0614 @rkh Minor README improvements.
rkh authored
515 Filters optionally taking a pattern, causing them to be evaluated only if the
516 request path matches that pattern:
da047d3 @rkh add pattern matching to before/after filters.
rkh authored
517
518 before '/protected/*' do
519 authenticate!
520 end
521
522 after '/create/:slug' do |slug|
523 session[:last_slug] = slug
524 end
525
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
526 == Halting
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
527
4e50ddb @jschementi Adds after filters
jschementi authored
528 To immediately stop a request within a filter or route use:
df800b5 Docs are started
Blake Mizerany authored
529
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
530 halt
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
531
c6d0614 @rkh Minor README improvements.
rkh authored
532 You can also specify the status when halting:
fbbd822 @sr More 'halt' doc
sr authored
533
534 halt 410
535
c6d0614 @rkh Minor README improvements.
rkh authored
536 Or the body:
df800b5 Docs are started
Blake Mizerany authored
537
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
538 halt 'this will be the body'
df800b5 Docs are started
Blake Mizerany authored
539
c6d0614 @rkh Minor README improvements.
rkh authored
540 Or both:
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
541
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
542 halt 401, 'go away!'
df800b5 Docs are started
Blake Mizerany authored
543
c6d0614 @rkh Minor README improvements.
rkh authored
544 With headers:
fbbd822 @sr More 'halt' doc
sr authored
545
546 halt 402, {'Content-Type' => 'text/plain'}, 'revenge'
547
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
548 == Passing
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
549
5018264 @rtomayko Tidy up README a bit; link to @sinatra on Twitter
rtomayko authored
550 A route can punt processing to the next matching route using <tt>pass</tt>:
df800b5 Docs are started
Blake Mizerany authored
551
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
552 get '/guess/:who' do
553 pass unless params[:who] == 'Frank'
6c9488e @sr Stick to single quote; kill a blank line
sr authored
554 'You got me!'
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
555 end
556
557 get '/guess/*' do
6c9488e @sr Stick to single quote; kill a blank line
sr authored
558 'You missed!'
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
559 end
560
561 The route block is immediately exited and control continues with the next
562 matching route. If no matching route is found, a 404 is returned.
df800b5 Docs are started
Blake Mizerany authored
563
13fc79d @rtomayko Remove support for source file reloading [#166]
rtomayko authored
564 == Configuration
1776a80 Added Version and Docs
Blake Mizerany authored
565
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
566 Run once, at startup, in any environment:
1776a80 Added Version and Docs
Blake Mizerany authored
567
568 configure do
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
569 ...
1776a80 Added Version and Docs
Blake Mizerany authored
570 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
571
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
572 Run only when the environment (RACK_ENV environment variable) is set to
13fc79d @rtomayko Remove support for source file reloading [#166]
rtomayko authored
573 <tt>:production</tt>:
1776a80 Added Version and Docs
Blake Mizerany authored
574
575 configure :production do
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
576 ...
1776a80 Added Version and Docs
Blake Mizerany authored
577 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
578
13fc79d @rtomayko Remove support for source file reloading [#166]
rtomayko authored
579 Run when the environment is set to either <tt>:production</tt> or
580 <tt>:test</tt>:
1776a80 Added Version and Docs
Blake Mizerany authored
581
582 configure :production, :test do
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
583 ...
1776a80 Added Version and Docs
Blake Mizerany authored
584 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
585
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
586 == Error handling
1776a80 Added Version and Docs
Blake Mizerany authored
587
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
588 Error handlers run within the same context as routes and before filters, which
c6d0614 @rkh Minor README improvements.
rkh authored
589 means you get all the goodies it has to offer, like <tt>haml</tt>,
590 <tt>erb</tt>, <tt>halt</tt>, etc.
1776a80 Added Version and Docs
Blake Mizerany authored
591
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
592 === Not Found
1776a80 Added Version and Docs
Blake Mizerany authored
593
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
594 When a <tt>Sinatra::NotFound</tt> exception is raised, or the response's status
595 code is 404, the <tt>not_found</tt> handler is invoked:
1776a80 Added Version and Docs
Blake Mizerany authored
596
597 not_found do
c6d0614 @rkh Minor README improvements.
rkh authored
598 'This is nowhere to be found.'
1776a80 Added Version and Docs
Blake Mizerany authored
599 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
600
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
601 === Error
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
602
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
603 The +error+ handler is invoked any time an exception is raised from a route
63fd773 @sr Small doc fix re. after filter
sr authored
604 block or a filter. The exception object can be obtained from the
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
605 <tt>sinatra.error</tt> Rack variable:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
606
1776a80 Added Version and Docs
Blake Mizerany authored
607 error do
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
608 'Sorry there was a nasty error - ' + env['sinatra.error'].name
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
609 end
610
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
611 Custom errors:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
612
613 error MyCustomError do
e7e0e55 @rtomayko Minor docfixes in README.rdoc
rtomayko authored
614 'So what happened was...' + request.env['sinatra.error'].message
1776a80 Added Version and Docs
Blake Mizerany authored
615 end
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
616
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
617 Then, if this happens:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
618
619 get '/' do
620 raise MyCustomError, 'something bad'
621 end
622
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
623 You get this:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
624
625 So what happened was... something bad
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
626
59e797e @sr Doc for error(500) { }
sr authored
627 Alternatively, you can install error handler for a status code:
628
629 error 403 do
630 'Access forbidden'
631 end
632
633 get '/secret' do
634 403
635 end
636
637 Or a range:
638
639 error 400..510 do
640 'Boom'
641 end
642
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
643 Sinatra installs special <tt>not_found</tt> and <tt>error</tt> handlers when
644 running under the development environment.
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
645
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
646 == Mime types
647
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
648 When using <tt>send_file</tt> or static files you may have mime types Sinatra
6d8b333 @sr Update README re. mime_type
sr authored
649 doesn't understand. Use +mime_type+ to register them by file extension:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
650
6d8b333 @sr Update README re. mime_type
sr authored
651 mime_type :foo, 'text/foo'
1776a80 Added Version and Docs
Blake Mizerany authored
652
cb8fcb6 @sr Doc for content_type :foo
sr authored
653 You can also use it with the +content_type+ helper:
654
655 content_type :foo
656
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
657 == Rack Middleware
bda21f1 @rtomayko add doc on using Rack middleware to README
rtomayko authored
658
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
659 Sinatra rides on Rack[http://rack.rubyforge.org/], a minimal standard
660 interface for Ruby web frameworks. One of Rack's most interesting capabilities
661 for application developers is support for "middleware" -- components that sit
662 between the server and your application monitoring and/or manipulating the
663 HTTP request/response to provide various types of common functionality.
bda21f1 @rtomayko add doc on using Rack middleware to README
rtomayko authored
664
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
665 Sinatra makes building Rack middleware pipelines a cinch via a top-level
666 +use+ method:
bda21f1 @rtomayko add doc on using Rack middleware to README
rtomayko authored
667
668 require 'sinatra'
669 require 'my_custom_middleware'
670
671 use Rack::Lint
672 use MyCustomMiddleware
673
674 get '/hello' do
675 'Hello World'
676 end
677
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
678 The semantics of +use+ are identical to those defined for the
679 Rack::Builder[http://rack.rubyforge.org/doc/classes/Rack/Builder.html] DSL
680 (most frequently used from rackup files). For example, the +use+ method
681 accepts multiple/variable args as well as blocks:
bda21f1 @rtomayko add doc on using Rack middleware to README
rtomayko authored
682
683 use Rack::Auth::Basic do |username, password|
684 username == 'admin' && password == 'secret'
685 end
686
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
687 Rack is distributed with a variety of standard middleware for logging,
688 debugging, URL routing, authentication, and session handling. Sinatra uses
689 many of of these components automatically based on configuration so you
690 typically don't have to +use+ them explicitly.
bda21f1 @rtomayko add doc on using Rack middleware to README
rtomayko authored
691
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
692 == Testing
1776a80 Added Version and Docs
Blake Mizerany authored
693
c831278 @rtomayko Recommend Rack::Test in README / note Sinatra::Test deprecation
rtomayko authored
694 Sinatra tests can be written using any Rack-based testing library
695 or framework. {Rack::Test}[http://gitrdoc.com/brynary/rack-test] is
696 recommended:
c00a25e @rtomayko Test framework refactoring
rtomayko authored
697
7cfe04a @jcrosby Fix for test/unit and test/spec docs
jcrosby authored
698 require 'my_sinatra_app'
c831278 @rtomayko Recommend Rack::Test in README / note Sinatra::Test deprecation
rtomayko authored
699 require 'rack/test'
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
700
1776a80 Added Version and Docs
Blake Mizerany authored
701 class MyAppTest < Test::Unit::TestCase
c831278 @rtomayko Recommend Rack::Test in README / note Sinatra::Test deprecation
rtomayko authored
702 include Rack::Test::Methods
703
704 def app
705 Sinatra::Application
706 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
707
2f377e2 @rtomayko Trim down Testing section in the README; link to doc site instead
rtomayko authored
708 def test_my_default
c00a25e @rtomayko Test framework refactoring
rtomayko authored
709 get '/'
c831278 @rtomayko Recommend Rack::Test in README / note Sinatra::Test deprecation
rtomayko authored
710 assert_equal 'Hello World!', last_response.body
1776a80 Added Version and Docs
Blake Mizerany authored
711 end
10c90d5 @sr document testing with rspec
sr authored
712
2f377e2 @rtomayko Trim down Testing section in the README; link to doc site instead
rtomayko authored
713 def test_with_params
c831278 @rtomayko Recommend Rack::Test in README / note Sinatra::Test deprecation
rtomayko authored
714 get '/meet', :name => 'Frank'
715 assert_equal 'Hello Frank!', last_response.body
10c90d5 @sr document testing with rspec
sr authored
716 end
717
2f377e2 @rtomayko Trim down Testing section in the README; link to doc site instead
rtomayko authored
718 def test_with_rack_env
c831278 @rtomayko Recommend Rack::Test in README / note Sinatra::Test deprecation
rtomayko authored
719 get '/', {}, 'HTTP_USER_AGENT' => 'Songbird'
720 assert_equal "You're using Songbird!", last_response.body
1fb5b99 @dylanegan Bacon support
dylanegan authored
721 end
722 end
723
c831278 @rtomayko Recommend Rack::Test in README / note Sinatra::Test deprecation
rtomayko authored
724 NOTE: The built-in Sinatra::Test module and Sinatra::TestHarness class
725 are deprecated as of the 0.9.2 release.
1776a80 Added Version and Docs
Blake Mizerany authored
726
5360333 @sr Add a note about Sinatra::Base to the README
sr authored
727 == Sinatra::Base - Middleware, Libraries, and Modular Apps
728
729 Defining your app at the top-level works well for micro-apps but has
730 considerable drawbacks when building reuseable components such as Rack
731 middleware, Rails metal, simple libraries with a server component, or
732 even Sinatra extensions. The top-level DSL pollutes the Object namespace
733 and assumes a micro-app style configuration (e.g., a single application
734 file, ./public and ./views directories, logging, exception detail page,
735 etc.). That's where Sinatra::Base comes into play:
736
737 require 'sinatra/base'
738
739 class MyApp < Sinatra::Base
740 set :sessions, true
741 set :foo, 'bar'
742
743 get '/' do
744 'Hello world!'
745 end
746 end
747
748 The MyApp class is an independent Rack component that can act as
749 Rack middleware, a Rack application, or Rails metal. You can +use+ or
750 +run+ this class from a rackup +config.ru+ file; or, control a server
751 component shipped as a library:
752
753 MyApp.run! :host => 'localhost', :port => 9090
754
755 The methods available to Sinatra::Base subclasses are exactly as those
756 available via the top-level DSL. Most top-level apps can be converted to
757 Sinatra::Base components with two modifications:
758
759 * Your file should require +sinatra/base+ instead of +sinatra+;
760 otherwise, all of Sinatra's DSL methods are imported into the main
761 namespace.
762 * Put your app's routes, error handlers, filters, and options in a subclass
763 of Sinatra::Base.
764
765 +Sinatra::Base+ is a blank slate. Most options are disabled by default,
766 including the built-in server. See {Options and Configuration}[http://sinatra.github.com/configuration.html]
767 for details on available options and their behavior.
768
769 SIDEBAR: Sinatra's top-level DSL is implemented using a simple delegation
770 system. The +Sinatra::Application+ class -- a special subclass of
771 Sinatra::Base -- receives all :get, :put, :post, :delete, :before,
772 :error, :not_found, :configure, and :set messages sent to the
773 top-level. Have a look at the code for yourself: here's the
035fe47 @sr fix Delegator links in README
sr authored
774 {Sinatra::Delegator mixin}[http://github.com/sinatra/sinatra/blob/ceac46f0bc129a6e994a06100aa854f606fe5992/lib/sinatra/base.rb#L1128]
775 being {included into the main namespace}[http://github.com/sinatra/sinatra/blob/ceac46f0bc129a6e994a06100aa854f606fe5992/lib/sinatra/main.rb#L28]
5360333 @sr Add a note about Sinatra::Base to the README
sr authored
776
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
777 == Command line
1776a80 Added Version and Docs
Blake Mizerany authored
778
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
779 Sinatra applications can be run directly:
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
780
4d61607 @sr update README/CHANGES re. -o
sr authored
781 ruby myapp.rb [-h] [-x] [-e ENVIRONMENT] [-p PORT] [-o HOST] [-s HANDLER]
1776a80 Added Version and Docs
Blake Mizerany authored
782
783 Options are:
784
785 -h # help
786 -p # set the port (default is 4567)
4d61607 @sr update README/CHANGES re. -o
sr authored
787 -o # set the host (default is 0.0.0.0)
1776a80 Added Version and Docs
Blake Mizerany authored
788 -e # set the environment (default is development)
f29486b @karmi Note "-s" (server) command line option in README
karmi authored
789 -s # specify rack server/handler (default is thin)
e7e0e55 @rtomayko Minor docfixes in README.rdoc
rtomayko authored
790 -x # turn on the mutex lock (default is off)
1776a80 Added Version and Docs
Blake Mizerany authored
791
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
792 == The Bleeding Edge
6326809 @cypher Add a subsection about tools needed for Sinatra to the Contributing sect...
cypher authored
793
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
794 If you would like to use Sinatra's latest bleeding code, create a local
795 clone and run your app with the <tt>sinatra/lib</tt> directory on the
796 <tt>LOAD_PATH</tt>:
6326809 @cypher Add a subsection about tools needed for Sinatra to the Contributing sect...
cypher authored
797
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
798 cd myapp
ba92616 @bmizerany Updated README to point to github.com/sinatra/sinatra.git
bmizerany authored
799 git clone git://github.com/sinatra/sinatra.git
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
800 ruby -Isinatra/lib myapp.rb
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
801
4f30c1c fix unclosed <tt> in README
Mathew Cucuzella authored
802 Alternatively, you can add the <tt>sinatra/lib</tt> directory to the
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
803 <tt>LOAD_PATH</tt> in your application:
1776a80 Added Version and Docs
Blake Mizerany authored
804
17cb177 @cypher README and CHANGES tweaks for 0.9.0 release (#63)
cypher authored
805 $LOAD_PATH.unshift File.dirname(__FILE__) + '/sinatra/lib'
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
806 require 'rubygems'
1776a80 Added Version and Docs
Blake Mizerany authored
807 require 'sinatra'
808
809 get '/about' do
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
810 "I'm running version " + Sinatra::VERSION
1776a80 Added Version and Docs
Blake Mizerany authored
811 end
e6c5471 @cypher Add a community section with info about the mailing list and irc channel
cypher authored
812
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
813 To update the Sinatra sources in the future:
d8fec16 @cypher Add subsection about contributing a patch as well as a link to the issue...
cypher authored
814
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
815 cd myproject/sinatra
816 git pull
e6c5471 @cypher Add a community section with info about the mailing list and irc channel
cypher authored
817
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
818 == More
e6c5471 @cypher Add a community section with info about the mailing list and irc channel
cypher authored
819
754f116 @rtomayko README: better links to project website and mailing list
rtomayko authored
820 * {Project Website}[http://www.sinatrarb.com/] - Additional documentation,
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
821 news, and links to other resources.
754f116 @rtomayko README: better links to project website and mailing list
rtomayko authored
822 * {Contributing}[http://www.sinatrarb.com/contributing] - Find a bug? Need
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
823 help? Have a patch?
60ac449 @sr lighthouse => github issue
sr authored
824 * {Issue tracker}[http://github.com/sinatra/sinatra/issues]
5018264 @rtomayko Tidy up README a bit; link to @sinatra on Twitter
rtomayko authored
825 * {Twitter}[http://twitter.com/sinatra]
754f116 @rtomayko README: better links to project website and mailing list
rtomayko authored
826 * {Mailing List}[http://groups.google.com/group/sinatrarb/topics]
4298a77 @rtomayko Tweak README formatting; move community/contributing to website
rtomayko authored
827 * {IRC: #sinatra}[irc://chat.freenode.net/#sinatra] on http://freenode.net
Something went wrong with that request. Please try again.