1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
Classy web-development dressed in a DSL (official / canonical repo)
Find a file
2007-10-23 15:42:00 -07:00
examples Discontinuing use of production/staging/test config methods because of conflict with other libs such as Sequel. 2007-10-22 18:59:15 -07:00
files * Pretty up default pages 2007-10-01 20:56:34 -07:00
lib Discontinuing use of production/staging/test config methods because of conflict with other libs such as Sequel. 2007-10-22 18:59:15 -07:00
site site updated for digg 2007-10-05 10:58:11 -07:00
test FIX: StaticEvents should ignore directories during path recognition 2007-10-22 18:47:57 -07:00
vendor docs 2007-10-04 15:40:12 -07:00
.gitignore ignores 2007-10-07 15:46:44 -07:00
CHANGELOG getting ready for release 2007-10-23 15:42:00 -07:00
LICENSE docs 2007-10-04 15:40:12 -07:00
Manifest getting ready for release 2007-10-23 15:42:00 -07:00
RakeFile getting ready for release 2007-10-23 15:42:00 -07:00
README getting ready for release 2007-10-23 15:42:00 -07:00

Sinatra (C) 2007 By Blake Mizerany

= Classy web-development dressed in a DSL

== Install!

  sudo gem install sinatra -y

== Use!

I'm going to move quick.  I'll let you drool at your own pace.

* Create a file called lyrics.rb (or any name you like)

* Add
    require 'rubygems'
    require 'sinatra'

* Run (yes, with just ruby)
    % ruby lyrics.rb
    == Sinata has taken the stage on port 4567!

* Take a moment and view the default page http://localhost:4567.  Go ahead and bask in it's glory.

* Notice:
  * It didn't create any page to show you that default page (just a cool thing to see, that's all)
  * There was nothing generated other than a log file
  * Sinatra is a really cool name for a web-framework that's a DSL

* Modify lyrics.rb by adding:
    get '/' do
      'Hello World'
    end
  
* Refresh (no need to restart Sinatra):
    http://localhost:4567

* Modify again (then refresh):
    get '/' do
      <<-HTML
        <form action='/' method="POST">
          <input type="text" name="name" />
          <input type="submit" value="Say my name!" />
        </form>
      HTML
    end
  
    post '/' do
      "Hello #{params[:name] || 'World'}!"
    end

* Now you try:
  Use the Sinatra::Erb::EventContext or Sinatra::Haml::EventContext to do the same.  Do them inline and as template files.

* Learn more cool stuff:
  see Sinatra::Dsl

* Create your own plugins!
  1. Create a 'vendor' directory in your app directory
  2. Lay it out like:

     myapp.rb : root
        |- vendor
		     | - plugin_name
                   | - init.rb  # load and hook here
                   | - lib
                         |- modules/classes here

  3. Use it in your app!

  see $SINATRA_GEM_ROOT/vendor/erb or $SINATRA_GEM_ROOT/vendor/erb for examples.

* Tell!
We would love to here what you're doing with Sinatra and any cool patches/features you would like.  (blake { dot } mizerany [ at ] gmail)

* Talk!
IRC (irc.freenode.com  #sinatra)
Mailing List (sinatrarb@googlegroups.com)

* Contribute

We're using git as our scm.. cuz.. it rocks.  You can get the latest source from http://repo.or.cz/w/sinatra.git

NOTE: You can also get tar'd snapshots of each commit there too.  So technically you don't need git to get the latest code.

It's probably going to happen.. you'll find a bug.  Please help by:

* Sending a message to sintrarb@googlegroups.com with BUG: at the start of the subject (I'm working on a better tracking system)
* Please send patches or pull requests to (blake { dot } mizerany [ at ] gmail) don't forget the dot com. ;)

== Thanks!

- Ezra Zygmuntowicz (http://brainspl.at) for answering all those random questions over IM and all the poached code
- Ditto to Chris Wanstrath (errtheblog.com) and helping me keep things simple, and some cool tricks
- Ari Lerner over at CitrusByte for ideas, code, and enthusiasm
- Christian Neukirchen for Rack (http://rack.rubyforge.org/)
- Koshi (http://www.songbirdnest.com/jkoshi/blog) here at POTI, Inc. for the Sinatra mark
- Pete Golibersuch for the hat logo
- John Philip Green (http://www.linkedin.com/in/johngreen) for motivation and evangelism
- The team here at songbirdnest.com for cool ideas