2009-07-19 10:24:19 -04:00
|
|
|
$:.push "rails/activesupport/lib"
|
|
|
|
$:.push "rails/actionpack/lib"
|
|
|
|
|
|
|
|
require "action_controller"
|
|
|
|
|
2009-08-06 18:50:22 -04:00
|
|
|
class Kaigi < ActionController::Metal
|
2009-07-19 10:24:19 -04:00
|
|
|
include AbstractController::Callbacks
|
|
|
|
include ActionController::RackConvenience
|
2009-08-06 17:48:48 -04:00
|
|
|
include ActionController::RenderingController
|
2009-07-19 10:24:19 -04:00
|
|
|
include ActionController::Layouts
|
|
|
|
include ActionView::Context
|
|
|
|
|
|
|
|
before_filter :set_name
|
|
|
|
append_view_path "views"
|
|
|
|
|
2009-08-06 18:45:40 -04:00
|
|
|
def view_context
|
2009-07-19 10:24:19 -04:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def controller
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
DEFAULT_LAYOUT = Object.new.tap {|l| def l.render(*) yield end }
|
|
|
|
|
2009-08-06 18:43:28 -04:00
|
|
|
def render_template(template, layout = DEFAULT_LAYOUT, options = {}, partial = false)
|
2009-07-19 10:24:19 -04:00
|
|
|
ret = template.render(self, {})
|
|
|
|
layout.render(self, {}) { ret }
|
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
|
|
|
render :template => "template"
|
|
|
|
end
|
|
|
|
|
|
|
|
def alt
|
|
|
|
render :template => "template", :layout => "alt"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def set_name
|
|
|
|
@name = params[:name]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
app = Rack::Builder.new do
|
|
|
|
map("/kaigi") { run Kaigi.action(:index) }
|
|
|
|
map("/kaigi/alt") { run Kaigi.action(:alt) }
|
|
|
|
end.to_app
|
|
|
|
|
2009-08-06 17:48:48 -04:00
|
|
|
Rack::Handler::Mongrel.run app, :Port => 3000
|