-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.ru
49 lines (40 loc) · 1.27 KB
/
config.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'sprockets'
class EmberHandlebars < Tilt::Template
self.default_mime_type = 'application/javascript'
def prepare
end
def evaluate(scope, locals, &block)
<<-OUTPUT
(function() {
Ember.TEMPLATES || (Ember.TEMPLATES = {});
Ember.TEMPLATES['#{scope.logical_path.gsub(/^templates\/(.*)$/i, "\\1")}'] = Handlebars.template("#{data.gsub(/$(.)/m, "\\1 ").strip}");
}).call(this);
OUTPUT
end
end
project_root = File.expand_path(File.dirname(__FILE__))
assets = Sprockets::Environment.new(project_root) do |env|
env.logger = Logger.new(STDOUT)
end
assets.register_engine('.hbs', EmberHandlebars)
assets.register_engine('.handlebars', EmberHandlebars)
assets.register_engine('.hjs', EmberHandlebars)
assets.append_path(File.join(project_root, 'app', 'assets', 'javascripts'))
assets.append_path(File.join(project_root, 'app', 'assets', 'stylesheets'))
assets.append_path(File.join(project_root, 'vendor', 'assets', 'javascripts'))
assets.append_path(File.join(project_root, 'vendor', 'assets', 'stylesheets'))
map "/assets" do
run assets
end
map "/" do
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
end