[kupu-checkins] r47143 - in kupu/trunk/kupu: doc plone plone/kupu_plone_layer
duncan at codespeak.net
duncan at codespeak.net
Thu Oct 4 10:48:07 CEST 2007
Author: duncan
Date: Thu Oct 4 10:48:07 2007
New Revision: 47143
Modified:
kupu/trunk/kupu/doc/CHANGES.txt
kupu/trunk/kupu/plone/html2captioned.py
kupu/trunk/kupu/plone/kupu_plone_layer/kupu_captioned_image.pt
Log:
Fix for Plone issue #7143: UnicodeError inserting image
Also the fix broke captioning, so I cleaned up the captioning code and associated template moving all of the logic out of the template into the Python code.
Modified: kupu/trunk/kupu/doc/CHANGES.txt
==============================================================================
--- kupu/trunk/kupu/doc/CHANGES.txt (original)
+++ kupu/trunk/kupu/doc/CHANGES.txt Thu Oct 4 10:48:07 2007
@@ -13,8 +13,9 @@
* 6970: can't upgrade to Kupu 1.4.1
* 6975: Cannot save HTML field as NULL
* 7119: 'Edit without visual editor' link doesn't show up in Plone 2.5.3
- * 7140: kupu fails with danish letters in title.
* 7139: Kupu Manage Anchors not working in inline edit
+ * 7140: kupu fails with danish letters in title.
+ * 7143: UnicodeError inserting image
- 1.4.2
Modified: kupu/trunk/kupu/plone/html2captioned.py
==============================================================================
--- kupu/trunk/kupu/plone/html2captioned.py (original)
+++ kupu/trunk/kupu/plone/html2captioned.py Thu Oct 4 10:48:07 2007
@@ -137,18 +137,39 @@
d['class'] = attrs.group('class')
d['originalwidth'] = attrs.group('width')
d['originalalt'] = attrs.group('alt')
+ d['url_path'] = target.absolute_url_path()
d['caption'] = newline_to_br(html_quote(target.Description()))
d['image'] = d['fullimage'] = target
+ d['tag'] = None
+ d['isfullsize'] = False
+ d['width'] = target.width
if srctail:
+ if isinstance(srctail, unicode):
+ srctail =srctail.encode('utf8') # restrictedTraverse doesn't accept unicode
try:
subtarget = target.restrictedTraverse(srctail)
except:
subtarget = getattr(target, srctail, None)
if subtarget:
d['image'] = subtarget
+
+ if srctail.startswith('image_'):
+ d['tag'] = target.getField('image').tag(target, scale=srctail[6:])
+ elif subtarget:
+ d['tag'] = subtarget.tag()
+
+ if d['tag'] is None:
+ d['tag'] = target.tag()
+
+ if subtarget:
+ d['isfullsize'] = subtarget.width == target.width and subtarget.height == target.height
+ d['width'] = subtarget.width
+
return template(**d)
return match.group(0) # No change
+ if isinstance(data, str):
+ data = data.decode('utf8')
html = IMAGE_PATTERN.sub(replaceImage, data)
# Replace urls that use UIDs with human friendly urls.
Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupu_captioned_image.pt
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupu_captioned_image.pt (original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupu_captioned_image.pt Thu Oct 4 10:48:07 2007
@@ -1,15 +1,9 @@
-<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>
+<dl tal:attributes="class options/class">
+<dt><a tal:omit-tag="options/isfullsize" rel="lightbox"
+ tal:attributes="href options/url_path;"
+ tal:content="structure options/tag">[image goes here]</a></dt>
<dd class="image-caption"
- tal:attributes="style string:width:${width}px;"
+ tal:attributes="style string:width:${options/width}px;"
tal:content="options/caption|nothing">
</dd>
</dl>
More information about the kupu-checkins
mailing list