[prev in list] [next in list] [prev in thread] [next in thread]
List: kupu-checkins
Subject: [kupu-checkins] r49342 - kupu/trunk/kupu/plone
From: duncan () codespeak ! net
Date: 2007-12-04 15:38:12
Message-ID: 20071204153812.76F618143 () code0 ! codespeak ! net
[Download RAW message or body]
Author: duncan
Date: Tue Dec 4 16:38:11 2007
New Revision: 49342
Added:
kupu/trunk/kupu/plone/config.py
Modified:
kupu/trunk/kupu/plone/ReftextField.py
kupu/trunk/kupu/plone/html2captioned.py
Log:
Moved UID_PATTERN to a separate config module. Made both the output transform and the \
reftext field use the same regex.
Modified: kupu/trunk/kupu/plone/ReftextField.py
==============================================================================
--- kupu/trunk/kupu/plone/ReftextField.py (original)
+++ kupu/trunk/kupu/plone/ReftextField.py Tue Dec 4 16:38:11 2007
@@ -7,11 +7,9 @@
from Products.Archetypes.exceptions import ReferenceException
from ZPublisher.HTTPRequest import FileUpload
from Products.CMFCore.utils import getToolByName
+from Products.kupu.plone.config import UID_PATTERN
import re
-# UID_PATTERN matches a UID in an anchor or image tag.
-UID_PATTERN = re.compile(r'''<(?:a\b[^>]+href|img\b[^>]+src)="resolveuid/(?P<uid>[^?#">/]+)''', \
re.I)
-
class ReftextField(TextField):
__implements__ = TextField.__implements__
@@ -46,7 +44,8 @@
value.seek(0);
value = value.read()
- uids = UID_PATTERN.findall(value) # XXX: build list of uids from the value \
here + # build list of uids from the value here
+ uids = [ m.group('uid') for m in UID_PATTERN.finditer(page) ]
uids = dict.fromkeys(uids).keys() # Remove duplicate uids.
tool = getToolByName(instance, REFERENCE_CATALOG)
Added: kupu/trunk/kupu/plone/config.py
==============================================================================
--- (empty file)
+++ kupu/trunk/kupu/plone/config.py Tue Dec 4 16:38:11 2007
@@ -0,0 +1,22 @@
+##############################################################################
+#
+# Copyright (c) 2003-2008 Kupu Contributors. All rights reserved.
+#
+# This software is distributed under the terms of the Kupu
+# License. See LICENSE.txt for license text. For a list of Kupu
+# Contributors see CREDITS.txt.
+#
+##############################################################################
+"""Kupu configuration file
+"""
+import re
+
+# Pattern to match resolveuid links in HTML.
+# Match groups:
+# tag: the html tag from the start up to the point where the uid
+# occurs.
+# url: the url containing the uid (stops after the uid: any
+# trailing part such as '/image_thumb' is not included.
+# uid: the uid itself.
+UID_PATTERN = re.compile('(?P<tag><(?:a|img|object|param)\\s[^>]*(?:src|href|data|value)\s*=\s*")(?P<url>[^"]*resolveuid/(?P<uid>[^/"#? \
]*))', re.DOTALL | re.IGNORECASE) +
Modified: kupu/trunk/kupu/plone/html2captioned.py
==============================================================================
--- kupu/trunk/kupu/plone/html2captioned.py (original)
+++ kupu/trunk/kupu/plone/html2captioned.py Tue Dec 4 16:38:11 2007
@@ -17,6 +17,8 @@
from urllib import unquote_plus, quote_plus
from Acquisition import aq_base
from htmlentitydefs import name2codepoint
+from Products.kupu.plone.config import UID_PATTERN
+
name2codepoint = name2codepoint.copy()
name2codepoint['apos']=ord("'")
@@ -66,8 +68,6 @@
</dl>
'''
-UID_PATTERN = re.compile('(?P<tag><(?:a|img|object|param)\\s[^>]*(?:src|href|data|value)\s*=\s*")(?P<url>[^"]*resolveuid/(?P<uid>[^/"#? \
]*))', re.DOTALL | re.IGNORECASE)
-
class HTMLToCaptioned:
"""Transform which adds captions to images embedded in HTML"""
__implements__ = itransform
_______________________________________________
kupu-checkins mailing list
kupu-checkins@codespeak.net
http://codespeak.net/mailman/listinfo/kupu-checkins
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic