Sinatra


Perth RORO meet-up April 09
              Matt Didcoe
What is Sinatra?



Micro framework for the Ruby language
Example
Can I use ‘x’ for views?
•   For your HTML/XML can use
     – Haml
        haml :index # renders ./views/index.haml
     –...
Configuring Sinatra
Routing
Rack Middleware
•   HTTP Authentication




•   Caching
•   Logging
•   Javascript ‘minification’

•   Write your own to d...
Error handling


Standard errors




Custom error handling can be rolled in as well
Deploying
1. Install Apache 2 + Passenger
2. Copy app to server and setup VirtualHost pointing to the public directory of
...
Links
There’s more to learn – visit these links or just download Sinatra and start
playing

•   http://www.sinatrarb.com/i...
Upcoming SlideShare
Loading in …5
×

Sinatra

1,901 views

Published on

My presentation on Sinatra, a Ruby micro framework to the Perth Ruby on Rails meetup

Published in: Technology, Design
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,901
On SlideShare
0
From Embeds
0
Number of Embeds
72
Actions
Shares
0
Downloads
22
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Sinatra

  1. 1. Sinatra Perth RORO meet-up April 09 Matt Didcoe
  2. 2. What is Sinatra? Micro framework for the Ruby language
  3. 3. Example
  4. 4. Can I use ‘x’ for views? • For your HTML/XML can use – Haml haml :index # renders ./views/index.haml – ERB erb :index # renders ./views/index.erb – Builder content_type 'application/xml', :charset => 'utf-8’ builder :index • For your CSS you can use – Straight css from the ./public directory (or a subfolder thereof) – SASS (much cooler) content_type 'text/css', :charset => 'utf-8’ sass :stylesheet • You can set a different view directory as well to suit
  5. 5. Configuring Sinatra
  6. 6. Routing
  7. 7. Rack Middleware • HTTP Authentication • Caching • Logging • Javascript ‘minification’ • Write your own to do whatever you want…
  8. 8. Error handling Standard errors Custom error handling can be rolled in as well
  9. 9. Deploying 1. Install Apache 2 + Passenger 2. Copy app to server and setup VirtualHost pointing to the public directory of your app (if you don’t have one, create one…it can be empty) 3. Put this config.ru file in your app root require 'rubygems' require 'sinatra' set :run, false set :environment, ENV['RACK_ENV'] require 'app' run Sinatra::Application 4. Go have a drink
  10. 10. Links There’s more to learn – visit these links or just download Sinatra and start playing • http://www.sinatrarb.com/intro.html • http://www.sinatrarb.com/documentation.html • http://github.com/sinatra

×