From yuppie at codespeak.net Mon Dec 4 21:13:36 2006 From: yuppie at codespeak.net (yuppie at codespeak.net) Date: Mon, 4 Dec 2006 21:13:36 +0100 (CET) Subject: [kupu-checkins] r35268 - in kupu/trunk/kupu: common doc tests Message-ID: <20061204201336.EF8571007E@code0.codespeak.net> Author: yuppie Date: Mon Dec 4 21:13:33 2006 New Revision: 35268 Modified: kupu/trunk/kupu/common/kupubasetools.js kupu/trunk/kupu/doc/CHANGES.txt kupu/trunk/kupu/tests/run_tests.html kupu/trunk/kupu/tests/test_kupubasetools.js kupu/trunk/kupu/tests/test_kupuhelpers.js Log: - fixed bug in createLink Modified: kupu/trunk/kupu/common/kupubasetools.js ============================================================================== --- kupu/trunk/kupu/common/kupubasetools.js (original) +++ kupu/trunk/kupu/common/kupubasetools.js Mon Dec 4 21:13:33 2006 @@ -1111,6 +1111,11 @@ // the order of the arguments is a bit odd here because of backward // compatibility this.createLink = function(url, type, name, target, title) { + url = url.strip(); + if (!url) { + this.deleteLink(); + return; + }; if (!this.formatSelectedLink(url, type, name, target, title)) { // No links inside or outside. this.editor.execCommand("CreateLink", url); Modified: kupu/trunk/kupu/doc/CHANGES.txt ============================================================================== --- kupu/trunk/kupu/doc/CHANGES.txt (original) +++ kupu/trunk/kupu/doc/CHANGES.txt Mon Dec 4 21:13:33 2006 @@ -2,6 +2,10 @@ Kupu changes ============ +- 1.4 unreleased + + - Fixed a bug where createLink deleted the selected text. + - 1.4 Beta 2 - Paragraph styling now permitted inside a table again (contributed Modified: kupu/trunk/kupu/tests/run_tests.html ============================================================================== --- kupu/trunk/kupu/tests/run_tests.html (original) +++ kupu/trunk/kupu/tests/run_tests.html Mon Dec 4 21:13:33 2006 @@ -67,6 +67,7 @@ testsuite.registerTest(InitKupuCheckersTestCase); testsuite.registerTest(KupuUITestCase); testsuite.registerTest(ImageToolTestCase); + testsuite.registerTest(LinkToolTestCase); testsuite.runSuite(); // global tear down Modified: kupu/trunk/kupu/tests/test_kupubasetools.js ============================================================================== --- kupu/trunk/kupu/tests/test_kupubasetools.js (original) +++ kupu/trunk/kupu/tests/test_kupubasetools.js Mon Dec 4 21:13:33 2006 @@ -291,7 +291,7 @@ KupuUITestCase.prototype = new SelectionTestCase; function ImageToolTestCase() { - this.name = 'KupuUITestCase'; + this.name = 'ImageToolTestCase'; SelectionTestCase.apply(this); this.base_setUp = this.setUp; @@ -325,3 +325,37 @@ }; ImageToolTestCase.prototype = new SelectionTestCase; + +function LinkToolTestCase() { + this.name = 'LinkToolTestCase'; + SelectionTestCase.apply(this); + this.base_setUp = this.setUp; + + this.setUp = function() { + this.base_setUp(); + this.editor = new KupuEditor(this.kupudoc, {}, new DummyLogger()); + this.editor._initialized = true; + this.linktool = new LinkTool(); + this.linktool.editor = this.editor; + }; + + this.test_createLink = function() { + this.body.innerHTML = '

foo bar baz

'; + // select |bar| + this._setSelection(4, null, 7, null, 'bar'); + this.linktool.createLink('http://www.example.org'); + this.assertEquals(this._cleanHtml(this.body.innerHTML), + '

foo bar baz

'); + }; + + this.test_createLinkEmpty = function() { + this.body.innerHTML = '

foo bar baz

'; + // select |bar| + this._setSelection(4, null, 7, null, 'bar'); + this.linktool.createLink(''); + this.assertEquals(this._cleanHtml(this.body.innerHTML), + '

foo bar baz

'); + }; +}; + +LinkToolTestCase.prototype = new SelectionTestCase; Modified: kupu/trunk/kupu/tests/test_kupuhelpers.js ============================================================================== --- kupu/trunk/kupu/tests/test_kupuhelpers.js (original) +++ kupu/trunk/kupu/tests/test_kupuhelpers.js Mon Dec 4 21:13:33 2006 @@ -101,6 +101,8 @@ s = s.toLowerCase().replace(/[\r\n]/g, ""); s = s.replace(/\>[ ]+\<"); s = s.replace(/\/>/g, ">"); + s = s.replace(' style=""', ""); + s = s.replace(" style=''", ""); return s; }; From duncan at codespeak.net Wed Dec 6 10:06:23 2006 From: duncan at codespeak.net (duncan at codespeak.net) Date: Wed, 6 Dec 2006 10:06:23 +0100 (CET) Subject: [kupu-checkins] r35367 - in kupu/trunk/kupu: doc plone plone/kupu_plone_layer Message-ID: <20061206090623.EB1C410070@code0.codespeak.net> Author: duncan Date: Wed Dec 6 10:06:21 2006 New Revision: 35367 Modified: kupu/trunk/kupu/doc/PLONE2.txt kupu/trunk/kupu/plone/kupu_plone_layer/kupu_wysiwyg_support.html kupu/trunk/kupu/plone/xmlconfig.kupu Log: Htmlfilter should not disappear just because we have no tag/attribute filters. Fixed docs for widget styles. Modified: kupu/trunk/kupu/doc/PLONE2.txt ============================================================================== --- kupu/trunk/kupu/doc/PLONE2.txt (original) +++ kupu/trunk/kupu/doc/PLONE2.txt Wed Dec 6 10:06:21 2006 @@ -440,18 +440,19 @@ (description='Please paste or type your article here', label='Body Copy', parastyles=( - ('div|pullQuote','Pull Quote'), - ('div|Caption','Caption'), - ('div|contactInformation','Contact Information'), - ('div|notesToEditors','Notes to editors'), + 'div|pullQuote|Pull Quote', + 'div|Caption|Caption', + 'div|contactInformation|Contact Information', + 'div|notesToEditors|Notes to editors', ), ), ), -``parastyles`` is a sequence of style definitions. Each definition should -be a 2-tuple of strings. The first string if either the tag to be -added, or tag, vertical bar, class to be assigned to the tag. The -second string is the caption that appears in the style pulldown. +``parastyles`` is a sequence of style definitions. Each definition +should be a string as for the style definitions in the control panel +containing the tag to be added, vertical bar, class to be assigned to +the tag, vertical bar, description that appears in the style pulldown. +The class may be omitted, so tag, vertical bar, description is also valid. Images ------ @@ -499,7 +500,7 @@ text/x-html-captioned and output type text/html. * On the portal_transforms policy tab add a policy with output - type=text/x-html-captioned, uses transforms='html-to-captioned'. + type=text/x-html-safe, uses transforms='html-to-captioned'. This will force the captioning transform to be applied before the safe_html transform. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupu_wysiwyg_support.html ============================================================================== --- kupu/trunk/kupu/plone/kupu_plone_layer/kupu_wysiwyg_support.html (original) +++ kupu/trunk/kupu/plone/kupu_plone_layer/kupu_wysiwyg_support.html Wed Dec 6 10:06:21 2006 @@ -19,7 +19,7 @@ - + @@ -57,7 +57,7 @@ - + Modified: kupu/trunk/kupu/plone/xmlconfig.kupu ============================================================================== --- kupu/trunk/kupu/plone/xmlconfig.kupu (original) +++ kupu/trunk/kupu/plone/xmlconfig.kupu Wed Dec 6 10:06:21 2006 @@ -32,7 +32,7 @@ - + Author: duncan Date: Thu Dec 7 15:39:41 2006 New Revision: 35436 Modified: kupu/trunk/kupu/plone/html2captioned.py Log: Link fixing messed up the page if you had href attributes containing non-ascii characters AND someone had set the python default encoding to something stupid like latin1. Fixed by forcing all replacements to work in unicode. Modified: kupu/trunk/kupu/plone/html2captioned.py ============================================================================== --- kupu/trunk/kupu/plone/html2captioned.py (original) +++ kupu/trunk/kupu/plone/html2captioned.py Thu Dec 7 15:39:41 2006 @@ -14,7 +14,7 @@ import re from cgi import escape from urlparse import urlsplit, urljoin, urlunsplit -from urllib import unquote_plus +from urllib import unquote_plus, quote_plus from Acquisition import aq_base from htmlentitydefs import name2codepoint @@ -386,8 +386,9 @@ if newlink != link: prefix = match.group('prefix') + newlink = html_quote(newlink).encode('ascii', 'xmlcharrefreplace') changes.append((match.start()+len(prefix), match.end(), newlink)) - return prefix + html_quote(newlink) + return prefix + newlink return matched info = [] @@ -413,13 +414,13 @@ # Don't attempt to modify non-html return None - data = field.getEditAccessor(object)() + data = field.getEditAccessor(object)().decode('utf8') __traceback_info__ = (object, data) newdata = LINK_PATTERN.sub(checklink, data) if data != newdata and self.commit_changes: mutator = field.getMutator(object) if mutator: - mutator(newdata, mimetype='text/html') + mutator(newdata.encode('utf8'), mimetype='text/html') object.reindexObject() # Need to flag update if info or changes: From duncan at codespeak.net Fri Dec 8 14:20:43 2006 From: duncan at codespeak.net (duncan at codespeak.net) Date: Fri, 8 Dec 2006 14:20:43 +0100 (CET) Subject: [kupu-checkins] r35477 - in kupu/trunk/kupu/plone: . kupu_plone_layer kupu_plone_layer/plonekupuimages Message-ID: <20061208132043.BD5461006E@code0.codespeak.net> Author: duncan Date: Fri Dec 8 14:20:38 2006 New Revision: 35477 Added: kupu/trunk/kupu/plone/helpers.py (contents, props changed) kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/link_icon.gif (contents, props changed) kupu/trunk/kupu/plone/spellchecker.kupu (contents, props changed) kupu/trunk/kupu/plone/zmi_toolbar.pt (contents, props changed) Modified: kupu/trunk/kupu/plone/drawers.kupu kupu/trunk/kupu/plone/kupu_config.pt kupu/trunk/kupu/plone/kupu_plone_layer/kupu_wysiwyg_support.html kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml kupu/trunk/kupu/plone/librarytool.py kupu/trunk/kupu/plone/plonelibrarytool.py kupu/trunk/kupu/plone/sourceedit.kupu kupu/trunk/kupu/plone/toolbar.kupu Log: Paragraph styles may now be replaced as well as added to in widget definitions. All toolbar buttons may be controlled from the configlet or from widget definition whitelists and blacklists. In javascript all the tools (I think) are now robust against their toolbar elements being omitted. Internal link icon now comes from kupu's images (as for all the other toolbar buttons) instead of using the icon for the link content type. Modified: kupu/trunk/kupu/plone/drawers.kupu ============================================================================== --- kupu/trunk/kupu/plone/drawers.kupu (original) +++ kupu/trunk/kupu/plone/drawers.kupu Fri Dec 8 14:20:38 2006 @@ -14,6 +14,35 @@ + + + + + + + + + +