[kupu-checkins] r44881 - in kupu/trunk/kupu: doc plone plone/kupu_plone_layer
duncan at codespeak.net
duncan at codespeak.net
Mon Jul 9 17:28:32 CEST 2007
Author: duncan
Date: Mon Jul 9 17:28:32 2007
New Revision: 44881
Added:
kupu/trunk/kupu/plone/kupu_plone_layer/kupu_captioned_image.pt
Modified:
kupu/trunk/kupu/doc/CHANGES.txt
kupu/trunk/kupu/plone/html2captioned.py
kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml
Log:
Removed hardwired html for captioning transform so the html can be customised in the skin.
Modified: kupu/trunk/kupu/doc/CHANGES.txt
==============================================================================
--- kupu/trunk/kupu/doc/CHANGES.txt (original)
+++ kupu/trunk/kupu/doc/CHANGES.txt Mon Jul 9 17:28:32 2007
@@ -2,7 +2,13 @@
Kupu changes
============
-- Recent
+- Recent changes
+
+ - Fixed broken code for determining the width of captioned images.
+ Also removed the hardwired html for the transform and use a
+ template instead (so it can be customised).
+
+- 1.4rc1
- Added a 'manage anchors' tab to the anchor drawer
Modified: kupu/trunk/kupu/plone/html2captioned.py
==============================================================================
--- kupu/trunk/kupu/plone/html2captioned.py (original)
+++ kupu/trunk/kupu/plone/html2captioned.py Mon Jul 9 17:28:32 2007
@@ -37,15 +37,17 @@
ATTR_VALUE = '=(?:"?)(?P<%s>(?<=")[^"]*|[^ \/>]*)'
ATTR_CLASS = ATTR_VALUE % 'class'
ATTR_WIDTH = ATTR_VALUE % 'width'
+ATTR_ALT = ATTR_VALUE % 'alt'
ATTR_PATTERN = re.compile('''
(?P<tag>\<
( class%s
| src\s*=\s*"resolveuid/(?P<src>([^/"#? ]*))
| width%s
+ | alt%s
| .
)*\>
- )''' % (ATTR_CLASS, ATTR_WIDTH), re.VERBOSE | re.IGNORECASE | re.DOTALL)
+ )''' % (ATTR_CLASS, ATTR_WIDTH, ATTR_ALT), re.VERBOSE | re.IGNORECASE | re.DOTALL)
SRC_TAIL = re.compile(r'/([^" \/>]+)')
CLASS_PATTERN = re.compile('\s*class\s*=\s*("[^"]*captioned[^"]*"|[^" \/>]+)')
@@ -111,6 +113,7 @@
(default: None)
"""
context = kwargs.get('context', None)
+ template = context.kupu_captioned_image
if context:
at_tool = context.archetype_tool
rc = at_tool.reference_catalog
@@ -125,39 +128,23 @@
srctail = m.group(1)
else:
srctail = None
- klass = attrs.group('class')
- width = attrs.group('width')
if src:
d = attrs.groupdict()
target = self.resolveuid(context, rc, src)
if target:
+ d['class'] = attrs.group('class')
+ d['originalwidth'] = attrs.group('width')
+ d['originalalt'] = attrs.group('alt')
d['caption'] = newline_to_br(html_quote(target.Description()))
- tag = CLASS_PATTERN.sub('', d['tag'])
- tag = ALT_PATTERN.sub('', tag)
- tag = END_TAG_PATTERN.sub('\\1 alt="%s"\\2' % escape(target.Title(),1), tag)
- d['tag'] = tag
- if not width and srctail:
+ d['image'] = d['fullimage'] = target
+ if srctail:
try:
subtarget = target.restrictedTraverse(srctail)
except:
subtarget = getattr(target, srctail, None)
-
- if hasattr(aq_base(subtarget), 'getWidth'):
- width = subtarget.getWidth()
- elif hasattr(aq_base(subtarget), 'width'):
- width = subtarget.width
- if not width:
- try:
- width = target.getWidth()
- except AttributeError:
- pass
- if not width:
- try:
- width = target.getImage().getWidth()
- except:
- width = 150
- d['width'] = width
- return IMAGE_TEMPLATE % d
+ if subtarget:
+ d['image'] = subtarget
+ return template(**d)
return match.group(0) # No change
html = IMAGE_PATTERN.sub(replaceImage, data)
Added: kupu/trunk/kupu/plone/kupu_plone_layer/kupu_captioned_image.pt
==============================================================================
--- (empty file)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupu_captioned_image.pt Mon Jul 9 17:28:32 2007
@@ -0,0 +1,15 @@
+<dl tal:define="image nocall:options/image;
+ width image/width|image/getWidth|python:150;
+ height image/height|image/getHeight|python:150;
+ oimage nocall:options/fullimage|nocall:options/image;
+ owidth oimage/width|oimage/getWidth|python:150;
+ oheight oimage/height|oimage/getHeight|python:150;"
+ tal:attributes="class options/class">
+<dt><a tal:omit-tag="python:height==oheight and width==owidth"
+ rel="lightbox" tal:attributes="href oimage/absolute_url_path;"><img
+ tal:replace="structure image/tag" /></a></dt>
+ <dd class="image-caption"
+ tal:attributes="style string:width:${width}px;"
+ tal:content="options/caption|nothing">
+ </dd>
+</dl>
Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml (original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml Mon Jul 9 17:28:32 2007
@@ -306,5 +306,12 @@
.kupu-html embed embed, .kupu-html embed object {
display:none;
}
+dd.image-caption {
+ text-align:left;
+ padding: 0;
+}
+dl.captioned {
+ padding: 10px;
+}
/* </dtml-let></dtml-with> */
More information about the kupu-checkins
mailing list