Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Allow absolute paths for the asset :cache option

#2766

This patch allows using an absolute path with the :cache option for stylesheet_link_tag and javascript_include_tag which didn't work before...

stylesheet_link_tag(:all, :cache => "/absolute/test")

Relative paths are accepted such as...

stylesheet_link_tag(:all, :cache => "../relative/test")

so this patch makes things more consitent and allows both.

Reported by Andrew Kaspick · June 5th, 2009 @ 05:01 AM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Michael Koziarski
    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?

    June 10th, 2009 @ 04:28 AM

  2. Andrew Kaspick
    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" reference
    

    The 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

    June 10th, 2009 @ 04:56 AM

  3. Michael Koziarski
    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.

    June 10th, 2009 @ 09:50 AM

  4. Andrew Kaspick
  5. Andrew Kaspick
    Andrew Kaspick

    Updated with new patch file.

    Thanks

    June 10th, 2009 @ 05:05 PM

  6. Michael Koziarski
    Michael Koziarski
    • State changed from new to resolved

    June 11th, 2009 @ 05:35 AM