Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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.

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.

Release History

Release History

This version
History Node

1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
cornerstone.cssvar-1.0.tar.gz (6.2 kB) Copy SHA256 Checksum SHA256 Source Mar 25, 2009

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting