Improving color.module for Drupal 7
Project information
Project page on drupal.org: http://drupal.org/project/color_soc08
Color.module SOC '08 page: http://www.skiquel.com/dev/color
Color.module SOC '08 Demo! http://www.skiquel.com/drupal6
Color.module SOC '08 Blog: http://skiquel.com/soc
Proposal: http://groups.drupal.org/node/10072
Current status: Coding! Working on user color scheme selection.
Description
Improving color.module to empower theme developers and webmasters.
Project schedule
This is subject to change.
- Milestone 1: May 26-June 7 -- Definable custom colors, multiple gradients. Basic documentation.
- Milestone 2: June 8-20 -- Webmaster-made custom color sets, allow users w/ permissions to choose color sets.
- Milestone 2: June 21-30 -- Custom preview.inc, Lighten/Darken/Randomize/Undo
- Milestone 3: July 1-14 -- Write functions for color harmonies (Complements, Analogous, Monochromatic, etc.)
- Milestone 4: July 15-31 -- Create color palette and link with color harmony functions through AJAX.
- Testing and bug squashing: August 1-10 -- Testing and bug finding. Tighten up code.
- Final polishing: August 11-18 -- Make sure code is up to standards. Finalize documentation.
Status updates
June 20, 2008
Commit of #122620
SQL Tweaking/New DB Functions. A complete redo of the color.database.inc.
- (Done) INNER/LEFT JOIN more!
- (Done) allow color_get_theme_info and work on grabbing specific fields instead of all columns
- (Done) change 'default_set' to 'default_scheme'. TRY TO USE ID!
- (Todo) Store info on what themes are colorable in {color} table
- (Done) in color_theme_select_submit() before hand use hidden field to include scheme_id
June 18, 2008
Bug fix/Tweaking release
- (Added) On uninstall, whipe old schemes from dir
- (Added) Do a preg_replace('~[^a-z0-9._]+~, '-', drupal_strtolower($string)); to normalize file paths
- (Fixed) On block administration page, the theme now changes.
- (Fixed) Users can now change schemes w/o 'select different theme' perm.
- (Fixed) Bug on garland/minnelli with invalid stylesheet recoloring
- (Tweaked) Suppress repeat warnings in certain parts of scripts.
- (Updated) Update minnelli color.inc to new version.
Caching
I do not see this module as being very cache-friendly. There will have to be some thinking when it comes to this.
- Block cache: lags on select boxes on anonymous/registered users
- Caching modes 'normal': interrupts scheme changing for anonymous users. works OK w/ logged in ones
June 16, 2008
New color replacement methods!
Changes:
- Find and replace fields from color.inc inside stylesheets. /* {{base}} */ #ffffff /* {{/base}} */
- Include a 'base' field if you want to change colors of non-tagged color values. (I.e. Garland)
- You can keep the above stylesheets in the /color folder by doing: 'css' => array( 'color/style.css',),
- Fixed bug w/ blend_target storing in DB
- Added some more logic for falling back to default themes/color theme changing
Quirks:
- In listthemes(), must check if theme is enabled in system! This shows extra color-enabled themes in user/{uid}/edit
- When changing over a theme, the old scheme name may show in selectbox (the module will still correctly move to default scheme for newly selected theme, though)
June 11, 2008
We got a color scheme block + anonymous color scheme selection + perms.
Changes:
- Fixed up webmaster theme selection
- Users other the uid 1 can choose scheme.
- Color scheme changing block. (YES.)
- Anonymous users can now pick color schemes
- Started applying user permissions to scheme selection. If user is not granted permission they will not be able to see scheme selection and default to default_set scheme for the theme.
Need to know: You have to set the 'choose color scheme' permissions for the user type if they want to see the block/change schemes.
June 9, 2008
Changes:
- Legacy support code is now in the color_get_info() function.
- Updated color.image.inc for some legacy support for gradients without the color field values. (supposed to be listed like x, y, width, height, color1, color2)
- Modularized code into color.database.inc, color.stylesheet.inc and color.misc.inc
- Now 3 tables: 'color' for theme info, 'color_schemes' for individual name/theme/hex info, and 'color_picks' for user scheme choices.
- In color.database.inc, there is now functions to find scheme based on UID, hex, and scheme/theme
- color_legacy($info) in color.misc.inc function for checking/changing old scheme .inc files to be compatible with this.
Known quirks:
- Minnelli is having very odd color effects. (http://img338.imageshack.us/img338/8634/picture8no4.png) (With current color.scheme using legacy support code to fix).
June 8, 2008
Users can now pick color schemes
Changes:
- Color schemes are now in 'color_schemes' table
- Instead of every theme having one scheme stored, all schemes are stored for user selection.
- Scheme file information stored in 'extra_attr' column
- In preparation for user custom schemes, the 'scheme' column will attempt to match with the 'name' column of a pre-made theme. If no match, in the future will assume it is a custom user theme. (Generate graphics/stylesheet)
- Users can now pick color schemes for themes on a user basis via user/{uid}/edit. (YES)
Known Quirks:
- Color schemes are installed when color.module is installed.
- New individual color themes are added when you go to admin/build/themes/settings/{theme}
- When schemes are first installed, esp. after the module installation w/ a few color themes, the set messages list is very long. Need to find a way to quiet that.
June 1, 2008
We are on our way to allowing users to select their color schemes.
Changes:
- For the moment the inline color scheme selection has been removed from /user/{uid}/edit. Can be placed back at a later time if wanted (it is in 1.6 of color.module)
- Fixed bug with color schemer showing on none Color.module themes.
- Users can now store their theme selections (not creations yet) in the DB. It will insert and edit.
+ New special 'user_scheme' name. Currently stores serialized hexed codes for color schemes. Built to support custom schemes for users.
+ A form validation for when a theme and color scheme is chosen at the same time.
May 30th, 2008
This is a commit so my mentors (Konstantin and Dmitri) and anyone else who wants to can see what I've been working on. There is a lot of temporary code in this commit. Thanks to Merlinofchaos for the magic elixir and clarification regarding themes.
Changes:
- Inline color scheme select
- Fixed schemer to work with more themes!
- Schemer now has some (maybe temporary) support for legacy color.inc files. It will present a warning but still adds to the database all the same.
- Split functions up into color.image.inc and color.algorithms.inc
- Removed indexes for Primary key. For now to change this please Uninstall/Reinstall module. It will suppress some duplicate errors from before.
Known Quirks: I cannot get the values of the select boxes for color schemes on color-enabled themes to all submit seperately on /user/{uid}/edit. It seems as if the last select box overwrites all the previous ones. And the ['colorselectbox'] hex shows up all around the form output with dprint_r($form);
May 28th, 2008
Changes:
- Added the "uid" column. Index in scheme for 'theme', 'uid' for the moment.
- Added "Color-enabled" in description of themes with color support (color.inc files present)
- Added "Color scheme" fieldset below "Theme Configuration" on the /user/{uid}/edit page. Shows up when users select a theme with color support. (user-selected schemes still have to be coded in)
Known quirks:
- I just found that current color.module in Drupal 6 may not be handling screenshot preview correctly.
May 26th, 2008
First commit to the CVS against the Drupal 6 color.module. You can read the current README.txt.
Changes:
- Support for unlimited/custom amount of color fields. Fields atm must be declared in color.inc.
- Color scheme keys changed to scheme name (was value/hexes). Implemented storage of schemes/other color theme variables in SQL.
- Color.module install schema.
- "Reset to defaults" can be used to reset the SQL (incase you wanted to try adding new fields/colors).
- Gradient colors can now be chosen through field names of your choice.
Known quirks:
- (Fixed) Blank page on module enable/disable, theme change submit/reset. Try reloading the URL w/o form POST.
May 11th, 2008
Added some more options to "Compatible colors". Added options for up to 6 "Last colors".
Also, I've been messing with a checkbox for "safe web colors" for the past 2 days. I'm questioning whether or not websafe colors are
Bug in Safari: "Last Colors" is bringing up more than one color when a color is set.
May 10th, 2008
Eureka! Fixed bug with the last input field not working.
Preview of how it's looking:

Fixed darken/lighten to stay in limits.
May 9th, 2008
Moved darken, lighten and randomize from page-javascript into farbtastic.js. Tweaked randomize to only move between certain levels of saturation and lightness (to avoid colors too light or dark).
Also added javascript support for compatible colors. Also support for the last 5 colors picked.
Bug though: For some reason on the last input field generated with "Last Colors" and "Compatible colors", the focused color will not be brought up. However, it jQuery is detecting the event of it being clicked.
May 8th, 2008
Can now darken, lighten, and randomize colors.
May 6th, 2008
Implemented farbtastic and jQuery on a page to mess around with things and get familiar.


Put this in your pipe
Heh, I found this earlier today, and webchick told me to post it in your direction.
http://demo.rockettheme.com/apr08_j15/
Great example of what it would be nice if the color module could do. Some default behavior along these lines would be very very nice... especially if it were associated with a permission.
Also, might be nice if color module could work on a user-by-user basis, allowing each user to have their own color themes. I dunno if that would be a stupidly huge amount of over-head though.
Eclipse
Good find
Thank you webchick and Eclipse.
If we make color.module function this way, we would not have to generate a new theme for every color set. There is no slicing, no filling, simply alpha-transparant png's with background. A webmaster could literally set up a block on their site for instant color switching.
Theme developers may be scared off by having to code a script to slice n' fill images. This could be a deliverance to them.
I will definitely take time to look into this and do my due diligence.
If color themes were to work like this (without a new theme being sliced/filled/generated), and simply worked through CSS, user themes like this may seem a lot more likely.
Thank you!
Skiquel
Details
The reason that the current color module is using image slicing and such is because you may have the need for rounded corners. How are we going to address that as a css only thing? I don't think we can, which puts us back at needing to do image slicing. We just need to have a really clear view of how to do this.
Problems with pure CSS/JS approach
One of the problems with the sole CSS/JS approach is it limits gradients to a single hue. In current color.module themes we have a header and footer color that can generate a gradient (Like a firey orange to red)
There is also the instance where an image color may need to change (for instance, in a corner graphic).
What do you think about color.module being able to generate gradients from scratch?
... support for color changing on a per-image (already sliced) basis?
Is there any preference for sticking with $base_image slicing?