Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 100 lines (70 sloc) 3.12 kb
85e1a4c docs
Blake Mizerany authored
1 Sinatra (C) 2007 By Blake Mizerany
208158a * README w/MIT
blake.mizerany@gmail.com authored
2
85e1a4c docs
Blake Mizerany authored
3 = Classy web-development dressed in a DSL
208158a * README w/MIT
blake.mizerany@gmail.com authored
4
85e1a4c docs
Blake Mizerany authored
5 == Install!
208158a * README w/MIT
blake.mizerany@gmail.com authored
6
85e1a4c docs
Blake Mizerany authored
7 sudo gem install sinatra -y
208158a * README w/MIT
blake.mizerany@gmail.com authored
8
85e1a4c docs
Blake Mizerany authored
9 == Use!
208158a * README w/MIT
blake.mizerany@gmail.com authored
10
85e1a4c docs
Blake Mizerany authored
11 I'm going to move quick. I'll let you drool at your own pace.
208158a * README w/MIT
blake.mizerany@gmail.com authored
12
c96aeed thank yous
Blake Mizerany authored
13 * Create a file called lyrics.rb (or any name you like)
208158a * README w/MIT
blake.mizerany@gmail.com authored
14
c96aeed thank yous
Blake Mizerany authored
15 * Add
85e1a4c docs
Blake Mizerany authored
16 require 'rubygems'
17 require 'sinatra'
208158a * README w/MIT
blake.mizerany@gmail.com authored
18
c96aeed thank yous
Blake Mizerany authored
19 * Run (yes, with just ruby)
85e1a4c docs
Blake Mizerany authored
20 % ruby lyrics.rb
21 == Sinata has taken the stage on port 4567!
208158a * README w/MIT
blake.mizerany@gmail.com authored
22
c96aeed thank yous
Blake Mizerany authored
23 * Take a moment and view the default page http://localhost:4567. Go ahead and bask in it's glory.
208158a * README w/MIT
blake.mizerany@gmail.com authored
24
85e1a4c docs
Blake Mizerany authored
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
208158a * README w/MIT
blake.mizerany@gmail.com authored
29
c96aeed thank yous
Blake Mizerany authored
30 * Modify lyrics.rb by adding:
85e1a4c docs
Blake Mizerany authored
31 get '/' do
32 'Hello World'
33 end
34
c96aeed thank yous
Blake Mizerany authored
35 * Refresh (no need to restart Sinatra):
85e1a4c docs
Blake Mizerany authored
36 http://localhost:4567
37
c96aeed thank yous
Blake Mizerany authored
38 * Modify again (then refresh):
85e1a4c docs
Blake Mizerany authored
39 get '/' do
40 <<-HTML
41 <form action='/' method="POST">
42 <input type="text" name="name" />
43 <input type="submit" value="Say my name!" />
44 </form>
45 HTML
46 end
47
48 post '/' do
49 "Hello #{params[:name] || 'World'}!"
50 end
51
c96aeed thank yous
Blake Mizerany authored
52 * Now you try:
53 Use the Sinatra::Erb::EventContext or Sinatra::Haml::EventContext to do the same. Do them inline and as template files.
54
55 * Learn more cool stuff:
56 see Sinatra::Dsl
57
58 * Create your own plugins!
59 1. Create a 'vendor' directory in your app directory
60 2. Lay it out like:
61
62 myapp.rb : root
63 |- vendor
64 | - plugin_name
65 | - init.rb # load and hook here
66 | - lib
67 |- modules/classes here
68
69 3. Use it in your app!
70
71 see $SINATRA_GEM_ROOT/vendor/erb or $SINATRA_GEM_ROOT/vendor/erb for examples.
72
73 * Tell!
74 We would love to here what you're doing with Sinatra and any cool patches/features you would like. (blake { dot } mizerany [ at ] gmail)
75
76 * Talk!
77 IRC (irc.freenode.com #sinatra)
78 Mailing List (sinatrarb@googlegroups.com)
79
80 * Contribute
81
82 We're using git as our scm.. cuz.. it rocks. You can get the latest source from http://repo.or.cz/w/sinatra.git
83
84 NOTE: You can also get tar'd snapshots of each commit there too. So technically you don't need git to get the latest code.
85
86 It's probably going to happen.. you'll find a bug. Please help by:
87
88 * Sending a message to sintrarb@googlegroups.com with BUG: at the start of the subject (I'm working on a better tracking system)
89 * Please send patches or pull requests to (blake { dot } mizerany [ at ] gmail) don't forget the dot com. ;)
90
91 == Thanks!
92
93 - Ezra Zygmuntowicz (http://brainspl.at) for answering all those random questions over IM and all the poached code
94 - Ditto to Chris Wanstrath (errtheblog.com) and helping me keep things simple, and some cool tricks
95 - Ari Lerner over at CitrusByte for ideas, code, and enthusiasm
96 - Koshi (http://www.songbirdnest.com/jkoshi/blog) here at POTI, Inc. for the Sinatra mark
97 - Pete Golibersuch for the hat logo
98 - John Philip Green (http://www.linkedin.com/in/johngreen) for motivation and evangelism
99 - The team here at songbirdnest.com for cool ideas
Something went wrong with that request. Please try again.