-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ru
40 lines (33 loc) · 959 Bytes
/
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
require 'bundler/setup'
require 'sinatra/base'
require './app'
class Assets < Sinatra::Base
configure do
set :assets, (Sprockets::Environment.new { |env|
env.append_path(settings.root + "/assets/images")
env.append_path(settings.root + "/assets/javascripts")
env.append_path(settings.root + "/assets/stylesheets")
# compress everything in production
if ENV["RACK_ENV"] == "production"
env.js_compressor = YUI::JavaScriptCompressor.new
env.css_compressor = YUI::CssCompressor.new
end
})
end
get "/assets/app.js" do
content_type("application/javascript")
settings.assets["app.js"]
end
get "/assets/app.css" do
content_type("text/css")
settings.assets["app.css"]
end
%w{jpg png}.each do |format|
get "/assets/:image.#{format}" do |image|
content_type("image/#{format}")
settings.assets["#{image}.#{format}"]
end
end
end
use Assets
run App.new