On Thu, 21 Sep 2006, James Britt wrote:

>> ERb looks like the ticket, but there's a missing link (for me). I can
>> write a ruby script that generates an rhtml file, but then how do I
>> serve that rhtml file without a framework like
>> Rails/Nitro/Camping/etc.? Probably the answer is with Webrick somehow,
>> but I'm missing the connection. I can't find a simple tutorial anywhere
>> online, and I'm no expert on web applications.
>
> I've an example of this that's ~100 lines of code, if you're interested.
>
> Maps URLs to classes and templates and renders them, using erb and Webrick.

I'd like to see it, just because I might find it educational.

I've also been wondering if framework support for this sort of thing, but 
very simple to setup, would be useful to people?

Something akin to this:

app.rb
-----
require 'iowa'

Iowa.run
-----


app.cnf
-----
socket:
   hostname: foo.bar.com
   port: 3000
application:
   dispatcher:
     class: StandardDispatcher
     mapfile: mapfile.cnf
-----


mapfile.cnf:
-----
:map:
   /index.html: Index
   /form.html: Myform
   /response.html: Myresponse
-----


If one had an index.rhtml, myform.rhtml, and myresponse.rhtml, they would 
be mapped to classes Index, Myform, and Myresponse, and requests for the 
urls above would go to the class in question and be rendered as an erb 
template.

You'd run it with:

ruby app.rb -r webrick
or
ruby app.rb -r mongrel

No other code or config necessary to serve those rhtml files.  Would 
anyone use this ability (as I personally would not).  Worth my time to 
make the above work?



Kirk haines