This package allow theme developers to add LESS stylesheets into a Plone site.
Project description
Introduction
This package allow theme developers to add LESS stylesheets into a Plone site.
LESS
LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions. LESS runs on both the client-side (Chrome, Safari, Firefox) and server-side, with Node.js and Rhino.
You can find more information about LESS at http://lesscss.org/
Integration with Plone
This package clone the portal_css behavior, extending it to meet both client-side and server-side LESS resources compiling methods.
It adds a portal_less tool to the portal, enables an import/export GS profile lessregistry.xml, overrides the default Products.ResourceRegistries viewlet by adding the LESS resources part for the <head> tag.
Adding LESS resources
This package is intended to be used in conjunction with an user defined Plone Theme package. As a developer, you can include as many LESS resources as you may need to build your theme. You can add LESS resources using a GS profile named lessregistry.xml. The syntax is cloned from cssregistry.xml profile:
<?xml version="1.0"?> <object name="portal_less" meta_type="LESS Stylesheets Registry"> <stylesheet title="++bootstrap++less/bootstrap.less" authenticated="False" enabled="on" id="++bootstrap++less/bootstrap.less" rendering="link"/> </object>
Control Panel
You can manage the way the LESS resources compile by accessing the LESS resources configlet located at the site setup. By default, client-side LESS resources compile mode is enabled.
Client side compiling
Client-side compiling is intended to use while in (theme) development mode.
collective.lesscss will use the standard method for compiling client-side by using the less.js (v1.3, at the time of this writting) and exposing the LESS resources after the portal_css ones:
<link rel="stylesheet/less" type="text/css" href="styles.less"> <!-- Here goes the rest of portal_javascript resources --> <script src="less.js" type="text/javascript"></script>
Server side compiling
Server-side compiled LESS resources are recommended in production mode. By unsetting this option, the site will server-side compile them into CSS resources and enable a volatile cache on them. Node.js is used for server side compiling, so you should have a Node.js installed in your system and less package installed as well. It’s recommended to let buildout handle this for you:
[buildout] parts = ... nodejs ... ... [nodejs] recipe = gp.recipe.node url = http://nodejs.org/dist/v0.6.14/node-v0.6.14.tar.gz npms = less scripts = lessc
This will download and compile Node.js and less extension. The lessc executable will be available at bin directory of your buildout. Please, review https://github.com/collective/collective.lesscss/blob/master/buildout.cfg for more references.
In case you already have Node.js and less extension in your system it’s required for you to create a symbolic link of lessc executable at bin directory of your buildout.
IMPORTANT NOTE: Server-side compiling requires to have declared the resources via plone.resource package in your theme package! Example:
<plone:static directory="resources/less" type="bootstrap" name="less" />
And furthermore, if you aren’t using plone.app.themimg for develop your theme you should declare the type you are using for your resources by creating this class somewhere in your theme (e.g. traversal.py):
from plone.resource.traversal import ResourceTraverser class BootstrapTraverser(ResourceTraverser): """The theme traverser. Allows traveral to /++bootstrap++<name> using ``plone.resource`` to fetch things stored either on the filesystem or in the ZODB. """ name = 'bootstrap'
and later on, declare the adapter via zcml:
<adapter name="bootstrap" for="* zope.publisher.interfaces.IRequest" provides="zope.traversing.interfaces.ITraversable" factory=".traversal.BootstrapTraverser" />
So, you should now be able to access to the resources inside the resources directory by accessing:
http://localhost/Plone/++bootstrap++less/
Twitter bootstrap integration
You can check out the package https://github.com/sneridagh/example.bootstrap for a full example on how to integrate LESS resources in your theme package.
Contributors
Victor Fernandez de Alba [sneridagh], Author
Changelog
1.0b1 (2012-04-13)
A portal_less inherited from CSSRegistry [sneridagh]
Import/Export GS profile [sneridagh]
A viewlet to include less files [sneridagh]
Register less.js in portal_javascripts [sneridagh]
A site wide configuration with : transform server side / client wide. [sneridagh]
Provide documented buildout to install nodejs to compile your files server side [sneridagh]
Make the results in cached with memoize [sneridagh]
test with twitter’s bootstrap sources [sneridagh]
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
Built Distribution
Hashes for collective.lesscss-1.0b1-py2.6.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | b894b9a56283bec768eb1b13953ca10d7b837114d0c954b56c59a6120f9144a3 |
|
MD5 | 4a56e29f0ff3fb282abfa9d4677bfec9 |
|
BLAKE2b-256 | f9aa3e2472203c0314c4d45c22bdb00dfbc027d1fe556687217e8d4a06c83881 |