documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

Rack Middleware instead of Controller? #161

Open jacquescrocker opened 13 years ago

jacquescrocker commented 13 years ago

I'm currently trying to get Jammit working within a Sinatra app. I think if we switch the ActionController stuff to use Rack middleware instead, then it would work across any Rack web framework (Rails included)

Interested in this change? Should I work on this in a fork or create a wrapper gem?

Thanks

adrianpacala commented 13 years ago

+1 For the Rack middleware.

mcollina commented 13 years ago

+1 For the Rack middleware. There is also https://github.com/juliocesar/rack-pagespeed.

jacquescrocker commented 13 years ago

Added functional middleware here: https://github.com/railsjedi/jammit/tree/rack_middleware

Jammit::Middleware

I didn't replace the Rails one because I didnt understand how to deal with the page_caching. However it should be testable on Rails by manually adding the Jammit::Middleware to your Rack middleware list. That will preempt the controller action so if it still works solid, then we can eventually remove the old controller implementation.

jacquescrocker commented 13 years ago

I packaged it up via a jammit wrapper gem here: https://github.com/railsjedi/jammit-sinatra

gem "jammit-sinatra", ">= 0.6.0"

Will be nice to eventually merge these changes into the main jammit repo, but for now the wrapper gem should work well.

agibralter commented 13 years ago

+1

micho commented 13 years ago

+1

craigulliott commented 13 years ago

+1

jacquescrocker commented 13 years ago

thanks for all the up votes. if you get a chance please try the middleware on https://github.com/railsjedi/jammit-sinatra and let me know if it can be improved. would love to get some users and solidify the codebase

fbjork commented 13 years ago

+1

jashkenas commented 13 years ago

+1 from me as well. @railsjedi: Do you have the page caching figured out?

Edit: Do you have a branch that I can try merging to master?

mulderp commented 11 years ago

For those still interested, I added a small update to exploring Jammit::Rack here: https://github.com/documentcloud/jammit/pull/251

and a demo app here: https://github.com/mulderp/jammit_test/blob/master/config.ru

I need to complete the integration with the Packager still, but it would be interesting to hear more thoughts about the current approach, what would be important? what would be a blocker?