lib/susanoo/application.rb in susanoo-0.4.1 vs lib/susanoo/application.rb in susanoo-0.5.0

- old
+ new

@@ -1,14 +1,33 @@ -module Susanoo - class Application - @@debug = false +require 'rack' - def self.debug? - @@debug +class Susanoo::Application + + class Index < Susanoo::Controller + def call(env) + template = Tilt.new(File.join(project_root, 'www/index.html.erb')) + [200, {'Content-Type' => 'text/html'}, [template.render(self)]] end + end - def self.debug=(value) - @@debug = value + class Assets < Susanoo::Controller + def call(env) + # [200, {'Content-Type' => 'text/html'}, [environment]] + run environment end + end + class Views < Susanoo::Controller + def call(env) + path = env['PATH_INFO'] + if File.exist?(File.join(project_root, "www/views#{path}.erb")) + template = Tilt.new(File.join(project_root, "www/views#{path}.erb")) + elsif File.exist?(File.join(project_root, "www/views#{path}")) + template = Tilt.new(File.join(project_root, "www/views#{path}")) + else + fail "There is no '#{path}' in 'www/views' directory." + end + [200, {'Content-Type' => 'text/html'}, [template.render(self)]] + end end + end