[kupu-checkins] r33558 - in kupu/trunk/kupu/plone: . kupu_plone_layer
duncan at codespeak.net
duncan at codespeak.net
Mon Oct 23 14:52:40 CEST 2006
Author: duncan
Date: Mon Oct 23 14:52:38 2006
New Revision: 33558
Modified:
kupu/trunk/kupu/plone/html2captioned.py
kupu/trunk/kupu/plone/kupu_plone_layer/kupu_migration.xml.pt
kupu/trunk/kupu/plone/plonedrawers.py
kupu/trunk/kupu/plone/zmi_links.pt
Log:
Change initialisation code for migration page yet again. The last
change worked for Linux but broke Windows.
Fix translation of field labels.
Make sure link checking code decodes entities so it recognises the
mailto: link on the Plone home page. (Surely a pointless bit of
obfuscation there: I can't imagine there are any spammers who don't
at least decode entites in when scraping links.)
Make sure link changing code ignores fields if they don't contain html.
Modified: kupu/trunk/kupu/plone/html2captioned.py
==============================================================================
--- kupu/trunk/kupu/plone/html2captioned.py (original)
+++ kupu/trunk/kupu/plone/html2captioned.py Mon Oct 23 14:52:38 2006
@@ -355,7 +355,7 @@
"""Check the relative links within this object."""
def checklink(match):
matched = match.group(0)
- newlink = link = match.group('href')
+ newlink = link = decodeEntities(match.group('href'))
classification, uid, relpath, tail = self.classifyLink(link, base)
if self.action=='check':
@@ -382,7 +382,7 @@
if newlink != link:
prefix = match.group('prefix')
changes.append((match.start()+len(prefix), match.end(), newlink))
- return prefix + newlink
+ return prefix + html_quote(newlink)
return matched
info = []
@@ -403,12 +403,17 @@
if field is None:
return None
+ content_type = field.getContentType(object)
+ if content_type != 'text/html':
+ # Don't attempt to modify non-html
+ return None
+
data = field.getEditAccessor(object)()
__traceback_info__ = (object, data)
newdata = LINK_PATTERN.sub(checklink, data)
if data != newdata and self.commit_changes:
mutator = field.getMutator(object)
- mutator(newdata)
+ mutator(newdata, mimetype='text/html')
if info or changes:
self.found += 1
@@ -591,3 +596,15 @@
if pt==FRAGMENT_TYPE:
return NAVIGATION_PAGE
return pt
+
+EntityPattern = re.compile('&(?:#(\d+)|([a-zA-Z]+));')
+def decodeEntities(s, encoding='utf-8'):
+ def unescape(match):
+ code = match.group(1)
+ if code:
+ return unichr(int(code, 10))
+ else:
+ code = match.group(2)
+ return unichr(name2codepoint[code])
+
+ return EntityPattern.sub(unescape, s)
Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupu_migration.xml.pt
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupu_migration.xml.pt (original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupu_migration.xml.pt Mon Oct 23 14:52:38 2006
@@ -3,6 +3,8 @@
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:html="http://www.w3.org/TR/REC-html40"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ i18n:domain="plone"
define="charset here/portal_properties/site_properties/default_charset|here/portal_properties/default_charset|string:utf-8;
content_type python:request.RESPONSE.setHeader('Content-Type', 'text/xml;;charset=%s' % charset);">
<html
@@ -41,7 +43,8 @@
onclick string:kj.submitForm(this.form,'$infouri',{'qlen':1,'portal_type':'$pt'});
id id;checked checked;" />
<label tal:attributes="for id;">
- <span tal:omit-tag="" tal:content="string:${f/type} (${f/label})" />
+ <span tal:omit-tag="" i18n:translate="" tal:content="f/type" />
+ (<span i18n:translate="" tal:content="f/label"></span>)
</label>
<span tal:define="folderpaths python:'\n'.join(uids)"
tal:attributes="kj:next string:$infouri?qlen=1&portal_type=$pt&folderpaths=$folderpaths"
@@ -107,6 +110,12 @@
</h3>
<h3 tal:condition="m/action_check" tal:content="m/heading|nothing" />
<h3 tal:condition="m/heading|nothing" tal:content="m/heading|nothing" />
+ <div class="discreet" tal:condition="m/action_check">
+ Links listed below are not recognised by kupu as pointing to content
+ within this Plone instance. There are several reasons why links which
+ are valid may not be recognised by kupu: you may click on each link to
+ verify whether it is indeed broken.
+ </div>
<div id="kupu-message">
<div class="highlightedSearchTerm"
style="text-align:center"
Modified: kupu/trunk/kupu/plone/plonedrawers.py
==============================================================================
--- kupu/trunk/kupu/plone/plonedrawers.py (original)
+++ kupu/trunk/kupu/plone/plonedrawers.py Mon Oct 23 14:52:38 2006
@@ -722,7 +722,7 @@
inuse = getToolByName(self, 'portal_catalog').uniqueValuesFor('portal_type')
for t,f,pt in self._getKupuFields():
if html2captioned.sanitize_portal_type(pt) in inuse or not filter:
- yield { 'type': t, 'name': f.getName(), 'label': f.widget.label, 'portal_type':pt }
+ yield { 'type': t, 'name': f.getName(), 'label': f.widget.Label(self), 'portal_type':pt }
def _getKupuFields(self):
"""Yield all fields which are editable using kupu"""
Modified: kupu/trunk/kupu/plone/zmi_links.pt
==============================================================================
--- kupu/trunk/kupu/plone/zmi_links.pt (original)
+++ kupu/trunk/kupu/plone/zmi_links.pt Mon Oct 23 14:52:38 2006
@@ -16,9 +16,6 @@
<script type="text/javascript"
tal:attributes="src portal/portal_skins/kupu_references/referencebrowser.js/absolute_url_path"
></script>
- <script type="text/javascript">
-registerPloneFunction(function() {kj.newRequest('kupu_migration.xml');});
- </script>
</metal:cssslot>
<body>
@@ -27,6 +24,10 @@
<div id="target">
Loading kupu link maintenance...
</div>
+ <div id="start" kj:nexturi="kupu_migration.xml"></div>
+ <script type="text/javascript">
+ addEventHandler(window, 'load', function(){kj.newRequest('kupu_migration.xml');}, document);
+ </script>
<form action="kupu_migration.xml"
method="post"
name="changes_form"
More information about the kupu-checkins
mailing list