Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Sinatra: 29 Links and Resources For A Quicker, Easier Way to Build Webapps

By Peter Cooper / December 18, 2008

sinatra-icon.pngSinatra, a Ruby "micro framework" for developing Web applications, is hot stuff! Despite being over a year since we first mentioned Sinatra (as used on a 100 line blogging app called Reprise), only now does Sinatra seem to have reached critical mass - it's on the cusp of becoming really popular. This is a good time, then, to check it out and see where it could fit into your own projects (with the new Rails Metal functionality (in edge/2.3 only) you can ever run a Sinatra app as a lightweight companion integrated with your Rails apps!)

Sinatra's official homepage provides an incredible number of alluring examples. Just install the sinatra gem or clone its git repository and you can have an ultra basic webapp running in just five lines of code:

require 'rubygems'
require 'sinatra'
get '/' do
'Hello world!'
end

Lots of awesome articles about Sinatra, Sinatra apps, and various links and resources have cropped up over the past few months. The remainder of this post links to the best we've found - most of which you should find useful as you start to explore Sinatra in detail. If you know of any others, please post links in the comments! Of course, if you ultimately agree with Ross Lawley that Sinatra's a "horrid looking ruby web framework that looks its born straight from the worst PHP frameworks" then you might also want to check out Ramaze!

Tutorials and Presentations

Building an iPhone Web app in under 50 lines with Sinatra and iUI - A comprehensive walkthrough of developing an iPhone friendly Web application based on Sinatra. Even if developing an iPhone app doesn't interest you much, this tutorial is so well written that it could act as a good introduction for anyone.

Lightweight Web Services with Sinatra and RestClient - A presentation (in slide form) by Adam Wiggins and Blake Mizerany on using Sinatra and RestClient to build lightweight Web services. Not much of depth in here but helps tie together some of the concepts.

The Sinatra Book - A page full of Sinatra reference joy.

How to use RSpec to describe a Sinatra application - Jesse Hallett looks at how to improve the RSpecability of Sinatra apps if you're into speccing.

Clone Pastie with Sinatra & DataMapper 0.9 - A tutorial by Nick Plante that walks you through developing a pastie.org-style application using Sinatra and DataMapper.

Rails Meets Sinatra - Pratik Naik (of the Rails core team) shows how you can mount a Sinatra app into a Rails app (not just at the metal, as mentioned before) so that you can write Sinatra methods directly within Rails classes!

Sinatra Tutorial - A basic Sinatra tutorial by Ari Lerner (for Sinatra 0.1.7 however).

Sinatra Applications

git-wiki - A "quick and dirty" Git-powered wiki built on Sinatra by Simon Rozet.

frankie - Easy creation of Facebook applications in Ruby using plugin for Sinatra web framework that integrates with the Facebooker gem.

rifgraf - "Fire-and-forget" data collection and graphing service by Adam Wiggins.

Integrity - A continuous integration server (you can see it in action here). Karel Minarik billed its source as "probably the most elegant Ruby I have seen lately."

gaze - A quick way to serve up Markdown files.

sinatra_wiki - An "ultralight, ultraminimal" wiki system that uses Markdown for formatting.

toopaste - A Pastie clone in Sinatra - uses DataMapper.

notable - Listens on Jabber and then relays messages back to you (on the Web).

rash - Extremely small and simple app to display results of a hashtag search on Twitter.

snail - A Web interface to Amazon Web Services.

yaml_micro_chat - A basic YAML-powered "micro-chat" system by Karel Minarik.

Deployment

capinatra - A tool to quickly deploy Sinatra apps to a Phusion Passenger installation

Deploying Sinatra on Dreamhost with Passenger - A tutorial by John Nunemaker that shows how to use Capistrano and Dreamhost to deploy your Sinatra apps.

Sinatra Blogging Engines

Marley - A blog engine by Karel Minarik. It works by publishing posts that you write in your favorite text editor, stored as plain files. This link goes to a post that explains Marley's operation in detail - well worth looking at.

scanty - A tiny blogging tool by Adam Wiggins. It uses Sequel for ORM, supports Ruby syntax highlighting, tags, and uses Markdown.

wink - A "minimalist blogging engine" by Ryan Tomayko. No longer actively maintained (but you can fork it!) but it powers a few blogs.

sin - A mini blog engine in Sinatra with hAtom and MetaWeblog API. All in a single file! Particularly interesting for the MetaWeblog API support. Uses Active Record.

Sites Built on Sinatra

Calendar About Nothing - A "Seinfeld Calendar" based upon public Github feeds. The principle is simple.. commit something to Github every day and you get a streak. Long streaks are celebrated. Hurrah!

Follow Cost - Find out how annoying it will be to follow specific people on Twitter, as measured in milli-scobles!

Stuff - A random collection of mostly Ruby stuff..

IRCLogger - A Sinatra based app that runs irclogger.com, a site that shows logs from several Ruby related IRC channels.

Thanks go to Karel Minarik of Restafari for supplying many of these links (as well as Simon Rozet with his list on Gist). Got your own? Leave a comment!

Support from: 1st Easy offers UK Rails hosting (dedicated and shared) running Phusion Passenger (mod_rails) and LAMP stack. If you want to get to know us first, or simply want to evaluate the performance of your Rails applications running on Passenger, we'll arrange a trial hosting account for you (full technical support included!)

Comments

  1. Jason Calleiro says:

    This is excellent. i found sinatra as a great way to ease into rails for newbies like myself.

  2. Geoffrey Grosenbach says:

    I spoke with Blake Mizerany recently on the Rails Podcast:

    http://podcast.rubyonrails.org/programs/1/episodes/rubyconf-2008

  3. Peter Cooper says:

    I had that as a link in my list, but because I couldn't figure out a category for it and I haven't listened to it yet it was skipped, so thanks for posting it!

  4. Pat Nakajim says:

    People interested in Sinatra might also dig my Sinatra's Hat library, which let's you easily mount RESTful resources (it's ORM agnostic, though out of the box it works with DataMapper). Here's the project: http://github.com/nakajima/sinatras-hat.

  5. Dale Campbell says:

    Simon Rozet is keeping a nice list of Sinatra-based apps. Lots of good stuff on there.

    http://gist.github.com/22172

  6. Peter Cooper says:

    I've added a credit to Simon since it appears many of the links were from there.

  7. Aaron Quint says:

    Hey Peter

    I also just wrote up a sinatra app skeleton generator that I worked with the sinatra mailing list on:

    http://github.com/quirkey/sinatra-gen

    Also second Pat's 'sinatras-hat'
    Thanks!

  8. Nicolás Sanguinetti says:

    Also to note is Chris Schneid's blog (http://gittr.com), which is an invaluable repository of examples and guides for sinatra =)

  9. karmi says:

    Also, definitely worth seeing is Adam's and Blake's energetic talk from RubyConf @ Confreaks: http://rubyconf2008.confreaks.com/lightweight-web-services.html

    (And thanks for the undeserved credits, Peter! :)

    --karmi

  10. Geoffrey Grosenbach says:

    Additionally from RubyConf, David Goodlad mentioned running Sinatra on embedded hardware.

    http://rubyconf2008.confreaks.com/ruby-for-embedded-applications.html

  11. Andy Atkinson says:

    Not really an app, but I made a simple site that scrapes HTML with hpricot off my github repo, with Sinatra, and found it is great for this type of thing, a small server side proxy, or a mashup data aggregator and provider. Have also used Sinatra for a single page site with a twitter and flickr gem to pull tweets and photos as a "live stream" type of site. http://webandy.com/2008/11/15/gadgets-and-demo-generator

  12. Jeedee says:

    Everyone is saying they made "small" apps using Sinatra but would it be also well suited for large applications as well? You can always use Ramaze which is amazing but what about Sinatra?

  13. Peter Cooper says:

    Theoretically I don't see why not, but the structure definitely seems a lot better suited to small apps from my POV.

  14. Blake Mizerany says:

    The easiest way to get a Sinatra app running and deployed is here: http://runswithpandas.heroku.com/past/2008/11/13/sinatra_hosting_for_free/

  15. Julio Capote says:

    I wrote a simple json powered blog api using sinatra/jruby/jdbc-sqlite just as a starting point for any embedded jruby/sinatra project. http://github.com/jcapote/bloggy/tree/master

  16. Andre Lewis says:

    Sinatra is really, really fun to work with. I recently put together a Sinatra + DataMapper + HAML/SASS proof-of-concept app, running on Passenger. I put up some notes & lessons learned here: http://earthcode.com/blog/2008/12/building_a_simple_sinatradatam.html

  17. Peter Cooper says:

    Just found this:

    http://locomotivation.com/blog/2008/12/01/disqus-sinatra-importer.html

    A Sinatra app that imports comments into Disqus.

  18. Daniel Berger says:

    Auuugghhh! Too many web frameworks!

  19. caffo says:

    MooURL is sinatra based - http://moourl.com/

  20. Tobias Crawley says:

    Another sinatra app - the opposite of moourl.com: http://urlunwind.com/

  21. Maik Schmidt says:

    Shameless plug: my new book (http://www.pragprog.com/titles/msenr/enterprise-recipes-with-ruby-and-rails) contains a Sinatra tutorial, too. It shows how to use Sinatra for quickly creating REST service prototypes.

  22. Rich Apps Consulting says:

    nice post and good collection of informative links together.

  23. Peter Cooper says:

    Cool demonstration of accepting file uploads in a Sinatra app in just one line!

    http://technotales.wordpress.com/2008/03/05/sinatra-the-simplest-thing-that-could-possibly-work/

  24. Vasudev Ram says:

    Nice post, Peter.

    Lightweight software (including lightweight frameworks) is one of my interests, so it was good to read this. With the huge growth in the mobile space, light software is likely to grow in use too, due to the relative CPU and memory constraints of mobile devices.

    BTW, you likely already know of them, but just in case, and also for other readers who also use or are interested in Python, CherryPy and web.py are somewhat similar frameworks to Sinatra, but for Python. Both of those also require only a few lines for an ultra basic web app, though maybe a bit more than your first Sinatra example above.

    And on a related note, Python's WSGI (Web Services Gateway Interface) is increasingly getting supported by the newer Python web app frameworks. (It's also supported in, in fact is one of the main ways of using, Google App Engine.) I also read just recently that Ruby's Rack was inspired by WSGI.

    Cool stuff ...

    - Vasudev

  25. Andrew Coleman says:

    I made a website with a complimentary Facebook application in Sinatra. FB app is about 550 ok lines, most is sass stylesheet. http://binaryattraction.com
    Code is at: http://github.com/penguincoder/binaryattraction

  26. Aaron Bedra says:

    Don't forget about Castronaut (http://github.com/relevance/castronaut) It is an implementation of a CAS server using Sinatra that implements a nice presenter pattern.

  27. Juan Lupión says:

    I wrote http://github.com/pantulis/whoisbigger/tree/master in an effort to learn Sinatra. In less than 6 hours I had that really simple app deployed with Passenger on Dreamhost, and loving it!

  28. Joe Fiorini says:

    I have an Intro to Sinatra screencast I put together at http://www.vimeo.com/2374819. It is an example of writing the app online at http://isitcodemashyet.com.

Other Posts to Enjoy

Twitter Mentions