anne001
6/14/2006 4:44:00 PM
For now I have a program with Nitro which maps a relative link to a
method
in the controller folder I have a main.rb file
class Main
def index
@title = "Erb Example"
@body = task1 + task2
@urlname = "better still"
@urladd = "alternate"
emit
end
def alternate
@title = "Advanced Example"
@body = task2 + task1
@urlname = "return"
@urladd = "index"
emit
end
private
def task1
return "1"
end
def task2
return "2"
end
def emit
template = ERB.new( html )
template.result(binding)
end
def html
"<html><head><title><%=@title %></title></head>
<body>
<%= @body %>
<a href=<%= @urladd %>> <%= @urlname %></a>
</body></html>"
end
end
in the main directory a file run.rb
#!/usr/bin/env ruby
require 'nitro'
require 'erb'
require 'controller/main'
Nitro.run(Main)
which I run from unix with ruby -rubygems run.rb
I have not shown I could do this with .htaccess, but I am assuming
there must be
ways like that to hard wire this type of behavior.
So at one end, a hardwired solution, at the other end, complex
frameworks, rails, nitro.
Can this be done more lightly, in software without framework? with cgi,
erb or eruby?