Changeset 2

Show
Ignore:
Timestamp:
10/10/06 15:14:38 (2 years ago)
Author:
e.@brainspl.at
Message:

update readme

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • README.txt

    r1 r2  
    11Merb. Mongrel+Erb 
     2 
     3Little bitty lightweight ruby app server. FOr when you really need performance 
     4for simple dynamic pages. 
     5 
     6**FEATURES** 1. Mongrel handler built in that parses incoming requests 
     7including multipart uploads and post as well as ?query=strings. Puts the 
     8params into @params and the cookies into @cookies when it instantiates your 
     9controller class. 
     10 
     112. Dead simple routing mechanism. You can define regex routes or rely on the 
     12handler to map urls to classes. By default it maps /example/hello/world to 
     13Example.new.hello('world') and returns the Erb template that your simple 
     14controller classes return. But you can also use the RouteMatcher for more 
     15complex mappings. 
     16 
     17ROUTES = Merb::RouteMatcher.new do |r|  
     18  r.add /foo\/bar/, :class => 'Qux', :method => 'spiffy'  
     19  r.add /test\/hello/, :class => 'Neebler', :method => 'wibble'  
     20end 
     21 
     22These routes are checked in order that you add them and the first one found is 
     23used. If no routes match it falls back to the defaults mapping. It passes 
     24extra url parts to your method as args. So with the routes defined above this 
     25is the route map. 
     26 
     27/foo/bar/baz/12 --> Qux.new.spiffy('baz', '12') 
     28 
     293. Simple controller classes with built in render method and template handling 
     30with instance vars available in the views automatically. 
     31 
     32class Test < Merb::Controller  
     33  template_dir :test 
     34 
     35  def hello(*names)  
     36    # @params and @cookies are avaialable here. string  
     37    # keys and not symbols just yet.  
     38    # Assign the parameter to an instance variable  
     39    @name = names.join(', ')  
     40    render  
     41  end  
     42end 
     43 
     44<html>  
     45  <head>  
     46    <title>Hello, <%= @name %></title>  
     47  </head>  
     48  <body>  
     49    <h1><%= @params.inspect %></h1>  
     50    <h1><%= @cookies.inspect %></h1> 
     51    <% 5.times do %> 
     52      <h1>Hello, <%= @name %>!</h1>  
     53    <% end %>  
     54  </body>  
     55</html> 
     56 
     574. the server. right now you add your routes and the port number and such in 
     58the server.rb file. will be split out into a config file in next release. So 
     59by default it runs on port 4000 
     60 
     61$ ruby server.rb