Class: Susanoo::Application::Index

Inherits:
Controller show all
Defined in:
lib/susanoo/controllers/index.rb

Overview

This controller is responsible for serving/building index.html file.

Instance Attribute Summary

Attributes inherited from Controller

#debug, #environment, #project_root

Instance Method Summary collapse

Methods inherited from Controller

#initialize, #static_compile?

Constructor Details

This class inherits a constructor from Susanoo::Controller

Instance Method Details

#build(generator, options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/susanoo/controllers/index.rb', line 13

def build(generator, options)
  platform = options[:platform]

  # Configure Sprockets::Helpers (if necessary)
  Sprockets::Helpers.configure do |config|
    config.environment = @environment
    config.prefix      = "/#{platform}_asset/www/assets"
    config.debug       = false
  end

  template = Tilt.new(File.join(project_root, 'src/index.html.erb'))
  data = template.render(self)
  # God forgive me for hard coding this part
  generator.create_file 'www/index.html', data
end

#call(env) ⇒ Object



7
8
9
10
11
# File 'lib/susanoo/controllers/index.rb', line 7

def call(env)
  # Tilt template object
  template = Tilt.new(File.join(project_root, 'src/index.html.erb'))
  [200, {'Content-Type' => 'text/html'}, [template.render(self)]]
end