In order to get tons of bugs in color module fixed we need to get this patch in. Please read http://drupal.org/node/113607#comment-500010 about the details. So this case is opened to waste testers and reviewers time and makes things more difficult with two splitted patches. However - without this patch we don't have color module support for RTL and a crippled color module that is totally non-reusable and buggy and only works for Garland.

About all bugs fixed with this patch, please read the referenced issue (http://drupal.org/node/113607#comment-500010). Everything has already been written.

This patch hardly depends on and will not work without http://drupal.org/node/113607#comment-634279.

Comments

hass’s picture

Priority: Normal » Critical
Freso’s picture

Title: beta 3 breaker: add RTL support to color module » beta4 breaker: add RTL support to color module

Can hardly be a breaker for beta 3, as that's been out for a little while.

gábor hojtsy’s picture

Title: beta4 breaker: add RTL support to color module » Color module is not RTL-aware

Guys, there is no need to mark anything a breaker. If there is code ready, it will be in, otherwise the beta will be out without it. We are not delaying releases on issues without much of an interest.

gábor hojtsy’s picture

Now that the patch this one depends on is committed, catch on work here :) This patch will also need to fix the IMHO bugos phpdoc on drupal_load_stylesheet():

This optimization will not apply for color.module enabled themes with CSS aggregation turned off.

If the aggregation is turned off, the optimization does not apply to any CSS anyway. So this is bugos.

catch’s picture

Status: Needs review » Needs work

Still applies although it has windows linebreaks, marking to needs work for the phpdoc.

hass’s picture

Status: Needs work » Needs review
StatusFileSize
new8.96 KB

Ok, new patch attached - hopefully now with UNIX line feed... I've added some more explanations, a few newlines to make the code more readable and updated the patch with the changed function name _drupal_build_css_path.

gábor hojtsy’s picture

However - without this patch we don't have color module support for RTL and a crippled color module that is totally non-reusable and buggy and only works for Garland.

About all bugs fixed with this patch, please read the referenced issue (http://drupal.org/node/113607#comment-500010). Everything has already been written.

Well, well. I tried to understand what issues are exactly fixed by *this* patch, but the link you gave discusses the fixes which are already in Drupal for @import handling. Also you point towards another issue for RTL stuff. Now that we have color module fixes here, maybe you can do a writeup on what is happening here. Please specify what bugs you found and how you solve them here. It would help a lot of we would not need to cherry-pick information from two other issues which also solved other issues. Thanks.

gábor hojtsy’s picture

Or to put it another way: it is good to know if we can find more attractive things to market this patch for review here. Like Minnelli is not recolorable in Drupal 6 head, because it does not use style.css, it uses minnelli.css. That's a pretty important problem to solve. Let's have a list of bugs found and approaches taken in this issue!

dvessel’s picture

Subscribing and testing..

dvessel’s picture

Status: Needs review » Postponed (maintainer needs more info)

Let me ask, is this really important? Rewriting rtl styles as it applies to color is really needed? rtl style sheets from what I've seen only apply to positioning and padding, not the actual color.

Did I miss something here? Please enlighten me.

The only thing I found useful is specifying the stylesheet. style.css isn't mandatory anymore and being specific about that would be nice. This would help the issue with Minnelli as Gabor mentioned.

I tested without this patch and rtl seems to work fine with color changes in Garland.

dvessel’s picture

However - without this patch we don't have color module support for RTL and a crippled color module that is totally non-reusable and buggy and only works for Garland.

And if you can mention specific issues about this.. What are the issues outside of Garland. Thanks.

hass’s picture

Status: Postponed (maintainer needs more info) » Needs review

I will try to answer all question and write up what this fixes at all... might become a little bit longer thread.

@dvessel: possible problems in RTL styles comes up if you have an border-right in LTR that will turn in RTL to a border-left. Then you come in the situation where you must override or set a non existent border-color. Same problem will happen with backround colors. This should be possible in general or we have limits, we do not really want and some themers will complain about. I must search for it, but i know about one or two situations i was made to use this. And the answer about "how" important this is... well - it primarily add's RTL support we current do not have. To allow this support i learned how non-API like tis module has been developed and it limit's all themers. So i tried to re-factor some problematic parts as you can see in _color_rewrite_stylesheet for e.g. Many themers like to depend on color module, but cannot use it, while it have so many limits. Later - more about this limits...

@garbor: i have never thought about minelli regarding this patch, but i think this should be solved by this patch, too. Not tested with Minelli, but with my themes that includes about ~15 CSS files.

hass’s picture

Sum up what this patch does and fix:

  1. BUG: Add's RTL CSS re-coloring support. Current color module hardcodes "style.css" and does not import RTL files where border and background colors could be inside.
  2. BUG: Cannot add more then one file per theme. I'm adding ~10-20 in template.php with drupal_add_css(). Solved with the configuration array in color.inc
  3. BUG: Color module does not import all type of @import we should support. For e.g. @import url("example.css") isn't possible. With the patch i'm reusing the @import code logic from #113607 and are not made to care about two different logics that make people confused.
  4. BUG: Dynamically added CSS files support is missing. The configuration option in color.inc is the solution for this issue. For e.g. you have two different menus in CSS. With theme-settings i'm able to provide a select box for switching them. In template.php i'm switching the menu style, but i cannot extend/write the style.css with @imports commands dynamically. With the configuration option i'm able to list all possible files that could be used - doesn't matter if really used now or only partial or not at all - but they are re-colored and i'm able to add the navigations dynamically if settings are changing. GREAT stuff...
  5. BUG: Current code add's the original style.css and the re-colored style.css to the page head. This doubles the CSS size and loading time and has been reported in #145369. After the refactoring this was only a one line fix in _color_page_alter and i decided to include this performance hit. This becomes a real performance issue if you add ~20 CSS files like i do and then you have 40 files with first byte download, 20 more connections to the webserver, etc.
  6. Feature _color_rewrite_stylesheet becomes re-usable. As themer i'm able to call the function whenever i'd like/must. I'm pushing content to the function and get content back. This content is then not saved to a predefined filename. Workaround this problem is really complex and i struggled hardly about this limitation.

So - if you ask you - why does this patch do not go *this* or *this* way:

  1. We cannot read the [theme].info file to get the css list from there... this might work often, but not every time, while some people like me dynamically adding css files via theme in theme_preprocess_page() with drupal_add_css(). The css file list configuration in color.inc solved this issue, while we are able to add files a theme might have not not every time in use.
  2. We cannot read the themes $var['css'] array, while this might change dynamically and re-coloring is a "static" process only done when pressing the "save" button on theme-setting page.

I'd really like to depend with my themes on color module (and many others too - as Gabor said somewhere else) and this looks only possible with the above fixes and the refactoring. I really hope this gives all of you an idea what becomes possible.

I will try to take a look into minelli re-coloring with this patch and we could create a follow up if we want this feature in!? Should only be the configuration option in color.inc - nothing more...

dvessel’s picture

Status: Needs review » Needs work

BUG: Add's RTL CSS re-coloring support. Current color module hardcodes "style.css" and does not import RTL files where border and background colors could be inside.

I agree, need to be changed.

BUG: Cannot add more then one file per theme. I'm adding ~10-20 in template.php with drupal_add_css(). Solved with the configuration array in color.inc

Was never supported so it's not a bug but I think this can solve another problem. See the end.

BUG: Color module does not import all type of @import we should support. For e.g. @import url("example.css") isn't possible. With the patch i'm reusing the @import code logic from #113607 and are not made to care about two different logics that make people confused.

Agreed, keep it consistent.

BUG: Dynamically added CSS files support is missing. The configuration option in color.inc is the solution for this issue. For e.g. you have two different menus in CSS. With theme-settings i'm able to provide a select box for switching them. In template.php i'm switching the menu style, but i cannot extend/write the style.css with @imports commands dynamically. With the configuration option i'm able to list all possible files that could be used - doesn't matter if really used now or only partial or not at all - but they are re-colored and i'm able to add the navigations dynamically if settings are changing. GREAT stuff...

Not a bug, your adding a new feature.

BUG: Current code add's the original style.css and the re-colored style.css to the page head. This doubles the CSS size and loading time and has been reported in #145369. After the refactoring this was only a one line fix in _color_page_alter and i decided to include this performance hit. This becomes a real performance issue if you add ~20 CSS files like i do and then you have 40 files with first byte download, 20 more connections to the webserver, etc.

That's only true when CSS aggregation is disabled and a big point of aggregation is minimizing requests. If you can colorize your theme, then you can turn on aggregation and solves that problem. I didn't study how your patch deals with this directly but if it fixes that, great. Not critical.

Feature _color_rewrite_stylesheet becomes re-usable. As themer i'm able to call the function whenever i'd like/must. I'm pushing content to the function and get content back. This content is then not saved to a predefined filename. Workaround this problem is really complex and i struggled hardly about this limitation.

Sounds like an interesting feature.

We cannot read the [theme].info file to get the css list from there... this might work often, but not every time, while some people like me dynamically adding css files via theme in theme_preprocess_page() with drupal_add_css(). ..[snip]

...see above.

Most of your points are leaning towards advanced features so I don't think it's helping this issue.

Note about the second point:

Instead of trying to automatically re-write the rtl styles (which I see as complicated and duplicates code from drupal_add_css()), why not just give the option to list the main style + the rtl inside color.inc. Looks like your patch is already set to accept multiple styles.

Not exactly related but there were complications with trying to let themes override module rtl styles automatically. To simplify, why not let the theme set it explicitly? Ya know, carry over that same requirement of being explicit with rtl files. If you know how to work with color.module, you surely can handle the extra line adding the extra styles.

About Minnelli.. it's broke and some minor tweaking should fix it. Should not a separate issue since that's a genuine bug.

dvessel’s picture

In short, I think the only real issue is getting Minnelli working and tweaking the @import handling so it's more inline with the previous import patch.

RTL handling is not critical IMO but would be nice to fix. Even if it wasn't, there would be workarounds with setting a rtl class and overriding that through the main style sheet. Not ideal but than again, how often would a theme depend on what color a side border is in?

hass’s picture

Check out pushbutton's RTL file please and you see how *many* colors, background-colors and borders are inside...

Maybe i added some "advanced features", but they come all together with the refactoring. Keep the current logics and try to extend them to RTL is really bad and looks awful. I started this way in the early beginnings and it would add additional variables to the var table and doesn't make things better and easier. Only ends up with another major drupal release with an color.module no theme other then garland can use.

Module overrides: If you add a module css you need to extend the css array in color.inc. That's how it is designed.

Please let me say - i don't like to create a color module fork. Without most of the above themers need to do so if they want the color module features in a non-core theme :-(((. We should help the people and not limit them as today.

hass’s picture

Aside about aggregated CSS files i think you are wrong. If you have both style.css in the array and the recolored style.css the resulting aggregated and compressed CSS file contain both file contents. This results in the doubled file size - if compressed or not. Ok, requests are reduced, but file size is doubled.

hass’s picture

Adding an RTL file to the settings file would be strange and not consistent, too. Everywhere in D6 we only add the LTR file and the RTL is auto detected. Why should we break with this logic now!? See theme.info file, drupal_add_css etc.

Please rethink if this really needs work. I don't think so until you find a bug and i don't know what i should change in "bug free" code. I won't like to waste my time with turning the wheel back to the crippled module we currently have. This patch got much brain (over 2 weeks work "try to understand this suboptimal existing code"/rework/rework/throw away/refactoring...) and look over some things not working over 1 year since D5. Mixing Minnelli stuff with this case is no good idea, while total different part of D6.

hass’s picture

Status: Needs work » Needs review
StatusFileSize
new716 bytes
new9.03 KB

While trying to support minnelli as re-colorable theme i found a relative path bug in my latest patch. I took over the '../' path correction from _drupal_build_css_path in common.inc and fixed this small bug this way.

Additional you find the small minnelli patch attached that makes minnelli color.module aware.

hass’s picture

Title: Color module is not RTL-aware » Color module is not RTL-aware / Fix broken recoloring for Minnelli
dvessel’s picture

Status: Needs review » Needs work

Hass, there's nothing wrong with rolling the Minnelli patch together. It is a color issue and it's doesn't complicate it further.

The other points I'll leave up to others to judge but code wise, there is an error where it does the split.

from "_color_rewrite_stylesheet()":

  // Split off the "Don't touch" section of the stylesheet.
  list($style, $fixed) = explode("Color Module: Don't touch", $style);

That function runs multiple times and the "Don't touch" string isn't always present so it will spit out a notice.

hass’s picture

@dvessel: WELL, there is a different EALL bug (see http://drupal.org/node/183374)... Dries complained about my workaround, but i don't know how to solve in a different way... maybe you know!? chx told me anywhere D6 will not EALL compliant.... i have no idea whats the priority about this...

dvessel’s picture

Status: Needs work » Needs review
StatusFileSize
new11.94 KB

Checking for the string works. Here it is, fixed the notice and the help docs changed removing references to style.css. Everything else is the same.

I was going to make a simpler patch partly based on your code Hass, but I'll wait for what Gabor thinks.

[edit: and this does include the fix to Minnelli.]

hass’s picture

That patch looks fine for me, too. Thank you for the addition of missing help text and the E_ALL notice fix.

EDIT: Aside, I'd like to mention that re-coloring of IE hack files becomes possible with this patch. Something we shouldn't miss, too.

gábor hojtsy’s picture

Status: Needs review » Needs work

Reviewed the latest patch:

- the code has weak comments... I find it quite hard to understand some of them like "// Add the non-colored stylesheet as we cannot use if/else in following loop.". So why cannot you use if/else? This sounds like a weak technical reason, but it might not be. I am confused.

- pulling out original styles looks like a good idea

- With the variable changes I wonder what happens on update... this is our first release, where color module needs to be upgraded... Because styles changed, color settings will need to be updated as well, right? This is not actually related, but people should be aware of this. What is related, is that the stylesheet variable is dropped, so as soon as it is dropped, the styles will not show up anyway. This should be on the upgrade path too (ie. do not leave unused variable in the database).

- Rewrite theme stylesheets has the exact same long code block copied twice. Why not make up a one or two element array and loop over that. Now whenever you modify something, you need to do it twice. This looks ugly.

- Hass, you use case about the CSS property in color.inc does not seem common. Why not use the built-in .info file based CSS discovery, which also handles inherited CSS files? The css property in color.inc seems like a superfluous extra place to specify the same as you did already in your theme .info file (or which was discovered by Drupal based on your .info file) for most themes.

hass’s picture

// Add the non-colored stylesheet as we cannot use if/else in following loop.

The problem here is, we might not have a recolored stylesheet for every css file a theme have. In this case we end up without a file. I have no idea how to do in a different way.

1. i'm adding the original stylesheet to the css array
2. i'm looping over this array and try to find a matching colored css file - then if found - overwrite with a colored css file and unset the original.

This is all done to keep the original stylesheet order intact (for correct css overriding).

Because styles changed, color settings will need to be updated as well, right?

Yep, but this is very simple (move single value 'stylesheet' into array structure and save inside 'stylesheets'). I must ask where we should do this? system update? Until now i thought we do not support this and users must change their custom theme to an default core theme with default setting and can change this back after upgrade. Please give me a hint where in system update and we will implement this simple upgrade. No css files needs to be rewritten for this step.

Rewrite theme stylesheets has the exact same long code block copied twice. Why not make up a one or two element array and loop over that. Now whenever you modify something, you need to do it twice. This looks ugly.

i will think about a better way later... i find this ugly too, but it looks more readable and this change might not easy... we will see later

you use case about the CSS property in color.inc does not seem common

Not really. The way is the only working solution.

1. If i use .info files i may miss files that get's added dynamically
2. .info files may not contain all files or theme settings page does not invoke this files. So we don't have a chance to get this info. We could only give some "hate" to the people who changed this... but i think they have some good reasons.

So color.inc allows us to add N css files that must/should be recolored. Think about files you don't like to recolor e.g. minnelli.css. This files are not added to color.inc then. On the other side your .info file have all files listed and this could cause some harm - or people must use "Color Module: Don't touch" as first line in their css... doesn't make much sense. But nevertheless the ".info" file is not available on theme settings page if you have an admin theme... so - no way to solve this this way.

Color.inc look like a very common use and only possible way in such a special case...

gábor hojtsy’s picture

1. Understandable, refine that comment please.

2. I mean if people upgrade their core Drupal 5 site to core Drupal 6 (no contrib module or theme, but a recolored Garland), because Garland's CSS was modified, they need to somehow run the recoloring process, right? So as part of the update, we would need to affect the settings array and possibly run recoloring on all themes, which were colored before. This later issue might need to go to another bug report, I would not like to overload this issue with more tasks, just realized that we have a problem here.

3. The long block of code seems to be the same so an array(original style, rtl style) or array(original style) if there was no rtl style and a foreach on the array with the same code block seems logical to me.

4. Ah. I am not buying all this stuff about the .info files. You can load the theme .info file whenever you wish. But I am buying the reasoning that you only need a subset of your styles recolored, so you can specify those. For *this* reason, a separate css array seems to be workable.

So tasks to do:

- fix the code comments (1)
- provide upgrade path for variable (2)
- clean up repeated code (3)

hass’s picture

Status: Needs work » Needs review
StatusFileSize
new11.77 KB

- comment fixed
- upgrade path added to system.install (net tested yet - i will do in ~10 hours). Note: i used list_themes to upgrade customized garland/minnelli themes, too.
- cleaned up repeated code

gábor hojtsy’s picture

Well, this looks much better now. I hope you can take some time with testing this more, and dvessel or someone else can also look into it soon. I only see some code comments not looking nice, but those I can always fix myself, instead of playing this back and forth. Now concentrate on testing.

gábor hojtsy’s picture

Title: Color module is not RTL-aware / Fix broken recoloring for Minnelli » Color module limited to style.css, broken with Minnelli

Retitled to be more to the point on what are we fixing, it is marginally RTL related.

hass’s picture

After Gabor's latest commit #91233 the patch in #28 have a failed hunk. Updated patch attached.

Testing:
1. I've done a plain D5 installation
2. recolored Garland (default theme)
3. recolored Minnelli
4. Upgraded to D6.
5. Both theme 'stylesheet' variables have been upgraded into the 'stylesheets' arrays, themes are kept recolored after upgrade.

This patch is RTBC for me...

dvessel’s picture

Status: Needs review » Reviewed & tested by the community

It works, so marking RTBC.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

I went through the code comments, and edited them for better English usage (as far as I know :). Also made the Don't touch string a variable as it is used multiple times, so now it is more evident. Committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

jprieto’s picture

forgive my ignorance

but I think there are MANY drupal users out there -- just like me -- who love D6, like the Garland theme, but just want to be able to change the color combinations.

so you got a patch here

great!

NOW......

How is it applied?

Why can't a file be created, so that when I upload into my site, it will override the existing file with the bug, and we all get a nice sleep?

Can anyone explaine how us -- not php savvy -- can apply this fix?

do we have to write some code? or can we just upload a file (patch)?

if a patch is just a file or files with coding entered or edited -- why can't the corrected file -- AS A WHOLE -- be provided?

please help

gábor hojtsy’s picture

jprieto: This is included in Drupal 6, no need to apply anything yourself.

moortrommler’s picture

Version: 6.x-dev » 6.0
Assigned: Unassigned » moortrommler
Priority: Critical » Minor
Status: Closed (fixed) » Postponed (maintainer needs more info)

im really not into coding, except for html, but I just installed the latest drupal 6 and when i tried to change the colorset in the minelli AND garland theme to, lets say, teal top, all i get is a theme without any css. plain html, like you can see on blog.fefe.de for example (not my site, but it looks like it after using the color switcher in drupal.) so if you think this is patched. tell me whats wrong. and please tell me if you want a screenshot. hard to find info on this if you are a fresh drupal starter btw, i hope i didnt do anything wrong with posting this. but as this is "fixed" but doesnt work, i didnt know better.

greetings moortrommler

hass’s picture

Version: 6.0 » 6.x-dev
Assigned: moortrommler » Unassigned
Priority: Minor » Critical
Status: Postponed (maintainer needs more info) » Closed (fixed)

Please open a new case. This one is fixed and closed.