Skip to content
Browse files

Serve bundles

  • Loading branch information...
1 parent e54edec commit d0efd666ec0bd0c024020f005da361e793c4f404 @peteog committed Dec 15, 2011
Showing with 22 additions and 3 deletions.
  1. +22 −3 lib/sinatra/simple_assets.rb
View
25 lib/sinatra/simple_assets.rb
@@ -24,15 +24,18 @@ def initialize(app, &block)
instance_eval(&block)
end
- def css(name, files)
+ def css(bundle, files)
end
- def js(name, files)
+ def js(bundle, files)
end
- def paths_for(name)
+ def paths_for(bundle)
[]
end
+
+ def content_for(bundle)
+ end
end
def assets(&block)
@@ -41,6 +44,22 @@ def assets(&block)
def self.registered(app)
app.helpers SimpleAssets::Helpers
+
+ app.get '/stylesheets/:bundle' do
+ serve_content(params[:bundle], :css)
+ end
+
+ app.get '/javascripts/:bundle' do
+ serve_content(params[:bundle], :js)
+ end
+
+ def serve_content(bundle, type)
+ content = settings.assets.content_for(bundle)
+ not_found unless content
+
+ content_type type
+ content
+ end
end
end
end

0 comments on commit d0efd66

Please sign in to comment.
Something went wrong with that request. Please try again.