[prev in list] [next in list] [prev in thread] [next in thread]
List: kupu-checkins
Subject: [kupu-checkins] r14575 - in kupu/branch/plone-2.1: . Extensions
From: duncan () codespeak ! net
Date: 2005-07-12 20:18:24
Message-ID: 20050712201824.B5C8127B53 () code1 ! codespeak ! net
[Download RAW message or body]
Author: duncan
Date: Tue Jul 12 22:18:12 2005
New Revision: 14575
Added:
kupu/branch/plone-2.1/config.py
- copied unchanged from r14574, kupu/trunk/kupu/config.py
kupu/branch/plone-2.1/plone/tests/runalltests.py
- copied unchanged from r14574, kupu/trunk/kupu/plone/tests/runalltests.py
kupu/branch/plone-2.1/plone/tests/runme.cmd
- copied unchanged from r14574, kupu/trunk/kupu/plone/tests/runme.cmd
Removed:
kupu/branch/plone-2.1/plone/kupu_plone_layer/browserSupportsKupu.py
Modified:
kupu/branch/plone-2.1/Extensions/Install.py
kupu/branch/plone-2.1/__init__.py
kupu/branch/plone-2.1/common/kupubasetools.js
kupu/branch/plone-2.1/common/kupudrawers.js
kupu/branch/plone-2.1/doc/LIBRARIES.txt
kupu/branch/plone-2.1/plone/__init__.py
kupu/branch/plone-2.1/plone/beforeunload.kupu
kupu/branch/plone-2.1/plone/drawers.kupu
kupu/branch/plone-2.1/plone/head.kupu
kupu/branch/plone-2.1/plone/kupu_plone_layer/contentUsesKupu.py
kupu/branch/plone-2.1/plone/kupu_plone_layer/kupu_wysiwyg_support.html
kupu/branch/plone-2.1/plone/kupu_plone_layer/wysiwyg_support.pt
kupu/branch/plone-2.1/plone/plonelibrarytool.py
kupu/branch/plone-2.1/plone/sourceedit.kupu
kupu/branch/plone-2.1/plone/tests/test_browserSupportsKupu.py
kupu/branch/plone-2.1/plone/wysiwyg_support.kupu
Log:
Merged trunk revisions 14502 to 14574 (HEAD).
Modified: kupu/branch/plone-2.1/Extensions/Install.py
==============================================================================
--- kupu/branch/plone-2.1/Extensions/Install.py (original)
+++ kupu/branch/plone-2.1/Extensions/Install.py Tue Jul 12 22:18:12 2005
@@ -15,6 +15,7 @@
"""
import os.path
import sys
+import re
from StringIO import StringIO
from App.Common import package_home
@@ -22,6 +23,7 @@
from Products.CMFCore.utils import getToolByName, minimalpath
from Products.CMFCore.DirectoryView import createDirectoryView
from Products.kupu import kupu_globals
+from Products.kupu.config import TOOLNAME, PROJECTNAME, TOOLTITLE
from OFS.ObjectManager import BadRequestException
from zExceptions import BadRequest
@@ -30,13 +32,12 @@
except ImportError:
pass # Plone not available
-PROJECTNAME = 'Kupu'
-
kupu_package_dir = package_home(kupu_globals)
def register_layer(self, relpath, name, out):
"""Register a file system directory as skin layer
"""
+ print >>out, "register skin layers"
skinstool = getToolByName(self, 'portal_skins')
if name not in skinstool.objectIds():
kupu_plone_skin_dir = minimalpath(os.path.join(kupu_package_dir, relpath))
@@ -76,8 +77,83 @@
install_libraries(self, out)
install_configlet(self, out)
install_transform(self, out)
+ install_resources(self, out)
install_customisation(self, out)
+def _read_resources():
+ resourcefile = open(os.path.join(kupu_package_dir, 'plone', 'head.kupu'), 'r')
+ try:
+ data = resourcefile.read()
+ return data
+ finally:
+ resourcefile.close()
+
+def css_files(resources):
+ CSSPAT = re.compile(r'\<link [^>]*rel="stylesheet"[^>]*\${portal_url}/([^"]*)"')
+ for m in CSSPAT.finditer(resources):
+ id = m.group(1)
+ yield id
+
+def js_files(resources):
+ JSPAT = re.compile(r'\<script [^>]*\${portal_url}/([^"]*)"')
+ for m in JSPAT.finditer(resources):
+ id = m.group(1)
+ if id=='sarissa.js':
+ continue
+ yield id
+
+def install_resources(self, out):
+ """Add the js and css files to the resource registry so that
+ they can be merged for download.
+ """
+ try:
+ from Products.ResourceRegistries.config import CSSTOOLNAME, JSTOOLNAME
+ except ImportError:
+ print >>out, "Resource registry not found: kupu will load its own resources"
+ return
+
+ data = _read_resources()
+
+ CONDITION = '''python:portal.kupu_library_tool.isKupuEnabled(REQUEST=request)'''
+ csstool = getToolByName(self, CSSTOOLNAME)
+ jstool = getToolByName(self, JSTOOLNAME)
+
+ for id in css_files(data):
+ print >>out, "CSS file", id
+ csstool.manage_removeStylesheet(id=id)
+ csstool.manage_addStylesheet(id=id,
+ expression=CONDITION,
+ rel='stylesheet',
+ enabled=True,
+ cookable=True)
+
+ for id in js_files(data):
+ print >>out, "JS file", id
+ jstool.manage_removeScript(id=id)
+ jstool.manage_addScript(id=id,
+ expression=CONDITION,
+ enabled=True,
+ cookable=True)
+
+def uninstall_resources(self, out):
+ """Remove the js and css files from the resource registries"""
+ try:
+ from Products.ResourceRegistries.config import CSSTOOLNAME, JSTOOLNAME
+ except ImportError:
+ return
+
+ data = _read_resources()
+
+ csstool = getToolByName(self, CSSTOOLNAME)
+ jstool = getToolByName(self, JSTOOLNAME)
+
+ for id in css_files(data):
+ csstool.manage_removeStylesheet(id=id)
+
+ for id in js_files(data):
+ jstool.manage_removeScript(id=id)
+ print >>out, "Resource files removed"
+
def install_libraries(self, out):
"""Install everything necessary to support Kupu Libraries
"""
@@ -105,8 +181,8 @@
return
try:
portal_conf.registerConfiglet( 'kupu'
- , 'Kupu'
- , 'string:${portal_url}/kupu_library_tool/kupu_config'
+ , TOOLTITLE
+ , 'string:${portal_url}/%s/kupu_config' % TOOLNAME
, '' # a condition
, 'Manage portal' # access permission
, 'Products' # section to which the configlet should be \
added: @@ -175,6 +251,23 @@
print >>out, "kupu successfully installed"
return out.getvalue()
+def uninstall_transform(self, out):
+ transform_tool = getToolByName(self, 'portal_transforms')
+ try:
+ transform_tool.manage_delObjects(['html-to-captioned'])
+ except:
+ pass
+ else:
+ print >>out, "Transform removed"
+
+def uninstall_tool(self, out):
+ try:
+ self.manage_delObjects([TOOLNAME])
+ except:
+ pass
+ else:
+ print >>out, "Kupu tool removed"
+
def uninstall(self):
out = StringIO()
@@ -184,5 +277,9 @@
configTool.unregisterConfiglet('kupu')
out.write('Removed kupu configlet\n')
+ uninstall_transform(self, out)
+ uninstall_tool(self, out)
+ uninstall_resources(self, out)
+
print >> out, "Successfully uninstalled %s." % PROJECTNAME
return out.getvalue()
Modified: kupu/branch/plone-2.1/__init__.py
==============================================================================
--- kupu/branch/plone-2.1/__init__.py (original)
+++ kupu/branch/plone-2.1/__init__.py Tue Jul 12 22:18:12 2005
@@ -57,8 +57,8 @@
registerDirectory('common', globals())
if have_plone:
- import plone
- initialize = plone.initialize
+ from Products.kupu.plone import initialize
+
elif have_zope2 and have_fss:
import zope2
initialize = zope2.initialize
Modified: kupu/branch/plone-2.1/common/kupubasetools.js
==============================================================================
--- kupu/branch/plone-2.1/common/kupubasetools.js (original)
+++ kupu/branch/plone-2.1/common/kupubasetools.js Tue Jul 12 22:18:12 2005
@@ -203,7 +203,7 @@
* change CSS positioning styles on an element which has focus.
*/
function KupuLateFocusStateButton(buttonid, commandfunc, checkfunc, offclass, \
onclass) {
- KupuStateButton.apply(this, buttonid, commandfunc, checkfunc, offclass, \
onclass); + KupuStateButton.apply(this, [buttonid, commandfunc, checkfunc, \
offclass, onclass]); this.execCommand = function() {
/* exec this button's command */
this.button.className = (this.pressed ? this.offclass : this.onclass);
Modified: kupu/branch/plone-2.1/common/kupudrawers.js
==============================================================================
--- kupu/branch/plone-2.1/common/kupudrawers.js (original)
+++ kupu/branch/plone-2.1/common/kupudrawers.js Tue Jul 12 22:18:12 2005
@@ -1012,4 +1012,4 @@
return false;
}
return true;
-}
\ No newline at end of file
+}
Modified: kupu/branch/plone-2.1/doc/LIBRARIES.txt
==============================================================================
--- kupu/branch/plone-2.1/doc/LIBRARIES.txt (original)
+++ kupu/branch/plone-2.1/doc/LIBRARIES.txt Tue Jul 12 22:18:12 2005
@@ -470,4 +470,4 @@
* Deeper standards support (WebDAV/DASL)
- * Image/file upload via the library
+
Modified: kupu/branch/plone-2.1/plone/__init__.py
==============================================================================
--- kupu/branch/plone-2.1/plone/__init__.py (original)
+++ kupu/branch/plone-2.1/plone/__init__.py Tue Jul 12 22:18:12 2005
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2003-2005 Kupu Contributors. All rights reserved.
+# Cocommpyright (c) 2003-2005 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
@@ -15,11 +15,14 @@
$Id$
"""
+from App.Common import package_home
from Products.CMFCore.DirectoryView import registerDirectory
from Products.CMFCore import utils
from Products.kupu.plone.plonelibrarytool import PloneKupuLibraryTool
+from Products.kupu import kupu_globals
-registerDirectory('kupu_plone_layer', globals())
+kupu_package_dir = package_home(kupu_globals)
+registerDirectory('plone/kupu_plone_layer', kupu_package_dir)
def initialize(context):
utils.ToolInit("kupu Library Tool",
Modified: kupu/branch/plone-2.1/plone/beforeunload.kupu
==============================================================================
--- kupu/branch/plone-2.1/plone/beforeunload.kupu (original)
+++ kupu/branch/plone-2.1/plone/beforeunload.kupu Tue Jul 12 22:18:12 2005
@@ -10,7 +10,8 @@
<kupu:part name="jsincludes">
<tal:condition condition="python:here.kupu_library_tool.installBeforeUnload() and \
not path('haveBeforeUnload|nothing')">
- <script type="text/javascript" src="kupubeforeunload.js"
+ <script tal:condition="not:exists:portal/portal_javascripts"
+ type="text/javascript" src="kupubeforeunload.js"
tal:attributes="src string:${portal_url}/kupubeforeunload.js"
tal:define="global haveBeforeUnload python:True;"> </script>
</tal:condition>
Modified: kupu/branch/plone-2.1/plone/drawers.kupu
==============================================================================
--- kupu/branch/plone-2.1/plone/drawers.kupu (original)
+++ kupu/branch/plone-2.1/plone/drawers.kupu Tue Jul 12 22:18:12 2005
@@ -9,13 +9,9 @@
<kupu:id>$Id$</kupu:id>
<kupu:part name="styles">
- <link href="kupudrawerstyles.css" rel="stylesheet" type="text/css"
- tal:attributes="href string:${portal_url}/kupudrawerstyles.css" />
</kupu:part>
<kupu:part name="jsincludes">
- <script type="text/javascript" src="kupudrawers.js"
- tal:attributes="src string:${portal_url}/kupudrawers.js"> </script>
</kupu:part>
<kupu:part name="xmlconfig">
Modified: kupu/branch/plone-2.1/plone/head.kupu
==============================================================================
--- kupu/branch/plone-2.1/plone/head.kupu (original)
+++ kupu/branch/plone-2.1/plone/head.kupu Tue Jul 12 22:18:12 2005
@@ -1,3 +1,4 @@
+<?xml version="1.0" ?>
<kupu:feature
name="head"
implementation="plone"
@@ -8,13 +9,18 @@
<kupu:id>$Id$</kupu:id>
<kupu:part name="styles">
+ <tal:test condition="not:exists:portal/portal_css">
<link href="kupustyles.css" rel="stylesheet" type="text/css"
tal:attributes="href string:${portal_url}/kupustyles.css" />
<link href="kupuplone.css" rel="stylesheet" type="text/css"
tal:attributes="href string:${portal_url}/kupuplone.css" />
+ <link href="kupudrawerstyles.css" rel="stylesheet" type="text/css"
+ tal:attributes="href string:${portal_url}/kupudrawerstyles.css" />
+ </tal:test>
</kupu:part>
<kupu:part name="jsincludes">
+ <tal:test condition="not:exists:portal/portal_javascripts">
<script type="text/javascript"
tal:attributes="src string:${portal_url}/kupunoi18n.js"> </script>
<script type="text/javascript"
@@ -39,12 +45,19 @@
<script type="text/javascript"
tal:attributes="src string:${portal_url}/kupuploneui.js"> </script>
+ <script type="text/javascript" src="kupusourceedit.js"
+ tal:attributes="src string:${portal_url}/kupusourceedit.js"> </script>
+
+ <script type="text/javascript" src="kupudrawers.js"
+ tal:attributes="src string:${portal_url}/kupudrawers.js"> </script>
+ </tal:test>
</kupu:part>
<!-- XXX this could be a separate feature, maybe -->
<kupu:part name="bootstrap-editor">
- <script type="text/javascript" src="kupuploneinit.js"
- tal:attributes="src string:${portal_url}/kupuploneinit.js"> </script>
+ <script tal:condition="not:exists:portal/portal_javascripts"
+ type="text/javascript" src="kupuploneinit.js"
+ tal:attributes="src string:${portal_url}/kupuploneinit.js"> </script>
</kupu:part>
</kupu:feature>
Deleted: /kupu/branch/plone-2.1/plone/kupu_plone_layer/browserSupportsKupu.py
==============================================================================
--- /kupu/branch/plone-2.1/plone/kupu_plone_layer/browserSupportsKupu.py Tue Jul 12 \
22:18:12 2005
+++ (empty file)
@@ -1,56 +0,0 @@
-## Script (Python) "browserSupportsKupu"
-##title=Allow graceful degradation is browser isn't supported
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=useragent=''
-from Products.CMFCore.utils import getToolByName
-
-def numerics(s):
- '''Convert a string into a tuple of all digit sequences
- Since we are in a Zope script we can't use regexes, so lets go back to first \
principles.
- '''
- seq = ['']
- for c in s:
- if c.isdigit():
- seq[-1] = seq[-1] + c
- elif seq[-1]:
- seq.append('')
- return tuple([ int(val) for val in seq if val])
-
-pm = getToolByName(context, 'portal_membership')
-user = pm.getAuthenticatedMember()
-if user.getProperty('wysiwyg_editor').lower() != 'kupu':
- return False
-
-if not useragent:
- useragent = context.REQUEST['HTTP_USER_AGENT']
-
-
-if 'Opera' in useragent or 'BEOS' in useragent:
- return False
-
-if not useragent.startswith('Mozilla/'):
- return False
-
-try:
- mozillaver = numerics(useragent[len('Mozilla/'):].split(' ')[0])
- if mozillaver > (5,0):
- return True
- elif mozillaver == (5,0):
- rv = useragent.find(' rv:')
- if rv >= 0:
- verno = numerics(useragent[rv+4:].split(')')[0])
- return verno >= (1,3,1)
-
- MSIE = useragent.find('MSIE')
- if MSIE >= 0:
- verno = numerics(useragent[MSIE+4:].split(';')[0])
- return verno >= (5,5)
-
-except:
- # In case some weird browser makes the test code blow up.
- pass
-return False
Modified: kupu/branch/plone-2.1/plone/kupu_plone_layer/contentUsesKupu.py
==============================================================================
--- kupu/branch/plone-2.1/plone/kupu_plone_layer/contentUsesKupu.py (original)
+++ kupu/branch/plone-2.1/plone/kupu_plone_layer/contentUsesKupu.py Tue Jul 12 \
22:18:12 2005 @@ -8,15 +8,17 @@
##parameters=fieldname
from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByName
+tool = getToolByName(context, 'kupu_library_tool')
+REQUEST = context.REQUEST
+
# If the user doesn't have kupu configured then we can't use it.
-if not context.browserSupportsKupu():
+if not tool.isKupuEnabled(REQUEST=REQUEST):
return False
if not fieldname:
return True # Non AT content always tries to use kupu
-REQUEST = context.REQUEST
-
if fieldname == REQUEST.form.get('kupu.convert', ''):
return True
if fieldname == REQUEST.form.get('kupu.suppress', ''):
Modified: kupu/branch/plone-2.1/plone/kupu_plone_layer/kupu_wysiwyg_support.html
==============================================================================
--- kupu/branch/plone-2.1/plone/kupu_plone_layer/kupu_wysiwyg_support.html (original)
+++ kupu/branch/plone-2.1/plone/kupu_plone_layer/kupu_wysiwyg_support.html Tue Jul 12 \
22:18:12 2005 @@ -18,7 +18,7 @@
<!--$Id: drawers.kupu 12805 2005-05-26 14:38:24Z duncan $-->
<!--$Id: include.kupu 9520 2005-02-26 16:30:23Z duncan $-->
<!--$Id: wire.kupu 12436 2005-05-18 13:15:32Z duncan $-->
- <!--$Id: head.kupu 13354 2005-06-13 15:03:23Z paul $-->
+ <!--$Id: head.kupu 14296 2005-07-05 15:02:12Z duncan $-->
<!--$Id: xmlconfig.kupu 12437 2005-05-18 13:19:00Z duncan $-->
<!--$Id: body.kupu 12982 2005-06-01 15:12:55Z duncan $-->
<!--$Id: toolbar.kupu 12353 2005-05-16 12:29:05Z duncan $-->
@@ -76,11 +76,14 @@
<div class="kupu-fulleditor">
+ <tal:test condition="not:exists:portal/portal_css">
<link href="kupustyles.css" rel="stylesheet" type="text/css" \
tal:attributes="href string:${portal_url}/kupustyles.css"/>
<link href="kupuplone.css" rel="stylesheet" type="text/css" tal:attributes="href \
string:${portal_url}/kupuplone.css"/>
-
<link href="kupudrawerstyles.css" rel="stylesheet" type="text/css" \
tal:attributes="href string:${portal_url}/kupudrawerstyles.css"/> + </tal:test>
+
+ <tal:test condition="not:exists:portal/portal_javascripts">
<script type="text/javascript" tal:attributes="src \
string:${portal_url}/kupunoi18n.js"> </script>
<script type="text/javascript" tal:attributes="src \
string:${portal_url}/sarissa.js"> </script>
<script type="text/javascript" tal:attributes="src \
string:${portal_url}/sarissa_ieemu_xpath.js"> </script> @@ -94,16 +97,18 @@
<script type="text/javascript" tal:attributes="src \
string:${portal_url}/kupuploneeditor.js"> </script>
<script type="text/javascript" tal:attributes="src \
string:${portal_url}/kupuploneui.js"> </script>
+ <script type="text/javascript" src="kupusourceedit.js" tal:attributes="src \
string:${portal_url}/kupusourceedit.js"> </script> +
+ <script type="text/javascript" src="kupudrawers.js" tal:attributes="src \
string:${portal_url}/kupudrawers.js"> </script> + </tal:test>
<tal:condition condition="python:here.kupu_library_tool.installBeforeUnload() and \
not path('haveBeforeUnload|nothing')">
- <script type="text/javascript" src="kupubeforeunload.js" tal:attributes="src \
string:${portal_url}/kupubeforeunload.js" tal:define="global haveBeforeUnload \
python:True;"> </script> + <script \
tal:condition="not:exists:portal/portal_javascripts" type="text/javascript" \
src="kupubeforeunload.js" tal:attributes="src \
string:${portal_url}/kupubeforeunload.js" tal:define="global haveBeforeUnload \
python:True;"> </script> </tal:condition>
- <script type="text/javascript" src="kupusourceedit.js" tal:attributes="src \
string:${portal_url}/kupusourceedit.js"> </script>
- <script type="text/javascript" src="kupudrawers.js" tal:attributes="src \
string:${portal_url}/kupudrawers.js"> </script>
- <script type="text/javascript" src="kupuploneinit.js" tal:attributes="src \
string:${portal_url}/kupuploneinit.js"> </script> + <script \
tal:condition="not:exists:portal/portal_javascripts" type="text/javascript" \
src="kupuploneinit.js" tal:attributes="src string:${portal_url}/kupuploneinit.js"> \
</script>
<div class="kupu-tb" id="toolbar">
@@ -360,12 +365,15 @@
<div tal:condition="not:usekupu">
+ <tal:test condition="not:exists:portal/portal_css">
<link href="kupustyles.css" rel="stylesheet" type="text/css" \
tal:attributes="href string:${portal_url}/kupustyles.css"/>
<link href="kupuplone.css" rel="stylesheet" type="text/css" tal:attributes="href \
string:${portal_url}/kupuplone.css"/> + <link href="kupudrawerstyles.css" \
rel="stylesheet" type="text/css" tal:attributes="href \
string:${portal_url}/kupudrawerstyles.css"/> + </tal:test>
<tal:archetypes tal:condition="fieldName|nothing">
<div tal:condition="python:path('widget/allow_format_edit|python:True') and \
not path('kupu_convert_message_generated|nothing')">
- <a class="forcekupu" href="#" tal:condition="here/browserSupportsKupu" \
tal:attributes="href string:${request/URL0}?kupu.convert=${fieldName};" title="reload \
current page using kupu to edit this field"> + <a class="forcekupu" href="#" \
tal:condition="python:portal.kupu_library_tool.isKupuEnabled(REQUEST=context.REQUEST)" \
tal:attributes="href string:${request/URL0}?kupu.convert=${fieldName};" title="reload \
current page using kupu to edit this field"> edit with Kupu
</a>
</div>
@@ -386,7 +394,7 @@
<tal:noeditor tal:condition="not:usekupu">
<tal:archetypes tal:condition="fieldName|nothing">
<div metal:use-macro="here/widgets/visual/macros/area_format"/>
- <span tal:condition="here/browserSupportsKupu" tal:define="global \
kupu_convert_message_generated python:True"> + <span \
tal:condition="python:portal.kupu_library_tool.isKupuEnabled(REQUEST=context.REQUEST)" \
tal:define="global kupu_convert_message_generated python:True">
<a href="#" tal:attributes="href \
string:${request/URL0}?kupu.convert=${fieldName};">Convert to HTML and edit with \
Kupu</a></span> </tal:archetypes>
<tal:nonat condition="not:fieldName|nothing">
Modified: kupu/branch/plone-2.1/plone/kupu_plone_layer/wysiwyg_support.pt
==============================================================================
--- kupu/branch/plone-2.1/plone/kupu_plone_layer/wysiwyg_support.pt (original)
+++ kupu/branch/plone-2.1/plone/kupu_plone_layer/wysiwyg_support.pt Tue Jul 12 \
22:18:12 2005 @@ -4,6 +4,7 @@
<div metal:define-macro="wysiwygEditorBox">
<tal:block define="editor python: member.getProperty('wysiwyg_editor','').lower();
+ editor python: test(editor=='fck editor', 'editor_fck', editor);
support python: \
path('nocall:here/%s_wysiwyg_support|here/%s/wysiwyg_support|here/plone_wysiwyg/wysiwyg_support' \
% (editor, editor));" on-error="string:Kupu not installed correctly: \
${error/value}"> <metal:block metal:use-macro="support/macros/wysiwygEditorBox">
@@ -13,7 +14,8 @@
<div metal:define-macro="textFormatSelector">
- <tal:block define="editor python: member.getProperty('wysiwyg_editor','').lower();
+ <tal:block define="editor python: \
member.getProperty('wysiwyg_editor','').lower().replace(' ', '_'); + editor \
python: test(editor=='fck editor', 'editor_fck', editor);
support python: \
path('nocall:here/%s_wysiwyg_support|here/%s/wysiwyg_support|here/plone_wysiwyg/wysiwyg_support' \
% (editor, editor));" on-error="string:Kupu not installed correctly: \
${error/value}"> <metal:block metal:use-macro="support/macros/textFormatSelector">
Modified: kupu/branch/plone-2.1/plone/plonelibrarytool.py
==============================================================================
--- kupu/branch/plone-2.1/plone/plonelibrarytool.py (original)
+++ kupu/branch/plone-2.1/plone/plonelibrarytool.py Tue Jul 12 22:18:12 2005
@@ -23,11 +23,12 @@
from Globals import InitializeClass
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-from Products.CMFCore.utils import UniqueObject
+from Products.CMFCore.utils import UniqueObject, getToolByName
from Products.kupu.plone.librarytool import KupuLibraryTool
from Products.kupu.plone import permissions, scanner
from Products.kupu import kupu_globals
+from Products.kupu.config import TOOLNAME, TOOLTITLE
_default_libraries = (
dict(id="root",
@@ -71,9 +72,9 @@
class PloneKupuLibraryTool(UniqueObject, SimpleItem, KupuLibraryTool):
"""Plone specific version of the kupu library tool"""
- id = "kupu_library_tool"
+ id = TOOLNAME
meta_type = "Kupu Library Tool"
- title = "Kupu WYSIWYG editor configuration"
+ title = TOOLTITLE
security = ClassSecurityInfo()
# protect methods provided by super class KupuLibraryTool
@@ -112,7 +113,7 @@
try:
return self.table_classnames
except AttributeError:
- return ('plain', 'listing', 'grid', 'data')
+ return ('plain', 'listing', 'vertical listing', 'listing nosort')
security.declareProtected('View', "getParagraphStyles")
def getParagraphStyles(self):
@@ -146,6 +147,55 @@
def installBeforeUnload(self):
return getattr(self, 'install_beforeunload', True)
+ security.declareProtected('View', 'isKupuEnabled')
+ def isKupuEnabled(self, useragent='', REQUEST=None):
+ def numerics(s):
+ '''Convert a string into a tuple of all digit sequences
+ '''
+ seq = ['']
+ for c in s:
+ if c.isdigit():
+ seq[-1] = seq[-1] + c
+ elif seq[-1]:
+ seq.append('')
+ return tuple([ int(val) for val in seq if val])
+
+ # First check whether the user actually wants kupu
+ pm = getToolByName(self, 'portal_membership')
+ user = pm.getAuthenticatedMember()
+ if user.getProperty('wysiwyg_editor').lower() != 'kupu':
+ return False
+
+ # Then check whether their browser supports it.
+ if not useragent:
+ useragent = REQUEST['HTTP_USER_AGENT']
+
+ if 'Opera' in useragent or 'BEOS' in useragent:
+ return False
+
+ if not useragent.startswith('Mozilla/'):
+ return False
+
+ try:
+ mozillaver = numerics(useragent[len('Mozilla/'):].split(' ')[0])
+ if mozillaver > (5,0):
+ return True
+ elif mozillaver == (5,0):
+ rv = useragent.find(' rv:')
+ if rv >= 0:
+ verno = numerics(useragent[rv+4:].split(')')[0])
+ return verno >= (1,3,1)
+
+ MSIE = useragent.find('MSIE')
+ if MSIE >= 0:
+ verno = numerics(useragent[MSIE+4:].split(';')[0])
+ return verno >= (5,5)
+
+ except:
+ # In case some weird browser makes the test code blow up.
+ pass
+ return False
+
# ZMI views
manage_options = (SimpleItem.manage_options[1:] + (
dict(label='Config', action='kupu_config'),
Modified: kupu/branch/plone-2.1/plone/sourceedit.kupu
==============================================================================
--- kupu/branch/plone-2.1/plone/sourceedit.kupu (original)
+++ kupu/branch/plone-2.1/plone/sourceedit.kupu Tue Jul 12 22:18:12 2005
@@ -9,8 +9,6 @@
<kupu:id>$Id$</kupu:id>
<kupu:part name="jsincludes">
- <script type="text/javascript" src="kupusourceedit.js"
- tal:attributes="src string:${portal_url}/kupusourceedit.js"> </script>
</kupu:part>
</kupu:feature>
Modified: kupu/branch/plone-2.1/plone/tests/test_browserSupportsKupu.py
==============================================================================
--- kupu/branch/plone-2.1/plone/tests/test_browserSupportsKupu.py (original)
+++ kupu/branch/plone-2.1/plone/tests/test_browserSupportsKupu.py Tue Jul 12 22:18:12 \
2005 @@ -27,8 +27,9 @@
md._updateProperty('wysiwyg_editor', 'Kupu')
self.qi = self.portal.portal_quickinstaller
self.qi.installProduct('kupu')
- self.script = self.portal.portal_skins.kupu_plone.browserSupportsKupu
-
+ #self.script = self.portal.portal_skins.kupu_plone.browserSupportsKupu
+ self.script = self.portal.kupu_library_tool.isKupuEnabled
+
# List of tuples of id, signature, os, version, browser
# browsers are:
# 1, MOZILLA -- supported 1.4 and above
@@ -396,13 +397,11 @@
createTests()
+from unittest import TestSuite, makeSuite
+def test_suite():
+ suite = TestSuite()
+ suite.addTest(makeSuite(TestBrowserSupportsKupu))
+ return suite
+
if __name__ == '__main__':
framework()
-else:
- # While framework.py provides its own test_suite()
- # method the testrunner utility does not.
- from unittest import TestSuite, makeSuite
- def test_suite():
- suite = TestSuite()
- suite.addTest(makeSuite(TestPythonScript))
- return suite
Modified: kupu/branch/plone-2.1/plone/wysiwyg_support.kupu
==============================================================================
--- kupu/branch/plone-2.1/plone/wysiwyg_support.kupu (original)
+++ kupu/branch/plone-2.1/plone/wysiwyg_support.kupu Tue Jul 12 22:18:12 2005
@@ -42,7 +42,8 @@
<tal:archetypes tal:condition="fieldName|nothing">
<div
tal:condition="python:path('widget/allow_format_edit|python:True') and not \
path('kupu_convert_message_generated|nothing')">
- <a class="forcekupu" href="#" tal:condition="here/browserSupportsKupu"
+ <a class="forcekupu" href="#"
+ tal:condition="python:portal.kupu_library_tool.isKupuEnabled(REQUEST=context.REQUEST)"
tal:attributes="href string:${request/URL0}?kupu.convert=${fieldName};"
title="reload current page using kupu to edit this field">
edit with Kupu
@@ -81,7 +82,7 @@
<tal:noeditor tal:condition="not:usekupu">
<tal:archetypes tal:condition="fieldName|nothing">
<div metal:use-macro="here/widgets/visual/macros/area_format" />
- <span tal:condition="here/browserSupportsKupu"
+ <span tal:condition="python:portal.kupu_library_tool.isKupuEnabled(REQUEST=context.REQUEST)"
tal:define="global kupu_convert_message_generated python:True">
<a href="#"
tal:attributes="href \
string:${request/URL0}?kupu.convert=${fieldName};">Convert to HTML and edit with \
Kupu</a></span>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic