peteboere / css-crush

CSS preprocessor.
http://the-echoplex.net/csscrush
MIT License
537 stars 51 forks source link

URL Rewrites #32

Closed gabrielhart closed 12 years ago

gabrielhart commented 12 years ago

Hi Pete, Excellent work.

I am having a problem with URL rewrites. The settings that I am using are all working except for the rewrites (dollar are vars coming from _GET, and working ok).

$options = array( 'debug' => $debug, 'boilerplate' => $boilerplate, 'cache' => $cache, 'versioning' => $versioning, 'rewrite_import_urls' => true );

$compiled_file = csscrush::file($filepath, $options);

For test purposes I put the 'rewrite_import_urls' in as a direct value.

Any advice appreciated or I can send you a sample. Currently the setup is:

/rootui /theme/themefile.css (this file references images below as "../media/image/.") /media/image/. /site/mysite/stylesheet.css (inside, this references themefile.css as @import(../../themefile.css) (after) /style/site/stylesheet.crush.css (references themefile.css as (../media/image/.)

In the crush file, the correct path to be generated in the crushed file (/style/site/stylesheet.crush.css) should be (../../media/image/) in order to continue to have a valid references for the original files, but it remains (../media/image/.).

I hacked the code a bit but cannot resolve...

Any help appreciated. G

PS: Option for url rewrite without conversion of images to data would be great too...

peteboere commented 12 years ago

Hi Gabriel, thanks for your input!

I've tracked this down, seems there was a regression during recent refactoring.

Just checked in a fix to the test branch if you'd like to pull that down and try it.

gabrielhart commented 12 years ago

Thank you Pete! Will do-my gang and I love this tool and it's a real help. 

Cheers! Gabriel


From: Pete Boere reply@reply.github.com To: gabrielhart gabriel.hart@rocketmail.com Sent: Tuesday, June 5, 2012 10:03 AM Subject: Re: [css-crush] URL Rewrites (#32)

Hi Gabriel, thanks for your input!

I've tracked this down, seems there was a regression during recent refactoring.

Just checked in a fix to the test branch if you'd like to pull that down and try it.


Reply to this email directly or view it on GitHub: https://github.com/peteboere/css-crush/issues/32#issuecomment-6125583

gabrielhart commented 12 years ago

Hi, So its not working perfectly yet, but I created some test cases for you to see. The piece of code that writes the path seems to have a little glitch in it.

Examples: Inside the Stylesheet -> /ui/site/test/styleheet.css: @import url( "../../theme/small-icons.css" ); /* path is /ui/theme/ - global stuff / @import url( "theme/large-icons.css" ); / path is /ui/site/test/theme/ - local stuff */

Original CSS in imported css files (pointing to different but same named folders): .sm-icon-add { background-image: url( ../media/image/icon/add.png ); }

.large-icon-1 { background-image: url( ../media/image/icon/large/applications-internet.png ); } (found in

Post-crush output: .sm-icon-add { background-image: url(../../theme/../media/image/icon/add.png); } .large-icon-1 { background-image: url(theme/../media/image/icon/large/applications-internet.png); }

The correct conversions should be: .sm-icon-add { background-image: url(../../media/image/icon/add.png) } // so it points to the common folder up there .large-icon-1 { background-image: url(media/image/icon/large/applications-internet.png); } // so it points to a more local folder

This kind of facility to get the paths right is so important-looking forward to a resolution. Happy to test further to get things working well. Hope this feedback is helpful.

Cheers! Gabriel

peteboere commented 12 years ago

I've tried to recreate your test case as follows:

└── ui
    ├── site
    │   └── test
    │       ├── stylesheet.css
    │       └── theme
    │           ├── large-icons.css
    │           └── media
    │               └── image
    │                   └── icon
    │                       └── large
    │                           └── applications-internet.png
    └── theme
        ├── media
        │   └── image
        │       └── icon
        │           └── add.png
        └── small-icons.css

If this is the case then these paths in your test case:

.sm-icon-add { background-image: url( ../media/image/icon/add.png ); }

.large-icon-1 { background-image: url( ../media/image/icon/large/applications-internet.png ); }

Should be (without ../ prefix):

.sm-icon-add { background-image: url( media/image/icon/add.png ); }

.large-icon-1 { background-image: url( media/image/icon/large/applications-internet.png ); }

If this is not right can you send a zip of your test case to pete at the-echoplex.net please