Closed jphpsf closed 13 years ago
I'll investigate in the next few days. Thanks for the report!
Sure thing. Let me know if I can help :)
Life got busy and I've been fighting to figure out how to test this.
I've been trying Rack::Mount, but I can't figure out wtf to put in there to make it work. SCRIPT_NAME doesn't get passed through, so I can't seem to test it properly... ideas?
I could not figure out how to write a proper test for this, nor how to fix the original code.
I am currently using this in my app.rb: configure :development do Sinatra::Bundles::StylesheetBundle.class_eval do def to_html(name, media = :all) media = media.join(', ') if media.is_a? Array prefix = "/foobar/#{@app.stylesheets}/bundles" href = @app.stamp_bundles ? "#{prefix}/#{name}/#{stamp}.css" : "#{prefix}/#{name}.css" "" end end end
Which I thought to be better than hardcoding my change into a copy of the bundle source code.
As an alternative solution, would a new option prefix
work? One could set(:prefix, '/foobar/')
and the value would be used as the prefix in StylesheetBundle::to_html
. It's easy to add a test for that.
I'll look into rack mount just in case.
It really should be automagic. It should operate like url helpers, etc. I basically just need to figure out the specifics of SCRIPT_NAME and how I can fake it effectively.
Keep rspec at 1.3.x Don't require the name to spit a bundle out to HTML Add ability to just get the path of a bundles. Makes life nice if you are using Rails with an asset host helper Support SCRIPT_NAME when we generate the link and script tags. Closed by 0b1771da3ca4627e247bb039d89d302995053332
Hey there,
I just wanted to follow up with this. I updated my gems today and your latest release works great and fixes the issue.
Thank you for your help.
Sweet! Glad it works, and glad you like it.
I am trying to use the sinatras-bundle helper but I am having some trouble because of my current setup. My current dev setup is a single passenger virtual host at /var/www with multiple subdirs for each of my apps. A foobar app would be under /var/www/foobar and I would access it using http://localhost/foobar
It seems the helper does not support the /foobar path.
In my sinatra app I did this, in my layout.erb
<%= stylesheet_bundle_link_tag(:all) %>
Which output:
<link media="all" rel="stylesheet" href="/stylesheets/bundles/all/1283313960.css" type="text/css">
I would expect the href to be /foobar/stylesheetsbundles/all/1283313960.css
I figured that adding
/foobar
inprefix = "/foobar/#{@app.stylesheets}/bundles"
(in the to_html method of the StylesheetBundle class was solving the issue, but that's not a proper solution).I was not able to figure out a proper patch :( I tried to get the /foobar from
ENV['SCRIPT_NAME']
as well as fromrequest.script_name
(that should be available from Rack right? I've seen this there).Any help/advice much appreciated :) I'd love to finish that patch + spec and send you a pull request.
Thanks!