CSS Variables Support for Zope.
Project description
This is an implementation of a CSS Variables extension for Zope Browser Resources.
Cascading Stylesheets don’t have any built in method to define variables and use them within the stylesheet. This feature was discussed at some CSS related blogs already and resulted in a non-official draft specification.
In former Zope versions DTML templating language was used to define variables in CSS. This breaks CSS syntax, looks crappy and produces error messages in CSS-enabled editors even if the browser gets the correct values.
cornerstone.cssvar uses an almost CSS syntax compatible variant to apply variables:
div.foo { color: var(myColor); }
If we declare such a css resource using zcml it looks this way:
<browser:cssvarResource name="foo" file="foo.css" />
If we use the common mechanism to declare variables using css like syntax we must do this in a separate file, this looks like:
@variables { myColor: #123456; }
The variable itself need to be defined by a named ICSSVariables adapter on request. We can register it by an own zcml directive:
<browser:cssvarDefinition name="foodef" file="foodef.css" />
Now we just need to tell our first css file which definition to use. Here theres no common syntax, so we put it in an comment:
/# vardef(foodef) /# div.foo { color: var(myColor); }
If we now in browser look at http://mydomain.tld/++resource++foo it results in:
/# vardef(foodef) /# div.foo { color: #123456; }
For resource directories as defined by zope.app.publisher the special CSS handling is registered for every CSS file if this module is imported.
This package is tested with Zope 3.5dev KGS (Python 2.6 )and in Zope 2.10.7 (with Plone 3.3 and Python 2.4).
TODO:
Write tests!
Make resourceDirectory work in Plone.
Profiling and performance testing.
Copyright
written by Jens W. Klein - BlueDynamics Alliance - Klein & Partner KEG, Austria
License
Copyright (c) 2008-2009, BlueDynamics Alliance, Austria All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the BlueDynamics Alliance nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY BlueDynamics Alliance ‘’AS IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BlueDynamics Alliance BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file cornerstone.cssvar-1.0.tar.gz
.
File metadata
- Download URL: cornerstone.cssvar-1.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d54ded412a3092a9c23e9e1dfaac3593e4f46105eb7adde8c03b5674ce496f88 |
|
MD5 | c416dbe749313e76f92c5933357ee4f4 |
|
BLAKE2b-256 | 5627adfc73589ca05966267eabbab0e2e7f79dc80740ac0895005dd48ceae335 |