Sinatra: 29 Links and Resources For A Quicker, Easier Way to Build Webapps
Sinatra, 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!)
December 18, 2008 at 4:47 pm
This is excellent. i found sinatra as a great way to ease into rails for newbies like myself.
December 18, 2008 at 4:50 pm
I spoke with Blake Mizerany recently on the Rails Podcast:
http://podcast.rubyonrails.org/programs/1/episodes/rubyconf-2008
December 18, 2008 at 4:59 pm
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!
December 18, 2008 at 5:07 pm
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.
December 18, 2008 at 5:20 pm
Simon Rozet is keeping a nice list of Sinatra-based apps. Lots of good stuff on there.
http://gist.github.com/22172
December 18, 2008 at 5:41 pm
I've added a credit to Simon since it appears many of the links were from there.
December 18, 2008 at 5:47 pm
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!
December 18, 2008 at 5:56 pm
Also to note is Chris Schneid's blog (http://gittr.com), which is an invaluable repository of examples and guides for sinatra =)
December 18, 2008 at 6:12 pm
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
December 18, 2008 at 6:28 pm
Additionally from RubyConf, David Goodlad mentioned running Sinatra on embedded hardware.
http://rubyconf2008.confreaks.com/ruby-for-embedded-applications.html
December 18, 2008 at 8:01 pm
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
December 18, 2008 at 8:43 pm
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?
December 18, 2008 at 8:45 pm
Theoretically I don't see why not, but the structure definitely seems a lot better suited to small apps from my POV.
December 18, 2008 at 8:46 pm
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/
December 18, 2008 at 9:35 pm
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
December 18, 2008 at 10:14 pm
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
December 18, 2008 at 10:45 pm
Just found this:
http://locomotivation.com/blog/2008/12/01/disqus-sinatra-importer.html
A Sinatra app that imports comments into Disqus.
December 18, 2008 at 10:55 pm
Auuugghhh! Too many web frameworks!
December 19, 2008 at 12:27 am
MooURL is sinatra based - http://moourl.com/
December 19, 2008 at 1:56 am
Another sinatra app - the opposite of moourl.com: http://urlunwind.com/
December 19, 2008 at 7:40 am
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.
December 19, 2008 at 6:47 pm
nice post and good collection of informative links together.
December 19, 2008 at 11:05 pm
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/
December 20, 2008 at 12:56 pm
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
December 21, 2008 at 7:41 am
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
December 30, 2008 at 7:47 pm
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.
January 3, 2009 at 10:00 am
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!
January 6, 2009 at 5:51 am
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.