Sinatra

2,018 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
2,018
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Sinatra

  1. 1. Sinatra Ryan Farnell (@criscokid)
  2. 2. What is Sinatra?
  3. 3. Micro Web Framework • Built on top of Rack • Uses RESTful thinking • URL’s are king
  4. 4. Features • Routing to code blocks • Static Files • Views/Layouts • Filters • Helpers
  5. 5. Routing To Blocks • Routes made up of 3 basic parts • HTTP Verb • Match Expression • Code block
  6. 6. HTTP Verbs POST GET PUT DELETE
  7. 7. Demo
  8. 8. Serving Public Files • If no matching URL was found, Sinatra checks the public folder • Public folder can be changed by setting :public set :public,'path/to/file/static'
  9. 9. Viewsmarkup • Views are mixes of code and • Sinatra works with ERB, HAML, and Builder by default • Views are kept in a folder at the root of the site called “views” • View folder can be changed by setting :views set :views,,'path/to/file/static'
  10. 10. Layout • Layouts are like templates for all your pages. • Bydefault looks for a file called “layout” in views with the same extension as the view you are rendering. • Default name can be overridden.
  11. 11. Demo
  12. 12. Filters • Filters run before all routes. • Theycan modify the Request and Response object. • Any instance variable created in the before filter is available in the route.
  13. 13. Helpers • Small methods that you find useful. • Available within the route and within the views.
  14. 14. Demo
  15. 15. Example Apps
  16. 16. Git-Wiki http://atonie.org/2008/02/git-wiki
  17. 17. Rif-Graf http://rifgraf.heroku.com/
  18. 18. Github-Services http://github.com/pjhyett/github-services/tree/maste
  19. 19. Deployment • Any server compatible with Rack • Ruby Servers • Mongrel • Thin • Webrick • Apache running mod_rack (Phusion Passenger) • FastCGI Server • Apache • Lighttpd
  20. 20. http://www.sinatrarb.com/
  21. 21. Q&A

×