lib/susanoo/application.rb in susanoo-0.5.1 vs lib/susanoo/application.rb in susanoo-0.7.0
- old
+ new
@@ -1,33 +1,14 @@
require 'rack'
+# This class contains basic controllers which is needed for Susanoo to
+# work. Each controller should contains `call` and `build` instance methods.
+# `call` is responsible to serving an http request base on **Rack** specification
+# and `build` is responsible to create static files with suitable content. `build`
+# method gets an argumant which is the generator object that calls build methods.
+# `generator` is a **Thor** object so you can use **Thor::Actions** in your method.
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
-
- 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
+
+require 'susanoo/controllers/index'
+require 'susanoo/controllers/views'
+require 'susanoo/controllers/assets'