docs
[sinatra.git] / README
blob05516492910261f0cc76781a6349d6e1e5da0164
1 Sinatra (C) 2007 By Blake Mizerany
3 = Classy web-development dressed in a DSL
5 == Install!
7   sudo gem install sinatra -y
9 == Use!
11 I'm going to move quick.  I'll let you drool at your own pace.
13 - Create a file called lyrics.rb (or any name you like)
15 - Add
16     require 'rubygems'
17     require 'sinatra'
19 - Run (yes, with just ruby)
20     % ruby lyrics.rb
21     == Sinata has taken the stage on port 4567!
23 - Take a moment and view the default page http://localhost:4567.  Go ahead and bask in it's glory.
25 * Notice:
26   * It didn't create any page to show you that default page (just a cool thing to see, that's all)
27   * There was nothing generated other than a log file
28   * Sinatra is a really cool name for a web-framework that's a DSL
30 - Modify lyrics.rb by adding:
32     get '/' do
33       'Hello World'
34     end
35   
36 - Refresh (no need to restart Sinatra):
38     http://localhost:4567
40 - Modify again (then refresh):
42     get '/' do
43       <<-HTML
44         <form action='/' method="POST">
45           <input type="text" name="name" />
46           <input type="submit" value="Say my name!" />
47         </form>
48       HTML
49     end
50   
51     post '/' do
52       "Hello #{params[:name] || 'World'}!"
53     end
54   
55 - Homework:
57 Use the Sinatra::Erb::EventContext or Sinatra::Haml::EventContext to do the same.  Do them inline and as template files.