Permalink
Browse files

Use dynamic send file instead of statically linking resources

  • Loading branch information...
1 parent 1ee911f commit ade7189647ba3f0f506e17967013c034cd41cab4 Ivan Navarrete and Jonas Nicklas committed Nov 2, 2011
Showing with 13 additions and 12 deletions.
  1. +13 −12 lib/evergreen/application.rb
@@ -10,23 +10,12 @@ def build_application
Rack::Builder.new do
instance_eval(&Evergreen.extensions) if Evergreen.extensions
- map "/jasmine" do
- use Rack::Static, :urls => ["/"], :root => File.expand_path('../jasmine/lib', File.dirname(__FILE__))
- run lambda { |env| [404, {}, "No such file"]}
- end
-
- map "/resources" do
- use Rack::Static, :urls => ["/"], :root => File.expand_path('resources', File.dirname(__FILE__))
- run lambda { |env| [404, {}, "No such file"]}
- end
-
map "/" do
app = Class.new(Sinatra::Base).tap do |app|
app.reset!
app.class_eval do
- set :static, true
+ set :static, false
set :root, File.expand_path('.', File.dirname(__FILE__))
- set :public_folder, File.expand_path(File.join(Evergreen.root, Evergreen.public_dir), File.dirname(__FILE__))
helpers do
def url(path)
@@ -59,6 +48,18 @@ def render_spec(spec)
@coffee_spec_helper = @suite.get_spec('spec_helper.coffee')
erb :run
end
+
+ get "/jasmine/*" do |path|
+ send_file File.expand_path(File.join('../jasmine/lib', path), File.dirname(__FILE__))
+ end
+
+ get "/resources/*" do |path|
+ send_file File.expand_path(File.join('resources', path), File.dirname(__FILE__))
+ end
+
+ get '/*' do |path|
+ send_file File.join(Evergreen.root, Evergreen.public_dir, path)
+ end
end
end
run app

0 comments on commit ade7189

Please sign in to comment.