This project is archived and is in readonly mode.
Allow absolute paths for the asset :cache option
-
Michael Koziarski
Those aren't (strictly speaking) absolute paths though? They're still relative to the public directory?
Out of interest, what's the use case that you have in mind where storing it in public is ok but in public/javascripts isn't?
-
Andrew Kaspick
Absolute to the asset dir (public) that is, just as any path reference can be absolute with respect to the asset dir used with any of the current asset methods (image_tag, stylesheet_link_tag, javascript_tag)
image_tag '/otherimages/image.png' # "absolute" referenceThe use case this came from is where I have bluetrip (css framework) installed in the base asset dir (public). Bluetrip refers to images in it's stylesheets relative to that stylesheets location, so it expects the css file to reside in a specific directory in order to for the image references to resolve correctly.
<%= stylesheet_link_tag '/bluetrip/css/screen', '/bluetrip/css/style' %>When stylesheet_link_tag is used with the :cache option, that collapses all of these css files into one file in the public/stylesheets directory, so the images are no longer in the correct relative spot for this new cached css file.
.somerule { background-image: url(../resources/ok.png); }This is how I currently fix the problem; by using a '../bluetrip/css/blueprint' "relative" path.
<%= stylesheet_link_tag '/bluetrip/css/screen', '/bluetrip/css/style', :cache => '../bluetrip/css/bluetrip' %>With my patch I'd be able to change that to an "absolute" path, just like any other asset file reference.
<%= stylesheet_link_tag '/bluetrip/css/screen', '/bluetrip/css/style', :cache => '/bluetrip/css/blueprint' %>It's a minor difference, but follows the same path naming rules that are used in the rest of the asset method. Also without this patch, the cached file is saved as 'public/stylesheets/bluetrip/css/blueprint.css', which is not correct for allowing the image references in the stylesheet to resolve.
If I'm not clear with my explanation, please let me know.
Thanks
-
Michael Koziarski
OK, Last thing is this patch doesn't clean up after itself right.
Run rake test a few times and then git status.
If you can fix that I'll apply it to master.
-
Andrew Kaspick
Updated with new patch file.
Thanks
-
Michael Koziarski
- State changed from new to resolved
