skip to navigation
skip to content

Not Logged In

cornerstone.cssvar 1.0

CSS Variables Support for Zope.

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.

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.

 
File Type Py Version Uploaded on Size
cornerstone.cssvar-1.0.tar.gz (md5) Source 2009-03-25 6KB
  • Downloads (All Versions):
  • 37 downloads in the last day
  • 237 downloads in the last week
  • 404 downloads in the last month