<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>_includes/book.html</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,1035 +1,9 @@
 ---
 title: &quot;Sinatra: The Book&quot;
 layout: default
+id: book
 ---
 
-&lt;h1 id='table_of_contents'&gt;The Book&lt;/h1&gt;
-&lt;div class='maruku_toc'&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#table_of_contents'&gt;Table of Contents&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#introduction'&gt;Introduction&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#what_is_sinatra'&gt;What is Sinatra?&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#installation'&gt;Installation&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#dependencies'&gt;Dependencies&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#living_on_the_edge'&gt;Living on the Edge&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#hello_world_application'&gt;Hello World Application&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#real_world_applications_in_sinatra'&gt;Real World Applications in Sinatra&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#github_services'&gt;Github Services&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#git_wiki'&gt;Git Wiki&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#integrity'&gt;Integrity&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#seinfeld_calendar'&gt;Seinfeld Calendar&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#about_this_book'&gt;About this book&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#routes'&gt;Routes&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#http_methods'&gt;HTTP methods&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#basic'&gt;Basic&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#options'&gt;Options&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#splats'&gt;Splats&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#user_agent'&gt;User agent&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#other_methods'&gt;Other methods&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#the_put_and_delete_methods'&gt;The PUT and DELETE methods&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#how_routes_are_looked_up'&gt;How routes are looked up&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#splitting_into_multiple_files'&gt;Splitting into multiple files&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#handlers'&gt;Handlers&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#structure'&gt;Structure&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#redirect'&gt;Redirect&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#sessions'&gt;Sessions&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#default_cookie_based_sessions'&gt;Default Cookie Based Sessions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#memory_based_sessions'&gt;Memory Based Sessions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#memcached_based_sessions'&gt;Memcached Based Sessions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#file_based_sessions'&gt;File Based Sessions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#database_based_sessions'&gt;Database Based Sessions&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#cookies'&gt;Cookies&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#status'&gt;Status&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#authentication'&gt;Authentication&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#filters'&gt;Filters&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#before_do'&gt;before do&amp;#8230;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#handling_of_rails_like_nested_params'&gt;Handling of Rails like nested params&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#views'&gt;Views&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#template_languages'&gt;Template Languages&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#haml'&gt;Haml&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#sass'&gt;Sass&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#erb'&gt;Erb&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#builder'&gt;Builder&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#atom_feed'&gt;Atom Feed&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#rss_feed'&gt;RSS Feed&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#layouts'&gt;Layouts&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#avoiding_a_layout'&gt;Avoiding a layout&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#in_file_views'&gt;In File Views&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#partials'&gt;Partials&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#models'&gt;Models&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#datamapper'&gt;Datamapper&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#sequel'&gt;Sequel&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#activerecord'&gt;ActiveRecord&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#helpers'&gt;Helpers&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#the_basics'&gt;The basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#implemention_of_rails_style_partials'&gt;Implemention of rails style partials&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#rack_middleware'&gt;Rack Middleware&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#error_handling'&gt;Error Handling&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#not_found'&gt;not_found&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#error'&gt;error&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#additional_information'&gt;Additional Information&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#configuration'&gt;Configuration&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#use_sinatras_set_option'&gt;Use Sinatra&amp;#8217;s &amp;#8220;set&amp;#8221; option&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#external_config_file_via_the_configure_block'&gt;External config file via the configure block&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#application_module__config_area'&gt;Application module / config area&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#deployment'&gt;Deployment&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#deployment_lighttpd'&gt;Lighttpd Proxied to Thin&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#deployment_passenger'&gt;Passenger (mod rails)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#deployment_fastcgi'&gt;FastCGI&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#heroku'&gt;Heroku&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#fuzed_and_amazon'&gt;Fuzed and Amazon&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#poolparty_and_amazon_ec2'&gt;Poolparty and Amazon EC2&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#contributing'&gt;Contributing&lt;/a&gt;&lt;ul style='list-style: none;'&gt;&lt;li&gt;&lt;a href='#how_can_i_clone_the_sinatra_repository'&gt;How can I clone the Sinatra repository?&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#how_to_create_a_patch'&gt;How to create a patch?&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#how_to_get_that_patch_into_the_official_sinatra'&gt;How to get that patch into the official Sinatra?&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;hr /&gt;
-&lt;h1 id='introduction'&gt;Introduction&lt;/h1&gt;
+&lt;h1&gt;The Book&lt;/h1&gt;
 
-&lt;h2 id='what_is_sinatra'&gt;What is Sinatra?&lt;/h2&gt;
-
-&lt;p&gt;Sinatra is a Domain Specific Language (DSL) for quickly creating web-applications in Ruby.&lt;/p&gt;
-
-&lt;p&gt;It keeps a minimal feature set, leaving the developer to use the tools that best suit them and their application.&lt;/p&gt;
-
-&lt;p&gt;It doesn&amp;#8217;t assume much about your application, apart from that:&lt;/p&gt;
-
-&lt;ul&gt;
-&lt;li&gt;it will be written in Ruby programming language&lt;/li&gt;
-
-&lt;li&gt;it will have URLs&lt;/li&gt;
-&lt;/ul&gt;
-
-&lt;p&gt;In Sinatra, you can write short &lt;em&gt;ad hoc&lt;/em&gt; applications or mature, larger application with the same easiness. (See section &amp;#8220;Real World Applications&amp;#8221; later in this book.)&lt;/p&gt;
-
-&lt;p&gt;You can use the power of various Rubygems and other libraries for Ruby available.&lt;/p&gt;
-
-&lt;p&gt;Sinatra really shines when used for experiments and application mock-ups or for creating a quick interface for your code.&lt;/p&gt;
-
-&lt;p&gt;It isn&amp;#8217;t a Model-View-Controller framework, but ties specific URL directly to relevant Ruby code and returns it&amp;#8217;s output in response. It does enable you, however, to write clean, properly organized applications: separating &lt;em&gt;views&lt;/em&gt; from application code, for instance.&lt;/p&gt;
-
-&lt;h2 id='installation'&gt;Installation&lt;/h2&gt;
-
-&lt;p&gt;The simplest way to obtain Sinatra is through Rubygems&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;$ sudo gem install sinatra&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h3 id='dependencies'&gt;Dependencies&lt;/h3&gt;
-
-&lt;p&gt;Sinatra depends on the &lt;em&gt;Rack&lt;/em&gt; gem (http://rack.rubyforge.org).&lt;/p&gt;
-
-&lt;p&gt;For optimal experience, you should also install the &lt;em&gt;Haml&lt;/em&gt; (http://haml.hamptoncatlin.com) and &lt;em&gt;Builder&lt;/em&gt; gem (http://builder.rubyforge.org), which simplifies working with views.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;$ sudo gem install builder haml&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h3 id='living_on_the_edge'&gt;Living on the Edge&lt;/h3&gt;
-
-&lt;p&gt;The &lt;em&gt;edge&lt;/em&gt; version of Sinatra lives in it&amp;#8217;s Git repository, available at &lt;strong&gt;http://github.com/sinatra/sinatra/tree/master&lt;/strong&gt;.&lt;/p&gt;
-
-&lt;p&gt;You can use the &lt;em&gt;edge&lt;/em&gt; version to try new functionality or to contribute to the framework. You need to have Git version control software installed (http://www.git-scm.com). Then follow these steps:&lt;/p&gt;
-
-&lt;ol&gt;
-&lt;li&gt;cd where/you/keep/your/projects&lt;/li&gt;
-
-&lt;li&gt;git clone git://github.com/sinatra/sinatra.git&lt;/li&gt;
-
-&lt;li&gt;cd sinatra&lt;/li&gt;
-
-&lt;li&gt;cd your_project&lt;/li&gt;
-
-&lt;li&gt;ln -s ../sinatra&lt;/li&gt;
-&lt;/ol&gt;
-
-&lt;p&gt;Then add this to your application:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;$:.unshift File.dirname(__FILE__) + &amp;#39;/sinatra/lib&amp;#39;
-require &amp;#39;sinatra&amp;#39;&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;You can check the version you are running by adding this route&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/about&amp;#39; do
-  &amp;quot;I&amp;#39;m running on Version &amp;quot; + Sinatra::VERSION
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;and loading &lt;code&gt;http://localhost:4567/about&lt;/code&gt; in your browser.&lt;/p&gt;
-
-&lt;h2 id='hello_world_application'&gt;Hello World Application&lt;/h2&gt;
-
-&lt;p&gt;Sinatra is installed and you&amp;#8217;re done eating cake, how about making your first application?&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;# hello_world.rb
-require &amp;#39;rubygems&amp;#39;
-require &amp;#39;sinatra&amp;#39;
-
-get &amp;#39;/&amp;#39; do
-  &amp;quot;Hello world, it&amp;#39;s #{Time.now} at the server!&amp;quot;
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;Run this application by &lt;code&gt;$ ruby hello_world.rb&lt;/code&gt; and load &lt;code&gt;http://localhost:4567&lt;/code&gt; in your browser.&lt;/p&gt;
-
-&lt;p&gt;As you can see, Sinatra doesn&amp;#8217;t force you to setup much infrastructure: a request to some URL (&lt;em&gt;root&lt;/em&gt; URL in this case) evaluates some Ruby code and returns some text in response.&lt;/p&gt;
-
-&lt;h2 id='real_world_applications_in_sinatra'&gt;Real World Applications in Sinatra&lt;/h2&gt;
-
-&lt;h3 id='github_services'&gt;Github Services&lt;/h3&gt;
-
-&lt;p&gt;Git hosting provider Github uses Sinatra for post-receive hooks, calling user specified services/URLs, whenever someone pushes to her repository:&lt;/p&gt;
-
-&lt;ul&gt;
-&lt;li&gt;http://github.com/blog/53-github-services-ipo&lt;/li&gt;
-
-&lt;li&gt;http://github.com/guides/post-receive-hooks&lt;/li&gt;
-
-&lt;li&gt;http://github.com/pjhyett/github-services&lt;/li&gt;
-&lt;/ul&gt;
-
-&lt;h3 id='git_wiki'&gt;Git Wiki&lt;/h3&gt;
-
-&lt;p&gt;Git Wiki is minimal Wiki engine powered by Sinatra and Git. See also various forks with additional functionality.&lt;/p&gt;
-
-&lt;ul&gt;
-&lt;li&gt;http://github.com/sr/git-wiki&lt;/li&gt;
-
-&lt;li&gt;http://github.com/sr/git-wiki/network&lt;/li&gt;
-&lt;/ul&gt;
-
-&lt;h3 id='integrity'&gt;Integrity&lt;/h3&gt;
-
-&lt;p&gt;Integrity is small and clean &lt;em&gt;continuous integration&lt;/em&gt; service using Sinatra, watching for failing builds of your codebase and notifying you by various channels.&lt;/p&gt;
-
-&lt;ul&gt;
-&lt;li&gt;http://www.integrityapp.com/&lt;/li&gt;
-
-&lt;li&gt;http://github.com/foca/integrity&lt;/li&gt;
-&lt;/ul&gt;
-
-&lt;h3 id='seinfeld_calendar'&gt;Seinfeld Calendar&lt;/h3&gt;
-
-&lt;p&gt;Seinfeld Calendar is a fun application tracking your contributions to open-source projects, displaying your &amp;#8220;streaks&amp;#8221;, ie. continuous commits to Github repositories.&lt;/p&gt;
-
-&lt;ul&gt;
-&lt;li&gt;http://www.calendaraboutnothing.com&lt;/li&gt;
-
-&lt;li&gt;http://github.com/entp/seinfeld&lt;/li&gt;
-&lt;/ul&gt;
-
-&lt;h2 id='about_this_book'&gt;About this book&lt;/h2&gt;
-
-&lt;p&gt;This book will assume you have a basic knowledge of the Ruby scripting language and a working Ruby interpreter.&lt;/p&gt;
-
-&lt;p&gt;For more information about the Ruby language visit the following links:&lt;/p&gt;
-
-&lt;ul&gt;
-&lt;li&gt;http://www.ruby-lang.org&lt;/li&gt;
-
-&lt;li&gt;http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/&lt;/li&gt;
-
-&lt;li&gt;http://www.ruby-doc.org&lt;/li&gt;
-
-&lt;li&gt;http://www.ruby-doc.org/core-1.8.7/index.html&lt;/li&gt;
-
-&lt;li&gt;http://www.ruby-doc.org/docs/ProgrammingRuby/&lt;/li&gt;
-&lt;/ul&gt;
-&lt;hr /&gt;
-&lt;h1 id='routes'&gt;Routes&lt;/h1&gt;
-
-&lt;h2 id='http_methods'&gt;HTTP methods&lt;/h2&gt;
-
-&lt;p&gt;Sinatra&amp;#8217;s routes are designed to respond to the HTTP request methods.&lt;/p&gt;
-
-&lt;ul&gt;
-&lt;li&gt;GET&lt;/li&gt;
-
-&lt;li&gt;POST&lt;/li&gt;
-
-&lt;li&gt;PUT&lt;/li&gt;
-
-&lt;li&gt;DELETE&lt;/li&gt;
-&lt;/ul&gt;
-
-&lt;h2 id='basic'&gt;Basic&lt;/h2&gt;
-
-&lt;p&gt;Simple&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/hi&amp;#39; do
-  ...
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;With params&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/:name&amp;#39; do
-  # matches /sinatra and the like and sets params[:name]
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='options'&gt;Options&lt;/h2&gt;
-
-&lt;h2 id='splats'&gt;Splats&lt;/h2&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/say/*/to/*&amp;#39; do
-  # matches /say/hello/to/world
-  params[&amp;quot;splat&amp;quot;] # =&amp;gt; [&amp;quot;hello&amp;quot;, &amp;quot;world&amp;quot;]
-end
-
-get &amp;#39;/download/*.*&amp;#39; do
-  # matches /download/path/to/file.xml
-  params[&amp;quot;splat&amp;quot;] # =&amp;gt; [&amp;quot;path/to/file&amp;quot;, &amp;quot;xml&amp;quot;]
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='user_agent'&gt;User agent&lt;/h2&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/foo&amp;#39;, :agent =&amp;gt; /Songbird (\d\.\d)[\d\/]*?/ do
-  &amp;quot;You&amp;#39;re using Songbird version #{params[:agent][0]}&amp;quot;
-end
-
-get &amp;#39;/foo&amp;#39; do
-  # matches non-songbird browsers
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='other_methods'&gt;Other methods&lt;/h2&gt;
-
-&lt;p&gt;Other methods are requested exactly the same as &amp;#8220;get&amp;#8221; routes. You simply use the &lt;code&gt;post&lt;/code&gt;, &lt;code&gt;put&lt;/code&gt;, or &lt;code&gt;delete&lt;/code&gt; functions to define the route, rather then the &lt;code&gt;get&lt;/code&gt; one. To access POSTed parameters, use &lt;code&gt;params[:xxx]&lt;/code&gt; where xxx is the name of the form element that was posted.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;post &amp;#39;/foo&amp;#39; do
-  &amp;quot;You just asked for foo, with post param bar equal to #{params[:bar]}&amp;quot;
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='the_put_and_delete_methods'&gt;The PUT and DELETE methods&lt;/h2&gt;
-
-&lt;p&gt;Since browsers don&amp;#8217;t natively support the PUT and DELETE methods, a hacky workaround has been adopted by the web community. Simply add a hidden element with the name &amp;#8220;_method&amp;#8221; and the value equal to the HTTP method you want to use. The form itself is sent as a POST, but Sinatra will interpret it as the desired method. For example:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;&amp;lt;form method=&amp;quot;post&amp;quot; action=&amp;quot;/destroy_it&amp;quot;&amp;gt;
-  &amp;lt;input name=&amp;quot;_method&amp;quot; value=&amp;quot;delete&amp;quot; /&amp;gt;
-  &amp;lt;div&amp;gt;&amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;Destroy it&amp;lt;/button&amp;gt;&amp;lt;/div&amp;gt;
-&amp;lt;/form&amp;gt;&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;When you want to use PUT or DELETE from a client that does support them (like Curl, or ActiveResource), just go ahead and use them as you normally would, and ignore the &lt;code&gt;_method&lt;/code&gt; advice above. That is only for hacking in support for browsers.&lt;/p&gt;
-
-&lt;h2 id='how_routes_are_looked_up'&gt;How routes are looked up&lt;/h2&gt;
-
-&lt;p&gt;Each time you add a new route to your application, it gets compiled down into a regular expression that will match it. That is stored in an array along with the handler block attached to that route.&lt;/p&gt;
-
-&lt;p&gt;When a new request comes in, each regex is run in turn, until one matches. Then the the handler (the code block) attached to that route gets executed.&lt;/p&gt;
-
-&lt;h2 id='splitting_into_multiple_files'&gt;Splitting into multiple files&lt;/h2&gt;
-
-&lt;p&gt;Because Sinatra clears out your routes and reloads your application on every request in development mode, you can&amp;#8217;t use require to load files containing your routes because these will only be loaded when the application starts (and reloaded even on the first request!) Instead, use &lt;a href='http://www.ruby-doc.org/core/classes/Kernel.html#M005966' title='Ruby RDoc: load'&gt;load&lt;/a&gt;:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;# application.rb
-require &amp;#39;rubygems&amp;#39;
-require &amp;#39;sinatra&amp;#39;
-
-get &amp;#39;/&amp;#39; do
-  &amp;quot;Hello world!&amp;quot;
-end
-
-load &amp;#39;more_routes.rb&amp;#39;&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;and&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;# more_routes.rb
-
-get &amp;#39;/foo&amp;#39; do
-  &amp;quot;Bar?  How unimaginative.&amp;quot;
-end&lt;/code&gt;&lt;/pre&gt;
-&lt;hr /&gt;
-&lt;h1 id='handlers'&gt;Handlers&lt;/h1&gt;
-
-&lt;h2 id='structure'&gt;Structure&lt;/h2&gt;
-
-&lt;p&gt;Handler is the generic term that Sinatra uses for the &amp;#8220;controllers&amp;#8221;. A handler is the initial point of entry for new HTTP requests into your application.&lt;/p&gt;
-
-&lt;p&gt;To find more about the routes, head to the Routes section (right above this one)&lt;/p&gt;
-
-&lt;h2 id='redirect'&gt;Redirect&lt;/h2&gt;
-
-&lt;p&gt;The redirect helper is a shortcut to a common http response code (302).&lt;/p&gt;
-
-&lt;p&gt;Basic usage is easy:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;redirect &amp;#39;/&amp;#39;
-
-redirect &amp;#39;/posts/1&amp;#39;
-
-redirect &amp;#39;http://www.google.com&amp;#39;&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;The redirect actually sends back a Location header to the browser, and the browser makes a followup request to the location indicated. Since the browser makes that followup request, you can redirect to any page, in your application, or another site entirely.&lt;/p&gt;
-
-&lt;p&gt;The flow of requests during a redirect is: Browser &#8594; Server (redirect to &amp;#8217;/&amp;#8217;) &#8594; Browser (request &amp;#8217;/&amp;#8217;) &#8594; Server (result for &amp;#8217;/&amp;#8217;)&lt;/p&gt;
-
-&lt;p&gt;To force Sinatra to send a different response code, it&amp;#8217;s very simple:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;redirect &amp;#39;/&amp;#39;, 303 # forces the 303 return code
-
-redirect &amp;#39;/&amp;#39;, 307 # forces the 307 return code&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='sessions'&gt;Sessions&lt;/h2&gt;
-
-&lt;h3 id='default_cookie_based_sessions'&gt;Default Cookie Based Sessions&lt;/h3&gt;
-
-&lt;p&gt;Sinatra ships with basic support for cookie based sessions. To enable it, in a configure block, or at the top of your application, you just need to enable the option.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;enable :sessions
-
-get &amp;#39;/&amp;#39; do
-  session[&amp;quot;counter&amp;quot;] ||= 0
-  session[&amp;quot;counter&amp;quot;] += 1
-
-  &amp;quot;You&amp;#39;ve hit this page #{session[&amp;quot;counter&amp;quot;]} time(s)&amp;quot;
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;The downside to this session approach is that all the data is stored in the cookie. Since cookies have a fairly hard limit of 4 kilobytes, you can&amp;#8217;t store much data. The other issue is that cookies are not tamper proof. The user can change any data in their session. But&amp;#8230; it is easy, and it doesn&amp;#8217;t have the scaling problems that memory or database backed sessions run into.&lt;/p&gt;
-
-&lt;h3 id='memory_based_sessions'&gt;Memory Based Sessions&lt;/h3&gt;
-
-&lt;h3 id='memcached_based_sessions'&gt;Memcached Based Sessions&lt;/h3&gt;
-
-&lt;h3 id='file_based_sessions'&gt;File Based Sessions&lt;/h3&gt;
-
-&lt;h3 id='database_based_sessions'&gt;Database Based Sessions&lt;/h3&gt;
-
-&lt;h2 id='cookies'&gt;Cookies&lt;/h2&gt;
-
-&lt;p&gt;Cookies are a fairly simple thing to use in Sinatra, but they have a few quirks.&lt;/p&gt;
-
-&lt;p&gt;Lets first look at the simple use case:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;require &amp;#39;rubygems&amp;#39;
-require &amp;#39;sinatra&amp;#39;
-
-get &amp;#39;/&amp;#39; do
-    # Get the string representation
-    cookie = request.cookies[&amp;quot;thing&amp;quot;]
-
-    # Set a default
-    cookie ||= 0
-
-    # Convert to an integer
-    cookie = cookie.to_i
-
-    # Do something with the value
-    cookie += 1
-
-    # Reset the cookie
-    set_cookie(&amp;quot;thing&amp;quot;, cookie)
-
-    # Render something
-    &amp;quot;Thing is now: #{cookie}&amp;quot;
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;Setting a path, expiration date, or domain gets a little more complicated - see the source code for set_cookie if you want to dig deeper.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;set_cookie(&amp;quot;thing&amp;quot;, :domain =&amp;gt; myDomain,
-                    :path =&amp;gt; myPath,
-                    :expires =&amp;gt; Date.new)&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;That&amp;#8217;s the easy stuff with cookies - It can also serialize Array objects, separating them with ampersands (&amp;amp;), but when they come back, it doesn&amp;#8217;t deserialize or split them in any way, it hands you the raw, encoded string for your parsing pleasure.&lt;/p&gt;
-
-&lt;h2 id='status'&gt;Status&lt;/h2&gt;
-
-&lt;p&gt;If you want to set your own status response instead of the normal 200 (Success), you can use the &lt;code&gt;status&lt;/code&gt;-helper to set the code, and then still render normally:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/&amp;#39; do
-  status 404
-  &amp;quot;Not found&amp;quot;
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;Alternatively you can use &lt;code&gt;throw :halt, [404, &amp;quot;Not found&amp;quot;]&lt;/code&gt; to immediately stop any further actions and return the specified status code and string to the client. &lt;code&gt;throw&lt;/code&gt; supports more options in this regard, see the appropriate section for more info.&lt;/p&gt;
-
-&lt;h2 id='authentication'&gt;Authentication&lt;/h2&gt;
-&lt;hr /&gt;
-&lt;h1 id='filters'&gt;Filters&lt;/h1&gt;
-
-&lt;h2 id='before_do'&gt;before do&amp;#8230;&lt;/h2&gt;
-
-&lt;p&gt;These are run in Sinatra::EventContext&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;before do
-  # .. this code will run before each event ..
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='handling_of_rails_like_nested_params'&gt;Handling of Rails like nested params&lt;/h2&gt;
-
-&lt;p&gt;If you want to use a form with parameters like this (aka. Rails&amp;#8217; nested params):&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;&amp;lt;form&amp;gt;
-  &amp;lt;input ... name=&amp;quot;post[title]&amp;quot; /&amp;gt;
-  &amp;lt;input ... name=&amp;quot;post[body]&amp;quot; /&amp;gt;
-  &amp;lt;input ... name=&amp;quot;post[author]&amp;quot; /&amp;gt;
-&amp;lt;/form&amp;gt;&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;You have convert parameters to a hash. You can easily do this with a before filter:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;before do
-  new_params = {}
-  params.each_pair do |full_key, value|
-    this_param = new_params
-    split_keys = full_key.split(/\]\[|\]|\[/)
-    split_keys.each_index do |index|
-      break if split_keys.length == index + 1
-      this_param[split_keys[index]] ||= {}
-      this_param = this_param[split_keys[index]]
-   end
-   this_param[split_keys.last] = value
-  end
-  request.params.replace new_params
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;Then parameters became:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;{&amp;quot;post&amp;quot;=&amp;gt;{ &amp;quot;title&amp;quot;=&amp;gt;&amp;quot;&amp;quot;, &amp;quot;body&amp;quot;=&amp;gt;&amp;quot;&amp;quot;, &amp;quot;author&amp;quot;=&amp;gt;&amp;quot;&amp;quot; }}&lt;/code&gt;&lt;/pre&gt;
-&lt;hr /&gt;
-&lt;h1 id='views'&gt;Views&lt;/h1&gt;
-
-&lt;p&gt;All file-based views are looked up in:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;root
-  | - views/&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='template_languages'&gt;Template Languages&lt;/h2&gt;
-
-&lt;h3 id='haml'&gt;Haml&lt;/h3&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/&amp;#39; do
-  haml :index
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;This will render ./views/index.haml&lt;/p&gt;
-
-&lt;h3 id='sass'&gt;Sass&lt;/h3&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/&amp;#39; do
-  sass :styles
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;This will render ./views/styles.sass&lt;/p&gt;
-
-&lt;h3 id='erb'&gt;Erb&lt;/h3&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/&amp;#39; do
-  erb :index
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;This will render ./views/index.erb&lt;/p&gt;
-
-&lt;h3 id='builder'&gt;Builder&lt;/h3&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/&amp;#39; do
-  builder :index
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;This will render ./views/index.builder&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/&amp;#39; do
-  builder do |xml|
-    xml.node do
-      xml.subnode &amp;quot;Inner text&amp;quot;
-    end
-  end
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;This will render the xml inline, directly from the handler.&lt;/p&gt;
-
-&lt;h4 id='atom_feed'&gt;Atom Feed&lt;/h4&gt;
-
-&lt;h4 id='rss_feed'&gt;RSS Feed&lt;/h4&gt;
-
-&lt;p&gt;Assume that your site url is http://liftoff.msfc.nasa.gov/.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/rss.xml&amp;#39; do
-  builder do |xml|
-    xml.instruct! :xml, :version =&amp;gt; &amp;#39;1.0&amp;#39;
-    xml.rss :version =&amp;gt; &amp;quot;2.0&amp;quot; do
-      xml.channel do
-        xml.title &amp;quot;Liftoff News&amp;quot;
-        xml.description &amp;quot;Liftoff to Space Exploration.&amp;quot;
-        xml.link &amp;quot;http://liftoff.msfc.nasa.gov/&amp;quot;
-        
-        @posts.each do |post|
-          xml.item do
-            xml.title post.title
-            xml.link &amp;quot;http://liftoff.msfc.nasa.gov/posts/#{post.id}&amp;quot;
-            xml.description post.body
-            xml.pubDate Time.parse(post.created_at.to_s).rfc822()
-            xml.guid &amp;quot;http://liftoff.msfc.nasa.gov/posts/#{post.id}&amp;quot;
-          end
-        end
-      end
-    end
-  end
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;This will render the rss inline, directly from the handler.&lt;/p&gt;
-
-&lt;h2 id='layouts'&gt;Layouts&lt;/h2&gt;
-
-&lt;p&gt;Layouts are simple in Sinatra. Put a file in your views directory named &amp;#8220;layout.erb&amp;#8221;, &amp;#8220;layout.haml&amp;#8221;, or &amp;#8220;layout.builder&amp;#8221;. When you render a page, the appropriate layout will be grabbed (of the same filetype), and used.&lt;/p&gt;
-
-&lt;p&gt;The layout itself should call &lt;code&gt;yield&lt;/code&gt; at the point you want the content to be included.&lt;/p&gt;
-
-&lt;p&gt;An example haml layout file could look something like this:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;%html
-  %head
-    %title SINATRA BOOK
-  %body
-    #container
-      = yield&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='avoiding_a_layout'&gt;Avoiding a layout&lt;/h2&gt;
-
-&lt;dl&gt;
-&lt;dt&gt;Sometimes you don&amp;#8217;t want the layout rendered. In your render method just pass&lt;/dt&gt;
-
-&lt;dd&gt;
-&lt;p&gt;layout =&amp;gt; false, and you&amp;#8217;re good.&lt;/p&gt;
-
-&lt;p&gt;get &amp;#8217;/&amp;#8217; do haml :index, :layout =&amp;gt; false end&lt;/p&gt;
-&lt;/dd&gt;
-&lt;/dl&gt;
-
-&lt;h2 id='in_file_views'&gt;In File Views&lt;/h2&gt;
-
-&lt;p&gt;This one is cool:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/&amp;#39; do
-  haml :index
-end
-
-use_in_file_templates!
-
-__END__
-
-@@ layout
-X
-= yield
-X
-
-@@ index
-%div.title Hello world!!!!!&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;Try it!&lt;/p&gt;
-
-&lt;h2 id='partials'&gt;Partials&lt;/h2&gt;
-&lt;hr /&gt;
-&lt;h1 id='models'&gt;Models&lt;/h1&gt;
-
-&lt;h2 id='datamapper'&gt;Datamapper&lt;/h2&gt;
-
-&lt;h2 id='sequel'&gt;Sequel&lt;/h2&gt;
-
-&lt;h2 id='activerecord'&gt;ActiveRecord&lt;/h2&gt;
-
-&lt;p&gt;First require ActiveRecord gem in your app, then give your database connection settings:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;require &amp;#39;rubygems&amp;#39;
-require &amp;#39;sinatra&amp;#39;
-require &amp;#39;activerecord&amp;#39;
-
-ActiveRecord::Base.establish_connection(
-  :adapter =&amp;gt; &amp;#39;sqlite3&amp;#39;,
-  :dbfile =&amp;gt;  &amp;#39;sinatra_application.sqlite3.db&amp;#39;
-)&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;Now you can create and use ActiveRecord models just like in Rails (the example assumes you already have a &amp;#8216;posts&amp;#8217; table in your database):&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;class Post &amp;lt; ActiveRecord::Base
-end
-
-get &amp;#39;/&amp;#39; do
-  @posts = Post.all()
-  erb :index 
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;This will render ./views/index.html:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;&amp;lt;% for post in @posts %&amp;gt;
-  &amp;lt;h1&amp;gt;&amp;lt;% post.title %&amp;gt;&amp;lt;/h1&amp;gt;
-&amp;lt;% end %&amp;gt;&lt;/code&gt;&lt;/pre&gt;
-&lt;hr /&gt;
-&lt;h1 id='helpers'&gt;Helpers&lt;/h1&gt;
-
-&lt;h2 id='the_basics'&gt;The basics&lt;/h2&gt;
-
-&lt;p&gt;It is ill-advised to create helpers on the root level of your application. They muddy the global namespace, and don&amp;#8217;t have easy access to the request, response, session or cookie variables.&lt;/p&gt;
-
-&lt;p&gt;Instead, use the handy helpers method to install methods on &lt;code&gt;Sinatra::EventContext&lt;/code&gt; for use inside events and templates.&lt;/p&gt;
-
-&lt;p&gt;Example:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;helpers do
-  def bar(name)
-    &amp;quot;#{name}bar&amp;quot;
-  end
-end
-
-get &amp;#39;/:name&amp;#39; do
-  bar(params[:name])
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='implemention_of_rails_style_partials'&gt;Implemention of rails style partials&lt;/h2&gt;
-
-&lt;p&gt;Using partials in your views is a great way to keep them clean. Since Sinatra takes the hands off approach to framework design, you&amp;#8217;ll have to implement a partial handler yourself.&lt;/p&gt;
-
-&lt;p&gt;Here is a really basic version:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;# Usage: partial :foo
-helpers do
-  def partial(page, options={})
-    haml page, options.merge!(:layout =&amp;gt; false)
-  end
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;A more advanced version that would handle passing local options, and looping over a hash would look like:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;# Render the page once:
-# Usage: partial :foo
-# 
-# foo will be rendered once for each element in the array, passing in a local variable named &amp;quot;foo&amp;quot;
-# Usage: partial :foo, :collection =&amp;gt; @my_foos    
-
-helpers do
-  def partial(template, *args)
-    options = args.extract_options!
-    options.merge!(:layout =&amp;gt; false)
-    if collection = options.delete(:collection) then
-      collection.inject([]) do |buffer, member|
-        buffer &amp;lt;&amp;lt; haml(template, options.merge(
-                                  :layout =&amp;gt; false, 
-                                  :locals =&amp;gt; {template.to_sym =&amp;gt; member}
-                                )
-                     )
-      end.join(&amp;quot;\n&amp;quot;)
-    else
-      haml(template, options)
-    end
-  end
-end&lt;/code&gt;&lt;/pre&gt;
-&lt;hr /&gt;
-&lt;h1 id='rack_middleware'&gt;Rack Middleware&lt;/h1&gt;
-
-&lt;p&gt;Sinatra rides on &lt;a href='http://rack.rubyforge.org/'&gt;Rack&lt;/a&gt;, a minimal standard interface for Ruby web frameworks. One of Rack&#8217;s most interesting capabilities for application developers is support for &amp;#8220;middleware&amp;#8221; &amp;#8211; components that sit between the server and your application monitoring and/or manipulating the HTTP request/response to provide various types of common functionality.&lt;/p&gt;
-
-&lt;p&gt;Sinatra makes building Rack middleware pipelines a cinch via a top-level &lt;code&gt;use&lt;/code&gt; method:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;require &amp;#39;sinatra&amp;#39;
-require &amp;#39;my_custom_middleware&amp;#39;
-
-use Rack::Lint
-use MyCustomMiddleware
-
-get &amp;#39;/hello&amp;#39; do
-  &amp;#39;Hello World&amp;#39;
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;The semantics of &amp;#8220;use&amp;#8221; are identical to those defined for the &lt;a href='http://rack.rubyforge.org/doc/classes/Rack/Builder.html'&gt;Rack::Builder&lt;/a&gt; DSL (most frequently used from rackup files). For example, the use method accepts multiple/variable args as well as blocks:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;use Rack::Auth::Basic do |username, password|
-  username == &amp;#39;admin&amp;#39; &amp;amp;&amp;amp; password == &amp;#39;secret&amp;#39;
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;Rack is distributed with a variety of standard middleware for logging, debugging, URL routing, authentication, and session handling. Sinatra uses many of of these components automatically based on configuration so you typically don&#8217;t have to use them explicitly.&lt;/p&gt;
-&lt;hr /&gt;
-&lt;h1 id='error_handling'&gt;Error Handling&lt;/h1&gt;
-
-&lt;h2 id='not_found'&gt;not_found&lt;/h2&gt;
-
-&lt;p&gt;Remember: These are run inside the Sinatra::EventContext which means you get all the goodies is has to offer (i.e. haml, erb, :halt, etc.)&lt;/p&gt;
-
-&lt;p&gt;Whenever NotFound is raised this will be called&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;not_found do
-  &amp;#39;This is nowhere to be found&amp;#39;
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='error'&gt;error&lt;/h2&gt;
-
-&lt;p&gt;By default error will catch Sinatra::ServerError&lt;/p&gt;
-
-&lt;p&gt;Sinatra will pass you the error via the &#8216;sinatra.error&#8217; in request.env&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;error do
-  &amp;#39;Sorry there was a nasty error - &amp;#39; + request.env[&amp;#39;sinatra.error&amp;#39;].name
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;Custom error mapping:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;error MyCustomError do
-  &amp;#39;So what happened was...&amp;#39; + request.env[&amp;#39;sinatra.error&amp;#39;].message
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;then if this happens:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/&amp;#39; do
-  raise MyCustomError, &amp;#39;something bad&amp;#39;
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;you gets this:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;So what happened was... something bad&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='additional_information'&gt;Additional Information&lt;/h2&gt;
-
-&lt;p&gt;Because Sinatra give you a default not_found and error do :production that are secure. If you want to customize only for :production but want to keep the friendly helper screens for :development then do this:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;configure :production do
-  not_found do
-    &amp;quot;We&amp;#39;re so sorry, but we don&amp;#39;t what this is&amp;quot;
-  end
-
-  error do
-    &amp;quot;Something really nasty happened.  We&amp;#39;re on it!&amp;quot;
-  end
-end&lt;/code&gt;&lt;/pre&gt;
-&lt;hr /&gt;
-&lt;h1 id='configuration'&gt;Configuration&lt;/h1&gt;
-
-&lt;h2 id='use_sinatras_set_option'&gt;Use Sinatra&amp;#8217;s &amp;#8220;set&amp;#8221; option&lt;/h2&gt;
-
-&lt;p&gt;Configure blocks are not executed in the event context, and don&amp;#8217;t have access to the same instance variables. To store a piece of information that you want to access in your routes, use &lt;code&gt;set&lt;/code&gt;.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;configure :development do
-  set :dbname, &amp;#39;devdb&amp;#39;
-end
-
-configure :production do
-  set :dbname, &amp;#39;productiondb&amp;#39;
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;&amp;#8230;&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;get &amp;#39;/whatdb&amp;#39; do
-  &amp;#39;We are using the database named &amp;#39; + options.dbname
-end&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='external_config_file_via_the_configure_block'&gt;External config file via the configure block&lt;/h2&gt;
-
-&lt;h2 id='application_module__config_area'&gt;Application module / config area&lt;/h2&gt;
-&lt;hr /&gt;
-&lt;h1 id='deployment'&gt;Deployment&lt;/h1&gt;
-
-&lt;h2 id='deployment_lighttpd'&gt;Lighttpd Proxied to Thin&lt;/h2&gt;
-
-&lt;p&gt;This will cover how to deploy Sinatra to a load balanced reverse proxy setup using Lighttpd and Thin.&lt;/p&gt;
-
-&lt;ol&gt;
-&lt;li&gt;
-&lt;p&gt;Install Lighttpd and Thin&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;# Figure out lighttpd yourself, it should be handled by your 
-# linux distro&amp;#39;s package manager
- 
-# For thin:
-gem install thin&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-
-&lt;li&gt;
-&lt;p&gt;Create your rackup file &amp;#8211; the &lt;code&gt;require &amp;#39;app&amp;#39;&lt;/code&gt; line should require the actual Sinatra app you have written.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;require &amp;#39;rubygems&amp;#39;
-require &amp;#39;sinatra&amp;#39;
-
-set :env,       :production
-set :port,      4567
-disable :run, :reload
-
-require &amp;#39;app&amp;#39;
-
-run Sinatra.application&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-
-&lt;li&gt;
-&lt;p&gt;Setup a config.yml - change the /path/to/my/app path to reflect reality.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;---
-  environment: production
-  chdir: /path/to/my/app
-  address: 127.0.0.1
-  user: root
-  group: root
-  port: 4567
-  pid: /path/to/my/app/thin.pid
-  rackup: /path/to/my/app/config.ru
-  log: /path/to/my/app/thin.log
-  max_conns: 1024
-  timeout: 30
-  max_persistent_conns: 512
-  daemonize: true&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-
-&lt;li&gt;
-&lt;p&gt;Setup lighttpd.conf - change mydomain to reflect reality. Also make sure the first port here matches up with the port setting in config.yml.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;$HTTP[&amp;quot;host&amp;quot;] =~ &amp;quot;(www\.)?mydomain\.com&amp;quot;  {
-        proxy.balance = &amp;quot;fair&amp;quot;
-        proxy.server =  (&amp;quot;/&amp;quot; =&amp;gt;
-                                (
-                                        ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;127.0.0.1&amp;quot;, &amp;quot;port&amp;quot; =&amp;gt; 4567 ),
-                                        ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;127.0.0.1&amp;quot;, &amp;quot;port&amp;quot; =&amp;gt; 4568 )
-                                )
-                        )
-}&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-
-&lt;li&gt;
-&lt;p&gt;Start thin and your application. I have a rake script so I can just call &amp;#8220;rake start&amp;#8221; rather than typing this in.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;thin -s 2 -C config.yml -R config.ru start&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-&lt;/ol&gt;
-
-&lt;p&gt;You&amp;#8217;re done! Go to mydomain.com/ and see the result! Everything should be setup now, check it out at the domain you setup in your lighttpd.conf file.&lt;/p&gt;
-
-&lt;p&gt;&lt;em&gt;Variation&lt;/em&gt; - nginx via proxy - The same approach to proxying can be applied to the nginx web server&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;upstream www_mydomain_com {
-  server 127.0.0.1:5000;
-  server 127.0.0.1:5001;
-}
-
-server {
-  listen    www.mydomain.com:80
-  server_name  www.mydomain.com live;
-  access_log /path/to/logfile.log
-  
-  location / {
-    proxy_pass http://www_mydomain_com;
-  }
-  
-}&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;&lt;em&gt;Variation&lt;/em&gt; - More Thin instances - To add more thin instances, change the &lt;code&gt;-s 2&lt;/code&gt; parameter on the thin start command to be how ever many servers you want. Then be sure lighttpd proxies to all of them by adding more lines to the proxy statements. Then restart lighttpd and everything should come up as expected.&lt;/p&gt;
-
-&lt;h2 id='deployment_passenger'&gt;Passenger (mod rails)&lt;/h2&gt;
-
-&lt;p&gt;Hate deployment via FastCGI? You&amp;#8217;re not alone. But guess what, Passenger supports Rack; and this book tells you how to get it all going.&lt;/p&gt;
-
-&lt;p&gt;You can find additional documentation at the Passenger Github repository.&lt;/p&gt;
-
-&lt;ol&gt;
-&lt;li&gt;
-&lt;p&gt;Setting up the account in the Dreamhost interface&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;Domains -&amp;gt; Manage Domains -&amp;gt; Edit (web hosting column)
-Enable &amp;#39;Ruby on Rails Passenger (mod_rails)&amp;#39;
-Add the public directory to the web directory box. So if you were using &amp;#39;rails.com&amp;#39;, it would change to &amp;#39;rails.com/public&amp;#39;
-Save your changes&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-
-&lt;li&gt;
-&lt;p&gt;Creating the directory structure&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;domain.com/
-domain.com/tmp
-domain.com/public
-# a vendored version of sinatra - not necessary if you use the gem
-domain.com/sinatra&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-
-&lt;li&gt;
-&lt;p&gt;Creating the &amp;#8220;Rackup file&amp;#8221; (rack configuration file) &lt;code&gt;config.ru&lt;/code&gt; &amp;#8211; the &lt;code&gt;require &amp;#39;app&amp;#39;&lt;/code&gt; line should require the actual Sinatra app you have written.&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;# This file goes in domain.com/config.ru
-require &amp;#39;rubygems&amp;#39;
-require &amp;#39;sinatra&amp;#39;
- 
-set :env,  :production
-disable :run
-
-require &amp;#39;app&amp;#39;
-
-run Sinatra.application&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-
-&lt;li&gt;
-&lt;p&gt;A very simple Sinatra application&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;# this is test.rb referred to above
-get &amp;#39;/&amp;#39; do
-  &amp;quot;Worked on dreamhost&amp;quot;
-end
- 
-get &amp;#39;/foo/:bar&amp;#39; do
-  &amp;quot;You asked for foo/#{params[:bar]}&amp;quot;
-end&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-&lt;/ol&gt;
-
-&lt;p&gt;And that&amp;#8217;s all there is to it! Once it&amp;#8217;s all setup, point your browser at your domain, and you should see a &amp;#8216;Worked on Dreamhost&amp;#8217; page. To restart the application after making changes, you need to run &lt;code&gt;touch tmp/restart.txt&lt;/code&gt;.&lt;/p&gt;
-
-&lt;p&gt;Please note that currently passenger 2.0.3 has a bug where it can cause Sinatra to not find the view directory. In that case, add &lt;code&gt;:views =&amp;gt; &amp;#39;/path/to/views/&amp;#39;&lt;/code&gt; to the Sinatra options in your Rackup file.&lt;/p&gt;
-
-&lt;p&gt;Additional note: some documentation sources will have a different format for passing options to Sinatra in the Rackup file, e.g.:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;Sinatra::Application.default_options.merge!(
-  :run =&amp;gt; false,
-  :env =&amp;gt; :production,
-  :raise_errors =&amp;gt; true
-)&lt;/code&gt;&lt;/pre&gt;
-
-&lt;p&gt;This is perfectly valid, however calling &lt;code&gt;set&lt;/code&gt;, &lt;code&gt;disable&lt;/code&gt; and &lt;code&gt;enable&lt;/code&gt; is preferred.&lt;/p&gt;
-
-&lt;h2 id='deployment_fastcgi'&gt;FastCGI&lt;/h2&gt;
-
-&lt;p&gt;The standard method for deployment is to use Thin or Mongrel, and have a reverse proxy (lighttpd, nginx, or even Apache) point to your bundle of servers.&lt;/p&gt;
-
-&lt;p&gt;But that isn&amp;#8217;t always possible. Cheaper shared hosting (like Dreamhost) won&amp;#8217;t let you run Thin or Mongrel, or setup reverse proxies (at least on the default shared plan).&lt;/p&gt;
-
-&lt;p&gt;Luckily, Rack supports various connectors, including CGI and FastCGI. Unluckily for us, FastCGI doesn&amp;#8217;t quite work with the current Sinatra release.&lt;/p&gt;
-
-&lt;p&gt;To get a simple &amp;#8216;hello world&amp;#8217; Sinatra application up and running on Dreamhost involves pulling down the current Sinatra code, and hacking at it a bit. Don&amp;#8217;t worry though, it only requires commenting out a few lines, and tweaking another.&lt;/p&gt;
-
-&lt;p&gt;Steps to deploy via FastCGI:&lt;/p&gt;
-
-&lt;ul&gt;
-&lt;li&gt;.htaccess&lt;/li&gt;
-
-&lt;li&gt;dispatch.fcgi&lt;/li&gt;
-
-&lt;li&gt;Tweaked sinatra.rb&lt;/li&gt;
-&lt;/ul&gt;
-
-&lt;ol&gt;
-&lt;li&gt;
-&lt;p&gt;.htaccess RewriteEngine on&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;AddHandler fastcgi-script .fcgi
-Options +FollowSymLinks +ExecCGI
- 
-RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-
-&lt;li&gt;
-&lt;p&gt;dispatch.fcgi&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;#!/usr/bin/ruby
- 
-require &amp;#39;rubygems&amp;#39;
-require &amp;#39;sinatra/lib/sinatra&amp;#39;
- 
-fastcgi_log = File.open(&amp;quot;fastcgi.log&amp;quot;, &amp;quot;a&amp;quot;)
-STDOUT.reopen fastcgi_log
-STDERR.reopen fastcgi_log
-STDOUT.sync = true
- 
-set :logging, false
-set :server, &amp;quot;FastCGI&amp;quot;
- 
-module Rack
-  class Request
-    def path_info
-      @env[&amp;quot;REDIRECT_URL&amp;quot;].to_s
-    end
-    def path_info=(s)
-      @env[&amp;quot;REDIRECT_URL&amp;quot;] = s.to_s
-    end
-  end
-end
- 
-load &amp;#39;app.rb&amp;#39;&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-
-&lt;li&gt;
-&lt;p&gt;sinatra.rb - Replace this function with the new version here (commenting out the &lt;code&gt;puts&lt;/code&gt; lines)&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;def run
-  begin
-    #puts &amp;quot;== Sinatra has taken the stage on port #{port} for #{env} with backup by #{server.name}&amp;quot;
-    require &amp;#39;pp&amp;#39;
-    server.run(application) do |server|
-      trap(:INT) do
-        server.stop
-        #puts &amp;quot;\n== Sinatra has ended his set (crowd applauds)&amp;quot;
-      end
-    end
-  rescue Errno::EADDRINUSE =&amp;gt; e
-    #puts &amp;quot;== Someone is already performing on port #{port}!&amp;quot;
-  end
-end&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-&lt;/ol&gt;
-
-&lt;h2 id='heroku'&gt;Heroku&lt;/h2&gt;
-
-&lt;p&gt;&lt;a href='http://www.heroku.com'&gt;Heroku&lt;/a&gt; has added basic support for Sinatra applications. This is possibly the easiest deployment option as once correctly configured,&lt;br /&gt;deploying to Heroku becomes simply a matter of pushing to git&lt;/p&gt;
-
-&lt;p&gt;Steps to deploy to Heroku:&lt;/p&gt;
-
-&lt;ul&gt;
-&lt;li&gt;make a config/rackup.ru&lt;/li&gt;
-
-&lt;li&gt;push to git&lt;/li&gt;
-&lt;/ul&gt;
-
-&lt;ol&gt;
-&lt;li&gt;
-&lt;p&gt;An example rackup file&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;set :app_file, File.expand_path(File.dirname(__FILE__) + &amp;#39;/../my_sinatra_app.rb&amp;#39;)
-set :public,   File.expand_path(File.dirname(__FILE__) + &amp;#39;/../public&amp;#39;)
-set :views,    File.expand_path(File.dirname(__FILE__) + &amp;#39;/../views&amp;#39;)
-set :env,      :production
-disable :run, :reload
-
-require File.dirname(__FILE__) + &amp;quot;/../my_sinatra_app&amp;quot;
-
-run Sinatra.application&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-
-&lt;li&gt;
-&lt;p&gt;push to git&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;$ git remote add heroku git@heroku.com:my-sinatra-app.git
-$ git push heroku master&lt;/code&gt;&lt;/pre&gt;
-&lt;/li&gt;
-&lt;/ol&gt;
-
-&lt;h2 id='fuzed_and_amazon'&gt;Fuzed and Amazon&lt;/h2&gt;
-
-&lt;p&gt;// TODO: Talk with Blake about this.&lt;/p&gt;
-
-&lt;h2 id='poolparty_and_amazon_ec2'&gt;Poolparty and Amazon EC2&lt;/h2&gt;
-
-&lt;p&gt;// TODO: What other deployment strategies are there?&lt;/p&gt;
-&lt;hr /&gt;
-&lt;h1 id='contributing'&gt;Contributing&lt;/h1&gt;
-
-&lt;h2 id='how_can_i_clone_the_sinatra_repository'&gt;How can I clone the Sinatra repository?&lt;/h2&gt;
-
-&lt;p&gt;First of all, you&amp;#8217;ll need the &lt;a href='http://git.or.cz'&gt;Git&lt;/a&gt; version control system. &lt;a href='http://git.or.cz'&gt;Git&lt;/a&gt; is available for all major platforms:&lt;/p&gt;
-
-&lt;ul&gt;
-&lt;li&gt;&lt;a href='http://code.google.com/p/msysgit/'&gt;Windows&lt;/a&gt;&lt;/li&gt;
-
-&lt;li&gt;&lt;a href='http://code.google.com/p/git-osx-installer/'&gt;Mac OS X&lt;/a&gt;&lt;/li&gt;
-
-&lt;li&gt;Linux and BSD users can usually acquire &lt;a href='http://git.or.cz'&gt;Git&lt;/a&gt; through their Package Management System, e.g. &lt;code&gt;apt-get install git-core&lt;/code&gt; on Debian systems.&lt;/li&gt;
-&lt;/ul&gt;
-
-&lt;p&gt;After that, cloning the Sinatra repository is as easy as typing the following into your command line:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;git clone git://github.com/bmizerany/sinatra.git&lt;/code&gt;&lt;/pre&gt;
-
-&lt;h2 id='how_to_create_a_patch'&gt;How to create a patch?&lt;/h2&gt;
-
-&lt;h2 id='how_to_get_that_patch_into_the_official_sinatra'&gt;How to get that patch into the official Sinatra?&lt;/h2&gt;
+{% include book.html %}</diff>
      <filename>book.html</filename>
    </modified>
    <modified>
      <diff>@@ -149,9 +149,6 @@ hr {
   padding:0;
   color:#eee;
 }
-.maruku_toc {
-  margin:1em 0;
-}
 
 /* HOME */
 
@@ -237,8 +234,19 @@ p.meta {
 /* ABOUT PAGE */
 
 body#about ul li{
-  margin-bottom: 10px;
+  margin-bottom:20px;
 }
-body#about ul strong {
+body#about #content strong, body#about #content a {
   font-weight:bold;
 }
+
+/* THE BOOK */
+#book .maruku_toc {
+  margin:1em 0;
+}
+#book .maruku_toc ul:first-child {
+  padding-left:0;
+}
+#book pre {
+  overflow:auto;
+}</diff>
      <filename>css/legend.css</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9c2751372082ce30053ebeb523e2552f5bba10a8</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Tomayko</name>
    <email>rtomayko@gmail.com</email>
  </author>
  <url>http://github.com/sinatra/sinatra.github.com/commit/c32d7637a10b860e8ffba142e841f38930c6520f</url>
  <id>c32d7637a10b860e8ffba142e841f38930c6520f</id>
  <committed-date>2009-01-29T01:30:03-08:00</committed-date>
  <authored-date>2009-01-29T01:24:05-08:00</authored-date>
  <message>Build book under _includes and include it from book.html

Also, fix overflow issues on pre blocks in book by showing the
scrollbar.</message>
  <tree>59edc479aa6b603c62a162b131581c80453d6fa5</tree>
  <committer>
    <name>Ryan Tomayko</name>
    <email>rtomayko@gmail.com</email>
  </committer>
</commit>
