Author: jmorliaguet Date: Sun May 21 21:00:16 2006 New Revision: 3182 Modified: cpsskins/branches/paris-sprint-2006/standard/fields/image.py cpsskins/branches/paris-sprint-2006/standard/filters/style/README.txt cpsskins/branches/paris-sprint-2006/standard/filters/style/css.py
Log: - added initial support for web images in CSS Modified: cpsskins/branches/paris-sprint-2006/standard/fields/image.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/standard/fields/image.py (original) +++ cpsskins/branches/paris-sprint-2006/standard/fields/image.py Sun May 21 21:00:16 2006 @@ -47,13 +47,6 @@ readonly=True, ) - def toUrl(self): - """URL representation: url(...) - """ - url = zapi.absoluteURL(self) - print url - return u'url(%s)' % url - class WebImage(Image): """A web image """ @@ -63,10 +56,3 @@ super(Image, self).__init__(**kw) self.title = title - def __str__(self): - """See cpsskins.elements.interfaces.IField""" - return self.toUrl() - - def toUrl(self): - return u'' - Modified: cpsskins/branches/paris-sprint-2006/standard/filters/style/README.txt ============================================================================== --- cpsskins/branches/paris-sprint-2006/standard/filters/style/README.txt (original) +++ cpsskins/branches/paris-sprint-2006/standard/filters/style/README.txt Sun May 21 21:00:16 2006 @@ -1,26 +1,27 @@ $Id$ -============= -CSS RENDERING -============= +============ +STYLE FILTER +============ >>> from zope.app import zapi + >>> from zope.component import getUtility - >>> from zope.component import getGlobalSiteManager, getUtility - >>> gsm = getGlobalSiteManager() + >>> from cpsskins.setup.interfaces import IResourceManager + >>> resources = getUtility(IResourceManager) >>> from cpsskins.standard.filters.style import CSSRenderer >>> from cpsskins.standard.filters.style import ICSSRenderer >>> from cpsskins.standard.filters.style import StyleFilter - >>> from cpsskins.standard.formats.style import IStyle, Style + >>> from cpsskins.standard.formats.style import Style +Inserting CSS class names into HTML markup +========================================== >>> s = Style() >>> s.identifier = 12345 -inserting class names in HTML tags: - >>> f = StyleFilter(s) >>> f(markup=u'<div>Some content</div>', info=None) @@ -44,41 +45,64 @@ >>> f(markup=u'<p style="color:red" class="fancy blue">Text</p>', info=None) u'<p style="color:red" class="fancy blue style12345">Text</p>' -rendering CSS: +Rendering styles in CSS +======================= >>> s = Style() >>> s.identifier = 12345 - >>> s[u'div.body'] = {'color': 'red'} + >>> print CSSRenderer(s)() div.body.style12345 {color:red} >>> s[u'ul'] = {'border': u'none', 'color': u'red'} + >>> print CSSRenderer(s)() div.body.style12345 {color:red} ul.style12345 {color:red;border:none} >>> s[u'ul'] = {} - >>> s[u''] = {'color': u'red'} + >>> print CSSRenderer(s)() .style12345 {color:red} div.body.style12345 {color:red} -web colors: +Web colors +---------- >>> s = Style() >>> s.identifier = 12345 - - >>> from cpsskins.setup.interfaces import IResourceManager - >>> resources = getUtility(IResourceManager) + >>> s[u'p'] = {'color': 'cpsskins://[EMAIL PROTECTED]'} >>> from cpsskins.standard.fields.color import WebColor + >>> color = WebColor(255, 0, 0) >>> setting = resources.register(name=u'red', title=u'Red color', ... resource=color) - >>> s[u'p'] = {'color': 'cpsskins://[EMAIL PROTECTED]'} >>> print CSSRenderer(s)() - p.style12345 {color:cpsskins://[EMAIL PROTECTED] + p.style12345 {color:#ff0000} + +Web images +---------- + + >>> s = Style() + >>> s.identifier = 12345 + >>> from cpsskins.standard.fields.image import WebImage + + >>> image1 = WebImage(title=u'blue background') + >>> image1.contentType = u'image/png' + >>> image1.data = "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00x" \ + ... "\x00\x00\x00x\x01\x03\x00\x00\x00\x03\xaa\xa4\x91\x00\x00\x00" \ + ... "\x03PLTE\xff\xff\xff\xa7\xc4\x1b\xc8\x00\x00\x00\x17IDAT8\xcbc`" \ + ... "\x18\x05\xa3`\x14\x8c\x82Q0\nF\x01\xbd\x01\x00\x07\x80\x00\x01:" \ + ... "\xe7\xca\xd4\x00\x00\x00\x00IEND\xaeB`\x82" + + >>> setting1 = resources.register(name=u'image1', title=u'Image 1', + ... resource=image1) + + >>> s[u'p'] = {'background-image': 'cpsskins://[EMAIL PROTECTED]'} + + >>> print CSSRenderer(s)() Modified: cpsskins/branches/paris-sprint-2006/standard/filters/style/css.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/standard/filters/style/css.py (original) +++ cpsskins/branches/paris-sprint-2006/standard/filters/style/css.py Sun May 21 21:00:16 2006 @@ -76,7 +76,7 @@ self.style = style def __str__(self): - return 'style%s' % unicode(IRelatable(self.style)) + return u'style%s' % unicode(IRelatable(self.style)) def __call__(self): """Render the style in CSS""" @@ -101,7 +101,7 @@ if isWebColor(r): q = str(r) elif isWebImage(r): - q = resources.url(uri, context) + q = '++image++%s' % q.split('@')[-1] if not q: continue props.append('%s:%s' % (p, q)) -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins