SlideShare une entreprise Scribd logo
1  sur  10
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
     – 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
Configuring Sinatra
Routing
Rack Middleware
•   HTTP Authentication




•   Caching
•   Logging
•   Javascript ‘minification’

•   Write your own to do whatever you want…
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
   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
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

Contenu connexe

Similaire à Sinatra

01 Struts Intro
01 Struts Intro01 Struts Intro
01 Struts Intro
sdileepec
 
Facebook Hadoop Data & Applications
Facebook Hadoop Data & ApplicationsFacebook Hadoop Data & Applications
Facebook Hadoop Data & Applications
dzhou
 
Intrusion Detection System using Snort
Intrusion Detection System using Snort Intrusion Detection System using Snort
Intrusion Detection System using Snort
webhostingguy
 

Similaire à Sinatra (20)

Sinatra
SinatraSinatra
Sinatra
 
Optaros Surf Code Camp Lab 2
Optaros Surf Code Camp Lab 2Optaros Surf Code Camp Lab 2
Optaros Surf Code Camp Lab 2
 
Sinatra
SinatraSinatra
Sinatra
 
Struts Into
Struts IntoStruts Into
Struts Into
 
01 Struts Intro
01 Struts Intro01 Struts Intro
01 Struts Intro
 
Sinatra
SinatraSinatra
Sinatra
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by Capistrano
 
Capistrano
CapistranoCapistrano
Capistrano
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
Modern Front-End Development
Modern Front-End DevelopmentModern Front-End Development
Modern Front-End Development
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
 
Facebook Hadoop Data & Applications
Facebook Hadoop Data & ApplicationsFacebook Hadoop Data & Applications
Facebook Hadoop Data & Applications
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
 
Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academy
 
Managing Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchManaging Your Security Logs with Elasticsearch
Managing Your Security Logs with Elasticsearch
 
WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011
 
Optaros Surf Code Camp Lab 1
Optaros Surf Code Camp Lab 1Optaros Surf Code Camp Lab 1
Optaros Surf Code Camp Lab 1
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
 
Real-World AJAX with ASP.NET
Real-World AJAX with ASP.NETReal-World AJAX with ASP.NET
Real-World AJAX with ASP.NET
 
Intrusion Detection System using Snort
Intrusion Detection System using Snort Intrusion Detection System using Snort
Intrusion Detection System using Snort
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Sinatra

  • 1. Sinatra Perth RORO meet-up April 09 Matt Didcoe
  • 2. What is Sinatra? Micro framework for the Ruby language
  • 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
  • 7. Rack Middleware • HTTP Authentication • Caching • Logging • Javascript ‘minification’ • Write your own to do whatever you want…
  • 8. Error handling Standard errors Custom error handling can be rolled in as well
  • 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. 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