I enabled the css preprocessor and certain parts of the Meta theme broke. At the top of the generated preprocessed css file was this:
@import /Drupal/sites/default/themes/meta/meta-paper/url('/Drupal/sites/default/themes/meta/meta-paper/../css/pagestructure.css');@import /Drupal/sites/default/themes/meta/meta-paper/url('/Drupal/sites/default/themes/meta/meta-paper/../css/pagestyles.css');/* $Id: node.css,v 1.2 2006/09/05 03:50:56 unconed Exp $ */
It should also be noted that those two files are imported by the individual css files (style.css in 4 different folder for four different color scheme; meta-paper is one of the folders) as follows:
@import url('../css/pagestructure.css');
@import url('../css/pagestyles.css');
I manually edited the preprocessed css file to the correct syntax and the theme works as usual. Regex not extracting @import properly?
Comments
Comment #1
edmund.kwok commentedIt seems that the regex that is supposed to look for @import that doesn't use url() matches those with url() also:
Not sure if the regex's purpose was to match @import 'file', @import "file", and @import file. But with that, @import url() gets matched also. Proposed that ([\'"]?) be changed to ([\'"]+) if the purpose is to match valid @import syntax that does not use url().
Changing title as css preprocessor might break other themes that are using @import url().
Comment #2
edmund.kwok commentedComment #3
dvessel commentedI noticed this when reviewing the css aggregator patch. m3vrk wanted to keep it similar to how color.module does it.
Your right. It doesn't consider @import with url(..). Both are legal, it just doesn't understand it both ways.
Comment #4
BioALIEN commentedWhat theme are you using?
Maybe this should be set to critical?
Comment #5
dvessel commentedDon't think it's critical. I'd say, more of a feature to support both options. You just have to make sure your not using url(). Instead just use
@import "../path/file.css";Comment #6
edmund.kwok commentedMain purpose of these process is to convert relative paths to absolute ones. url() were already converted in the line before; thus the regex was meant for @import that don't use url() as mentioned in the code comments.
Oh, I just noticed the code comment has a typo :p I think using url() is fine, but the regex needs some tweaking. I'm using the Meta theme as mentioned in #1. Don't think this is critical either; it only breaks certain theme and if css preprocessor is enabled.
Comment #7
Steven commented@import "foo.css"and@import url("foo.css")are both valid CSS and mean exactly the same thing. Why not precede the url() regexp with one that wraps all @import arguments in url(), and get rid of this dodgy one we have now?Comment #8
edmund.kwok commented+1 on the suggestion. At least we can standardize the @import syntax in the process. Attached patch converts @import "file", @import 'file' and @import file to @import url("file").
Tested on:
Garland - no @import statements => No change
Meta - @import url('file') => No change
Minnelli - @import "file" => Converted to @import url("file")
Comment #9
dvessel commentedHaven't tested the patch but does it convert from
@import url(...). You mentioned it converts to that style but does it work the other way around? I must have missed something as that was the main issue here.Comment #10
Steven commentedTested and verified. I tweaked the replace string so it doesn't insert an extra semi-colon. Committed to HEAD, thanks.
Comment #11
bradlis7 commentedI'm using drupal-rc1, and my theme was using a statement like this:
But, the file was not being imported, until I changed it to:
I'm not sure what the deal is, but I don't think this is fixed.
Comment #12
edmund.kwok commentedHmm, what theme are you using specifically? If possible, can you take a look at the css file generated in files/css and see what's the difference in the @import statement in the first line, before and after you changed the @import syntax.
Comment #13
bradlis7 commentedThere was no @import in the generated file at all, so I'm not sure what the deal was. Like I said, it simply had
I was working on the B7 theme, but I changed it to use the @import url() syntax, and it worked.
Comment #14
edmund.kwok commentedI can't seem to reproduce the error. I tried disabling and enabling the css preprocessor for B7, B7 Brown and B7 Green. B7 used @import url("base.css"); while B7 Brown and B7 Green used @import "../base.css";. All of them worked fine and each of the generated preprocessed css file in files/css directory had the proper @import url("absolute path/base.css") syntax at the top.
Comment #15
bradlis7 commentedI'm not sure what the problem was, but this is the page with the change I made: http://cvs.drupal.org/viewcvs/drupal/contributions/themes/B7/style.css?r... .
Comment #16
edmund.kwok commentedSo when B7's main style.css was @import "base.css", you enabled the css preprocessor, and the theme breaks. Then you changed it to @import url("base.css"); and enabled css preprocessor, and now its working. Correct? Can you look in your drupal/files/css directory and see if there are any differences when @import and @import url() was used. The file should be a css file named some 32 random characters, eg 90bd4ab7320dba7267ade209d114bc33.css
Comment #17
bradlis7 commentedHm, I can't seem to recreate the problem. I think it originally didn't have any kind of "import" at all in the generated file, but when I added url(), it put the import into the file. Unless this happens to someone else, I guess you can consider this fixed.
Comment #18
(not verified) commentedComment #19
morbus iffThis seems to be happening on disobey.com:
Comment #20
morbus iffThis is reproducible using Garland's Minelli - enable it, and make sure CSS caching is on. The first characters of the cache file is "@import url("/themes/garland/minnelli/../style.css");.node-unpublished,", which means that the import happens, then all the declarations are overridden with the inclusion of the system/node stuff.
Comment #21
morbus iffMine's a different a bug. Resetting back.