You are previewing Sinatra: Up and Running.
O'Reilly logo
Sinatra: Up and Running

Book Description

Sinatra gives developers a small but powerful and scalable framework for building web applications with Ruby. This introduction gets readers started, helping them to build, install, and polish a first application. It also explores how Sinatra fits in the web application ecosystem, especially in comparison to its far larger cousin, Ruby on Rails.

Table of Contents

  1. Sinatra: Up and Running
  2. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  3. Preface
    1. Who This Book Is For
    2. How This Book Is Organized
      1. The Basics
      2. Digging Deeper
      3. Hands On
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
  4. 1. Taking the Stage
    1. Characteristics of Sinatra
      1. Is It a Framework?
      2. Does It Implement MVC?
      3. Who’s Using It?
      4. What Does a Production Project Look Like?
      5. What’s the Catch?
      6. Are These Skills Transferrable?
    2. Installation
      1. Thin
    3. Up and Running
      1. Breaking Down the Syntax
      2. Testing with Telnet
    4. Rock, Paper, Scissors or “The Shape of Things to Come”
    5. Summary
  5. 2. Fundamentals
    1. Routing
      1. Hypertext Transfer Protocol
      2. Verbs
      3. Common Route Definition
      4. Many URLs, Similar Behaviors
      5. Routes with Parameters
      6. Routes with Query String Parameters
      7. Routes with Wildcards
      8. The First Sufficient Match Wins
      9. Routes with Regular Expressions
      10. Halting a Request
      11. Passing a Request
      12. Redirecting a Request
    2. Static Files
    3. Views
      1. Inline Templates
      2. External View Files
        1. External Views in Subfolders
      3. Passing Data into Views
    4. Filters
    5. Handling Errors
      1. 404 Not Found
      2. 500 Internal Server Error
    6. Configuration
    7. HTTP Headers
      1. The headers Method
      2. Exploring the request Object
    8. Caching
      1. Setting Headers Manually
      2. Settings Headers via expires
      3. ETags
        1. Generating ETags
        2. Weak ETags
    9. Sessions
      1. Destroying a Session
    10. Cookies
    11. Attachments
    12. Streaming
      1. Keeping the Connection Open
      2. Finite Streaming
    13. Summary
  6. 3. A Peek Behind the Curtain
    1. Application and Delegation
      1. The Inner Self
      2. Where Does get Come From?
      3. Exploring the Implementation
    2. Helpers and Extensions
      1. Creating Sinatra Extensions
      2. Helpers
        1. Helpers Without Modules
      3. Combining Helpers and Extensions
    3. Request and Response
      1. Rack
      2. Sinatra Without Sinatra
    4. Rack It Up
      1. Middleware
      2. Sinatra and Middleware
    5. Dispatching
      1. Dispatching Redux
      2. Changing Bindings
    6. Summary
  7. 4. Modular Applications
    1. Subclassing Sinatra
      1. Running Modular Applications
        1. Using run!
        2. With rackup
      2. About Settings
        1. Settings and Classes
      3. Subclassing Subclasses
        1. Route Inheritance
        2. Architecture
      4. Dynamic Subclass Generation
    2. Better Rack Citizenship
      1. Chaining Classes
        1. Middleware Chain
        2. Cascade
        3. With a Router
      2. On Return Values
      3. Using Sinatra as Router
    3. Extensions and Modular Applications
      1. Helpers
      2. Extensions
    4. Summary
  8. 5. Hands On: Your Own Blog Engine
    1. Workflow Concept
      1. File-Based Posts
      2. Git for Distribution
      3. Semistatic Pages
    2. The Implementation
      1. Displaying Blog Posts
        1. Rendering Markdown
        2. Generating articles
        3. Adding an index
        4. Adding a basic layout
      2. Git Integration
        1. Regenerating content
        2. Pulling changes
        3. Proper cache headers
      3. Glueing Everything Together
        1. Rack It Up!
        2. Setting it up on GitHub
        3. Setting it up on Bitbucket
        4. Using a post-receive hook
        5. What about Heroku?
    3. Summary
  9. About the Authors
  10. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  11. Copyright