[kupu-checkins] r35477 - in kupu/trunk/kupu/plone: . kupu_plone_layer kupu_plone_layer/plonekupuimages

duncan at codespeak.net duncan at codespeak.net
Fri Dec 8 14:20:43 CET 2006


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 @@
   <kupu:part name="jsincludes">
   </kupu:part>
 
+  <kupu:part name="buttons">
+    <span class="kupu-tb-buttongroup" tal:condition="filter/bg-drawers">
+      <button type="button" class="kupu-image"
+              tal:condition="filter/imagelibdrawer-button"
+              id="kupu-imagelibdrawer-button"
+              title="Insert image" i18n:attributes="title"
+        >&#160;</button>
+      <button type="button" class="kupu-inthyperlink"
+              tal:condition="filter/linklibdrawer-button"
+              id="kupu-linklibdrawer-button"
+              title="Insert internal link"
+        i18n:attributes="title">&#160;</button>
+      <button type="button" class="kupu-exthyperlink"
+              tal:condition="filter/linkdrawer-button"
+              id="kupu-linkdrawer-button"
+              title="Insert external link"
+        i18n:attributes="title">&#160;</button>
+      <button type="button" class="kupu-anchors"
+              tal:condition="filter/anchors-button"
+              id="kupu-anchors"
+              title="Insert anchors" i18n:attributes="title">&#160;</button>
+      <button type="button" class="kupu-table"
+              tal:condition="filter/tabledrawer-button"
+              id="kupu-tabledrawer-button"
+              title="Insert table" i18n:attributes="title"
+        >&#160;</button>
+    </span>
+  </kupu:part>
+
   <kupu:part name="xmlconfig">
     <tal:var define="field field|nothing;
             tool here/kupu_library_tool;

Added: kupu/trunk/kupu/plone/helpers.py
==============================================================================
--- (empty file)
+++ kupu/trunk/kupu/plone/helpers.py	Fri Dec  8 14:20:38 2006
@@ -0,0 +1,80 @@
+##############################################################################
+#
+# Copyright (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
+# Contributors see CREDITS.txt.
+#
+##############################################################################
+# Helper classes
+FILTERS = [
+    ('bg-basicmarkup', 'Bold/Italic group', True),
+    ('bold-button', 'Bold button', True),
+    ('italic-button', 'Italic button', True),
+    ('bg-subsuper', 'Subscript/Superscript group', True),
+    ('subscript-button', 'Subscript button', True),
+    ('superscript-button', 'Superscript button', True),
+    ('bg-justify', 'Justify group', True),
+    ('justifyleft-button', 'Justify left button', True),
+    ('justifycenter-button', 'Justify center button', True),
+    ('justifyright-button', 'Justify right button', True),
+    ('bg-list', 'List group', True),
+    ('list-ol-addbutton', 'Add ordered list button', True),
+    ('list-ul-addbutton', 'Add unordered list button', True),
+    ('definitionlist', 'Definition list', True),
+    ('bg-indent', 'Indent group', True),
+    ('outdent-button', 'Outdent button', True),
+    ('indent-button', 'Indent button', True),
+    ('bg-drawers', 'Drawers group', True),
+    ('imagelibdrawer-button', 'Image drawer button', True),
+    ('linklibdrawer-button', 'Link drawer button', True),
+    ('linkdrawer-button', 'External link drawer button', True),
+    ('anchors-button', 'Anchor drawer button', True),
+    ('tabledrawer-button', 'Table drawer button', True),
+    ('bg-remove', 'Remove group', True),
+    ('removeimage-button', 'Remove image button', True),
+    ('removelink-button', 'Remove link button', True),
+    ('bg-undo', 'Undo group', True),
+    ('undo-button', 'Undo button', True),
+    ('redo-button', 'Redo button', True),
+    ('spellchecker', 'Spellchecker', False),
+    ('source', 'Source', True),
+    ('styles', 'Styles pulldown', True),
+    ('ulstyles', 'Unordered list style pulldown', True),
+    ('olstyles', 'Ordered list style pulldown', True),
+    ('zoom', 'Zoom button', True),
+]
+FILTERDICT = dict([(k,v) for (k,title,v) in FILTERS])
+
+class ButtonFilter:
+    """Helper class to control visibility of buttons.
+    Works from both a whitelist and a blacklist in the widget.
+    XXX Add expressions to the configlet so that a button may be hidden conditionally.
+    """
+    __allow_access_to_unprotected_subobjects__ = 1
+
+    def __init__(self, tool, context, field=None):
+        self.tool = tool
+        self.field = field
+        widget = getattr(field, 'widget', None)
+        self.filter_buttons = getattr(widget, 'filter_buttons', None)
+        self.allow_buttons = getattr(widget, 'allow_buttons', None)
+        self.visible_buttons = tool.getToolbarFilters(context, field)
+        print "visible=", self.visible_buttons
+
+    def isButtonAllowed(self, name):
+        visible = self.visible_buttons.get(name, True)
+        if self.allow_buttons is not None:
+            return visible and name in self.allow_buttons
+        if self.filter_buttons is not None:
+           return visible and name not in self.filter_buttons
+        return visible
+
+    def __getattr__(self, name):
+        """name should be an id of a button or a button group in the kupu toolbar."""
+        if name[0]=='_':
+            raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
+        allowed = self.isButtonAllowed(name)
+        print "ButtonFilter",name,"->",allowed
+        return allowed

Modified: kupu/trunk/kupu/plone/kupu_config.pt
==============================================================================
--- kupu/trunk/kupu/plone/kupu_config.pt	(original)
+++ kupu/trunk/kupu/plone/kupu_config.pt	Fri Dec  8 14:20:38 2006
@@ -33,7 +33,7 @@
     <!-- simulating views -->
     <ul class="contentViews"
        tal:define="tabs python:('Config','kupu_config'),('Libraries','zmi_libraries'),('Resource Types','zmi_resource_types'),
-        ('Documentation', 'zmi_docs'),('Links', 'zmi_links'),;
+        ('Documentation', 'zmi_docs'),('Links', 'zmi_links'),('Toolbar', 'zmi_toolbar'),;
                    tabs python:[ {'label':label, 'name':name} for (label,name) in tabs ];"
     >
         <li tal:repeat="tab tabs"

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	Fri Dec  8 14:20:38 2006
@@ -20,7 +20,7 @@
     <!--$Id: include.kupu 9520 2005-02-26 16:30:23Z duncan $-->
     <!--$Id: wire.kupu 25247 2006-04-03 11:23:02Z fschulze $-->
     <!--$Id: head.kupu 34332 2006-11-07 14:50:40Z duncan $-->
-    <!--$Id: xmlconfig.kupu 30512 2006-07-25 10:17:05Z duncan $-->
+    <!--$Id: xmlconfig.kupu 35367 2006-12-06 09:06:21Z duncan $-->
     <!--$Id: body.kupu 34311 2006-11-07 11:18:23Z duncan $-->
     <!--$Id: toolbar.kupu 25717 2006-04-12 10:33:01Z fschulze $-->
     <!--$Id: drawers.kupu 21175 2005-12-15 14:25:08Z duncan $-->
@@ -117,89 +117,89 @@
   
     <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">
+    <div class="kupu-tb" id="toolbar" tal:define="tool context/kupu_library_tool;field field|nothing;filter python:tool.filterToolbar(context,field);">
       
     <span id="kupu-tb-buttons" class="kupu-tb-buttons">
       
   
-    <span class="kupu-tb-buttongroup" style="float: right" id="kupu-zoom">
+    <span class="kupu-tb-buttongroup" style="float: right" id="kupu-zoom" tal:condition="filter/zoom">
       <button type="button" class="kupu-zoom" id="kupu-zoom-button" i18n:attributes="title" title="Zoom: Access key (Alt or Ctrl) + X" accesskey="x">&#160;</button>
     </span>
   
-    <span class="kupu-tb-buttongroup" id="kupu-bg-basicmarkup">
-      <button type="button" class="kupu-bold" id="kupu-bold-button" title="Bold: Access key (Alt or Ctrl) + B" i18n:attributes="title" accesskey="b">&#160;</button>
-      <button type="button" class="kupu-italic" id="kupu-italic-button" title="Italic: Access key (Alt or Ctrl) + I" i18n:attributes="title" accesskey="i">&#160;</button>
+    <span class="kupu-tb-buttongroup" id="kupu-bg-basicmarkup" tal:condition="filter/bg-basicmarkup">
+      <button type="button" class="kupu-bold" id="kupu-bold-button" title="Bold: Access key (Alt or Ctrl) + B" tal:condition="filter/bold-button" i18n:attributes="title" accesskey="b">&#160;</button>
+      <button type="button" class="kupu-italic" id="kupu-italic-button" title="Italic: Access key (Alt or Ctrl) + I" tal:condition="filter/italic-button" i18n:attributes="title" accesskey="i">&#160;</button>
     </span>
   
-    <span class="kupu-tb-buttongroup" id="kupu-bg-subsuper">
-      <button type="button" class="kupu-subscript" id="kupu-subscript-button" title="Subscript: Access key (Alt or Ctrl) + -" i18n:attributes="title" accesskey="-">&#160;</button>
-      <button type="button" class="kupu-superscript" id="kupu-superscript-button" title="Superscript: Access key (Alt or Ctrl) + +" i18n:attributes="title" accesskey="+">&#160;</button>
+    <span class="kupu-tb-buttongroup" id="kupu-bg-subsuper" tal:condition="filter/bg-subsuper">
+      <button type="button" class="kupu-subscript" id="kupu-subscript-button" title="Subscript: Access key (Alt or Ctrl) + -" tal:condition="filter/subscript-button" i18n:attributes="title" accesskey="-">&#160;</button>
+      <button type="button" class="kupu-superscript" id="kupu-superscript-button" title="Superscript: Access key (Alt or Ctrl) + +" tal:condition="filter/superscript-button" i18n:attributes="title" accesskey="+">&#160;</button>
     </span>
   
-    <span class="kupu-tb-buttongroup" id="kupu-bg-justify">
-      <button type="button" class="kupu-justifyleft" id="kupu-justifyleft-button" title="Left justify: Access key (Alt or Ctrl) + L" i18n:attributes="title" accesskey="l">&#160;</button>
-      <button type="button" class="kupu-justifycenter" id="kupu-justifycenter-button" title="Center justify: Access key (Alt or Ctrl) + C" i18n:attributes="title" accesskey="c">&#160;</button>
-      <button type="button" class="kupu-justifyright" id="kupu-justifyright-button" title="Right justify: Access key (Alt or Ctrl) + R" i18n:attributes="title" accesskey="r">&#160;</button>
+    <span class="kupu-tb-buttongroup" id="kupu-bg-justify" tal:condition="filter/bg-justify">
+      <button type="button" class="kupu-justifyleft" id="kupu-justifyleft-button" tal:condition="filter/justifyleft-button" title="Left justify: Access key (Alt or Ctrl) + L" i18n:attributes="title" accesskey="l">&#160;</button>
+      <button type="button" class="kupu-justifycenter" tal:condition="filter/justifycenter-button" id="kupu-justifycenter-button" title="Center justify: Access key (Alt or Ctrl) + C" i18n:attributes="title" accesskey="c">&#160;</button>
+      <button type="button" class="kupu-justifyright" tal:condition="filter/justifyright-button" id="kupu-justifyright-button" title="Right justify: Access key (Alt or Ctrl) + R" i18n:attributes="title" accesskey="r">&#160;</button>
     </span>
   
-              <span class="kupu-tb-buttongroup" id="kupu-bg-list">
+    <span class="kupu-tb-buttongroup" id="kupu-bg-list" tal:condition="filter/bg-list">
       
-      <button type="button" class="kupu-insertorderedlist" title="Numbered list: Access key (Alt or Ctrl) + #" id="kupu-list-ol-addbutton" i18n:attributes="title" accesskey="#">&#160;</button>
-      <button type="button" class="kupu-insertunorderedlist" title="Unordered list: Access key (Alt or Ctrl) + *" id="kupu-list-ul-addbutton" i18n:attributes="title" accesskey="*">&#160;</button>
+      <button type="button" class="kupu-insertorderedlist" tal:condition="filter/list-ol-addbutton" title="Numbered list: Access key (Alt or Ctrl) + #" id="kupu-list-ol-addbutton" i18n:attributes="title" accesskey="#">&#160;</button>
+      <button type="button" class="kupu-insertunorderedlist" tal:condition="filter/list-ul-addbutton" title="Unordered list: Access key (Alt or Ctrl) + *" id="kupu-list-ul-addbutton" i18n:attributes="title" accesskey="*">&#160;</button>
               </span>
   
-    <span class="kupu-tb-buttongroup" id="kupu-bg-definitionlist">
+    <span class="kupu-tb-buttongroup" id="kupu-bg-definitionlist" tal:condition="filter/definitionlist">
       
       <button type="button" class="kupu-insertdefinitionlist" title="Definition list: Access key (Alt or Ctrl) + =" id="kupu-list-dl-addbutton" i18n:attributes="title" accesskey="=">&#160;</button>
     </span>
   
-    <span class="kupu-tb-buttongroup" id="kupu-bg-indent">
-      <button type="button" class="kupu-outdent" id="kupu-outdent-button" title="Decrease quote level: Access key (Alt or Ctrl) + &lt;" i18n:attributes="title" accesskey="&lt;">&#160;</button>
-      <button type="button" class="kupu-indent" id="kupu-indent-button" title="Increase quote level: Access key (Alt or Ctrl) + &gt;" i18n:attributes="title" accesskey="&gt;">&#160;</button>
+    <span class="kupu-tb-buttongroup" id="kupu-bg-indent" tal:condition="filter/bg-indent">
+      <button type="button" class="kupu-outdent" tal:condition="filter/outdent-button" id="kupu-outdent-button" title="Decrease quote level: Access key (Alt or Ctrl) + &lt;" i18n:attributes="title" accesskey="&lt;">&#160;</button>
+      <button type="button" class="kupu-indent" tal:condition="filter/indent-button" id="kupu-indent-button" title="Increase quote level: Access key (Alt or Ctrl) + &gt;" i18n:attributes="title" accesskey="&gt;">&#160;</button>
     </span>
   
-    <span class="kupu-tb-buttongroup">
-      <button type="button" class="kupu-image" id="kupu-imagelibdrawer-button" title="Insert image" i18n:attributes="title">&#160;</button>
-      <button type="button" class="kupu-inthyperlink" id="kupu-linklibdrawer-button" title="Insert internal link" i18n:attributes="title">&#160;</button>
-      <button type="button" class="kupu-exthyperlink" id="kupu-linkdrawer-button" title="Insert external link" i18n:attributes="title">&#160;</button>
-      <button type="button" class="kupu-anchors" id="kupu-anchors" title="Insert anchors" i18n:attributes="title">&#160;</button>
-      <button type="button" class="kupu-table" id="kupu-tabledrawer-button" title="Insert table" i18n:attributes="title">&#160;</button>
+    <span class="kupu-tb-buttongroup" tal:condition="filter/bg-drawers">
+      <button type="button" class="kupu-image" tal:condition="filter/imagelibdrawer-button" id="kupu-imagelibdrawer-button" title="Insert image" i18n:attributes="title">&#160;</button>
+      <button type="button" class="kupu-inthyperlink" tal:condition="filter/linklibdrawer-button" id="kupu-linklibdrawer-button" title="Insert internal link" i18n:attributes="title">&#160;</button>
+      <button type="button" class="kupu-exthyperlink" tal:condition="filter/linkdrawer-button" id="kupu-linkdrawer-button" title="Insert external link" i18n:attributes="title">&#160;</button>
+      <button type="button" class="kupu-anchors" tal:condition="filter/anchors-button" id="kupu-anchors" title="Insert anchors" i18n:attributes="title">&#160;</button>
+      <button type="button" class="kupu-table" tal:condition="filter/tabledrawer-button" id="kupu-tabledrawer-button" title="Insert table" i18n:attributes="title">&#160;</button>
     </span>
   
-    <span class="kupu-tb-buttongroup" id="kupu-bg-remove">
-      <button type="button" class="kupu-removeimage invisible" id="kupu-removeimage-button" title="Remove image" i18n:attributes="title">&#160;</button>
-      <button type="button" class="kupu-removelink invisible" id="kupu-removelink-button" title="Remove link" i18n:attributes="title">&#160;</button>
+    <span class="kupu-tb-buttongroup" id="kupu-bg-remove" tal:condition="filter/bg-remove">
+      <button type="button" class="kupu-removeimage invisible" tal:condition="filter/removeimage-button" id="kupu-removeimage-button" title="Remove image" i18n:attributes="title">&#160;</button>
+      <button type="button" class="kupu-removelink invisible" tal:condition="filter/removelink-button" id="kupu-removelink-button" title="Remove link" i18n:attributes="title">&#160;</button>
     </span>
   
-    <span class="kupu-tb-buttongroup" id="kupu-bg-undo">
-      <button type="button" class="kupu-undo" id="kupu-undo-button" title="Undo: Access key (Alt or Ctrl) + Z" i18n:attributes="title" accesskey="z">&#160;</button>
-      <button type="button" class="kupu-redo" id="kupu-redo-button" title="Redo: Access key (Alt or Ctrl) + Y" i18n:attributes="title" accesskey="y">&#160;</button>
+    <span class="kupu-tb-buttongroup" id="kupu-bg-undo" tal:condition="filter/bg-undo">
+      <button type="button" class="kupu-undo" tal:condition="filter/undo-button" id="kupu-undo-button" title="Undo: Access key (Alt or Ctrl) + Z" i18n:attributes="title" accesskey="z">&#160;</button>
+      <button type="button" class="kupu-redo" tal:condition="filter/redo-button" id="kupu-redo-button" title="Redo: Access key (Alt or Ctrl) + Y" i18n:attributes="title" accesskey="y">&#160;</button>
     </span>
   
     <span class="kupu-tb-buttongroup kupu-spellchecker-span" id="kupu-spellchecker">
       <button type="button" class="kupu-spellchecker" id="kupu-spellchecker-button" title="Check spelling" i18n:attributes="title">&#160;</button>
     </span>
   
-    <span class="kupu-tb-buttongroup kupu-source-span" id="kupu-source">
+    <span class="kupu-tb-buttongroup kupu-source-span" id="kupu-source" tal:condition="filter/source">
       <button type="button" class="kupu-source" id="kupu-source-button" title="Switch between visual editor and HTML view" i18n:attributes="title toggle_source_view;" accesskey="h">&#160;</button>
     </span>
   
-    <select class="kupu-tb-styles" tal:define="gstyles here/kupu_library_tool/getParagraphStyles|python:[];                 lstyles field/widget/parastyles|python:[];                 allstyles python:list(gstyles)+list(lstyles);">
+    <select class="kupu-tb-styles" tal:condition="filter/styles" tal:define="styles python:tool.getStyleList(field);">
       <option value="p" i18n:translate="">Normal</option>
-      <tal:block condition="allstyles|nothing" repeat="style allstyles">
-        <option i18n:translate="" tal:define="parts python:style.split('|',1)+['','']" tal:attributes="value python:parts[1]" tal:content="python:parts[0]"/>
+      <tal:block condition="styles" repeat="style styles">
+        <option i18n:translate="" tal:attributes="value style/value" tal:content="style/content"/>
       </tal:block>
     </select>
   
     </span>
   
-    <select id="kupu-ulstyles" class="kupu-ulstyles">
+    <select id="kupu-ulstyles" class="kupu-ulstyles" tal:condition="filter/ulstyles">
       <option value="disc" i18n:translate="list-disc">&#9679;</option>
       <option value="square" i18n:translate="list-square">&#9632;</option>
       <option value="circle" i18n:translate="list-circle">&#9675;</option>
       <option value="none" i18n:translate="list-nobullet">no bullet</option>
     </select>
-    <select id="kupu-olstyles" class="kupu-olstyles">
+    <select id="kupu-olstyles" class="kupu-olstyles" tal:condition="filter/olstyles">
       <option value="decimal" i18n:translate="list-decimal">1</option>
       <option value="upper-roman" i18n:translate="list-upperroman">I</option>
       <option value="lower-roman" i18n:translate="list-lowerroman">i</option>

Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml	(original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml	Fri Dec  8 14:20:38 2006
@@ -147,7 +147,7 @@
 .kupu-inthyperlink-pressed {
   border-color: &dtml-buttonshadow; &dtml-buttonhighlight; &dtml-buttonhighlight; &dtml-buttonshadow;;
 }
-.kupu-exthyperlink {background-image: url("&dtml-portal_url;/link_icon.gif");}
+.kupu-exthyperlink {background-image: url("&dtml-portal_url;/plonekupuimages/link_icon.gif");}
 .kupu-exthyperlink-pressed {
   border-color: &dtml-buttonshadow; &dtml-buttonhighlight; &dtml-buttonhighlight; &dtml-buttonshadow;;
 }

Added: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/link_icon.gif
==============================================================================
Binary file. No diff available.

Modified: kupu/trunk/kupu/plone/librarytool.py
==============================================================================
--- kupu/trunk/kupu/plone/librarytool.py	(original)
+++ kupu/trunk/kupu/plone/librarytool.py	Fri Dec  8 14:20:38 2006
@@ -227,3 +227,39 @@
                 return expr(context)
         return url
 
+    def _setToolbarFilters(self, filters):
+        """Set the toolbar filtering
+        filter is a list of records with: id, visible, override"""
+        clean = {}
+        for f in filters:
+            id = f.id
+            visible = bool(getattr(f, 'visible', False))
+            expr = getattr(f, 'override', None)
+
+            if not id:
+                continue
+
+            if expr:
+                expr = Expression(expr)
+            else:
+                expr = None
+            clean[id] = dict(id=id, visible=visible, override=expr)
+
+        self._toolbar_filters = clean
+
+    def getToolbarFilters(self, context, field=None):
+        expr_context = self._getExpressionContext(context)
+        expr_context.setGlobal('field', field)
+        filters = getattr(self, '_toolbar_filters', {})
+        visible = {}
+        for k in filters:
+            f = filters[k]
+            override = f.get('override', None)
+            if override:
+                visible[k] = override(expr_context)
+            else:
+                visible[k] = f['visible']
+        return visible
+
+    def _getToolbarFilterOptions(self):
+        return getattr(self, '_toolbar_filters', {})

Modified: kupu/trunk/kupu/plone/plonelibrarytool.py
==============================================================================
--- kupu/trunk/kupu/plone/plonelibrarytool.py	(original)
+++ kupu/trunk/kupu/plone/plonelibrarytool.py	Fri Dec  8 14:20:38 2006
@@ -28,7 +28,7 @@
 from Products.PythonScripts.standard import Object
 
 from Products.kupu.plone.librarytool import KupuLibraryTool
-from Products.kupu.plone import permissions, scanner, plonedrawers, util
+from Products.kupu.plone import permissions, scanner, plonedrawers, util, helpers
 from Products.kupu import kupu_globals
 from Products.kupu.config import TOOLNAME, TOOLTITLE
 from StringIO import StringIO
@@ -157,6 +157,66 @@
         except AttributeError:
             return _default_paragraph_styles
 
+    security.declareProtected('View', "getStyleList")
+    def getStyleList(self, field=None):
+        """Return the paragraph styles for a field."""
+        gstyles = self.getParagraphStyles()
+        if field:
+            widget = field.widget
+            redefine = getattr(widget, 'redefine_parastyles', False)
+            lstyles = getattr(widget, 'parastyles', ())
+        else:
+            redefine = False
+            lstyles = False
+
+        result = []
+        if redefine:
+            styles = lstyles
+        else:
+            styles = list(gstyles) + list(lstyles)
+            
+        for style in styles:
+            parts = style.split('|',1)+['','']
+            value = parts[1]
+            content = parts[0]
+            result.append({'value':value, 'content':content})
+
+        return result
+
+    security.declareProtected('View', "filterToolbar")
+    def filterToolbar(self, context, field=None):
+        return helpers.ButtonFilter(self, context, field)
+
+    security.declareProtected('View', "getFilterOptions")
+    def getFilterOptions(self, field=None):
+        filters = helpers.FILTERS
+        config = self._getToolbarFilterOptions()
+        res = []
+        for (id, title, default) in filters:
+            cfg = config.get(id, {})
+            visible = cfg.get('visible', default)
+            expr = cfg.get('override', None)
+            if expr is not None:
+                expr = expr.text
+            res.append(dict(id=id, title=title, visible=visible, override=expr))
+        return res
+
+    security.declareProtected(permissions.ManageLibraries, "set_toolbar_filters")
+    def set_toolbar_filters(self, filters, REQUEST=None):
+        """Set the toolbar filtering
+        filter is a list of records with: id, checked, expression"""
+        DEFAULTS = helpers.FILTERDICT
+        def nonstandard(f):
+            expr = f['override']
+            id = f['id']
+            visible = bool(f.get('visible', False))
+            return expr != '' or visible != DEFAULTS.get(id, False)
+            
+        cleaned = [ f for f in filters if nonstandard(f) ]
+        self._setToolbarFilters(filters)
+        if REQUEST:
+            REQUEST.RESPONSE.redirect(self.absolute_url() + '/zmi_toolbar')
+
     security.declareProtected('View', "getHtmlExclusions")
     def getHtmlExclusions(self):
         try:
@@ -418,6 +478,10 @@
     zmi_links = PageTemplateFile("zmi_links.pt", globals())
     zmi_links.title = 'kupu link maintenance'
 
+    security.declareProtected(permissions.ManageLibraries, "zmi_toolbar")
+    zmi_toolbar = PageTemplateFile("zmi_toolbar.pt", globals())
+    zmi_toolbar.title = 'kupu toolbar customisation'
+
     security.declareProtected(permissions.ManageLibraries, "zmi_docs")
     zmi_docs = PageTemplateFile("zmi_docs.pt", globals())
     zmi_docs.title = 'kupu configuration documentation'

Modified: kupu/trunk/kupu/plone/sourceedit.kupu
==============================================================================
--- kupu/trunk/kupu/plone/sourceedit.kupu	(original)
+++ kupu/trunk/kupu/plone/sourceedit.kupu	Fri Dec  8 14:20:38 2006
@@ -4,11 +4,24 @@
     implementation="plone"
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:kupu="http://kupu.oscom.org/namespaces/dist"
+    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
     xmlns:tal="http://xml.zope.org/namespaces/tal"
     >
     <kupu:id>$Id$</kupu:id>
 
   <kupu:part name="jsincludes">
   </kupu:part>
+  <kupu:part name="buttons">
+    <span class="kupu-tb-buttongroup kupu-source-span" id="kupu-source"
+          tal:condition="filter/source">
+      <button type="button"
+              class="kupu-source"
+              id="kupu-source-button"
+              title="Switch between visual editor and HTML view"
+              i18n:attributes="title toggle_source_view;"
+              accesskey="h"
+              >&#160;</button>
+    </span>
+  </kupu:part>
 
 </kupu:feature>

Added: kupu/trunk/kupu/plone/spellchecker.kupu
==============================================================================
--- (empty file)
+++ kupu/trunk/kupu/plone/spellchecker.kupu	Fri Dec  8 14:20:38 2006
@@ -0,0 +1,24 @@
+<?xml version="1.0" ?>
+<kupu:feature
+    name="spellchecker"
+    implementation="default"
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:kupu="http://kupu.oscom.org/namespaces/dist"
+    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+    i18n:domain="kupu"
+    >
+  <kupu:id>$Id: sourceedit.kupu 9779 2005-03-15 11:34:47Z duncan $</kupu:id>
+
+  <kupu:part name="buttons">
+    <span class="kupu-tb-buttongroup kupu-spellchecker-span"
+        id="kupu-spellchecker" tal:condition="filter/spellchecker">
+      <button type="button"
+              class="kupu-spellchecker"
+              id="kupu-spellchecker-button"
+              title="Check spelling"
+              i18n:attributes="title"
+              >&#160;</button>
+    </span>
+  </kupu:part>
+
+</kupu:feature>

Modified: kupu/trunk/kupu/plone/toolbar.kupu
==============================================================================
--- kupu/trunk/kupu/plone/toolbar.kupu	(original)
+++ kupu/trunk/kupu/plone/toolbar.kupu	Fri Dec  8 14:20:38 2006
@@ -8,30 +8,158 @@
     >
 <kupu:id>$Id$</kupu:id>
 
+  <kupu:part name="toolbar">
+    <div class="kupu-tb" id="toolbar"
+         tal:define="tool context/kupu_library_tool;field field|nothing;filter python:tool.filterToolbar(context,field);">
+      <kupu:define-slot name="toolbar" />
+    </div>
+  </kupu:part>
+
   <kupu:part name="logo">
   </kupu:part>
 
+  <kupu:part name="zoom">
+    <span class="kupu-tb-buttongroup" style="float: right" id="kupu-zoom"
+          tal:condition="filter/zoom">
+      <button type="button" class="kupu-zoom" id="kupu-zoom-button"
+              i18n:attributes="title"
+              title="Zoom: Access key (Alt or Ctrl) + X" accesskey="x">&#160;</button>
+    </span>
+  </kupu:part>
+
+
+  <kupu:part name="buttongroup-basicmarkup">
+    <span class="kupu-tb-buttongroup" id="kupu-bg-basicmarkup" tal:condition="filter/bg-basicmarkup">
+      <button type="button" class="kupu-bold" id="kupu-bold-button"
+              title="Bold: Access key (Alt or Ctrl) + B"
+              tal:condition="filter/bold-button"
+              i18n:attributes="title" accesskey="b">&#160;</button>
+      <button type="button" class="kupu-italic" id="kupu-italic-button"
+              title="Italic: Access key (Alt or Ctrl) + I"
+              tal:condition="filter/italic-button"
+              i18n:attributes="title" accesskey="i">&#160;</button>
+    </span>
+  </kupu:part>
+  <kupu:part name="buttongroup-subsuper">
+    <span class="kupu-tb-buttongroup" id="kupu-bg-subsuper" tal:condition="filter/bg-subsuper">
+      <button type="button" class="kupu-subscript" id="kupu-subscript-button" title="Subscript: Access key (Alt or Ctrl) + -"
+              tal:condition="filter/subscript-button"
+              i18n:attributes="title" accesskey="-">&#160;</button>
+      <button type="button" class="kupu-superscript" id="kupu-superscript-button" title="Superscript: Access key (Alt or Ctrl) + +"
+              tal:condition="filter/superscript-button"
+              i18n:attributes="title" accesskey="+">&#160;</button>
+    </span>
+  </kupu:part>
+
+  <kupu:part name="buttongroup-justify">
+    <span class="kupu-tb-buttongroup" id="kupu-bg-justify" tal:condition="filter/bg-justify">
+      <button type="button" class="kupu-justifyleft" id="kupu-justifyleft-button" 
+              tal:condition="filter/justifyleft-button"
+              title="Left justify: Access key (Alt or Ctrl) + L" i18n:attributes="title"
+              accesskey="l">&#160;</button>
+      <button type="button" class="kupu-justifycenter" 
+              tal:condition="filter/justifycenter-button"
+              id="kupu-justifycenter-button" title="Center justify: Access key (Alt or Ctrl) + C" 
+              i18n:attributes="title" accesskey="c">&#160;</button>
+      <button type="button" class="kupu-justifyright" 
+              tal:condition="filter/justifyright-button"
+              id="kupu-justifyright-button" title="Right justify: Access key (Alt or Ctrl) + R"
+              i18n:attributes="title" accesskey="r">&#160;</button>
+    </span>
+  </kupu:part>
+
+  <kupu:part name="buttongroup-list">
+    <span class="kupu-tb-buttongroup" id="kupu-bg-list" tal:condition="filter/bg-list">
+      <!-- list button events are set on the list tool -->
+      <button type="button" class="kupu-insertorderedlist"
+              tal:condition="filter/list-ol-addbutton"
+              title="Numbered list: Access key (Alt or Ctrl) + #" id="kupu-list-ol-addbutton" 
+              i18n:attributes="title" accesskey="#">&#160;</button>
+      <button type="button" class="kupu-insertunorderedlist" 
+              tal:condition="filter/list-ul-addbutton"
+              title="Unordered list: Access key (Alt or Ctrl) + *" id="kupu-list-ul-addbutton" 
+              i18n:attributes="title" accesskey="*">&#160;</button>
+              </span>
+  </kupu:part>
+
+  <kupu:part name="buttongroup-definitionlist">
+    <span class="kupu-tb-buttongroup" id="kupu-bg-definitionlist" tal:condition="filter/definitionlist">
+      <!-- list button events are set on the list tool -->
+      <button type="button" class="kupu-insertdefinitionlist" 
+              title="Definition list: Access key (Alt or Ctrl) + =" id="kupu-list-dl-addbutton" 
+              i18n:attributes="title" accesskey="=">&#160;</button>
+    </span>
+  </kupu:part>
+
+  <kupu:part name="buttongroup-indent">
+    <span class="kupu-tb-buttongroup" id="kupu-bg-indent" tal:condition="filter/bg-indent">
+      <button type="button" class="kupu-outdent" 
+              tal:condition="filter/outdent-button"
+              id="kupu-outdent-button" title="Decrease quote level: Access key (Alt or Ctrl) + &lt;"
+              i18n:attributes="title" accesskey="&lt;">&#160;</button>
+      <button type="button" class="kupu-indent" 
+              tal:condition="filter/indent-button"
+              id="kupu-indent-button" title="Increase quote level: Access key (Alt or Ctrl) + &gt;"
+              i18n:attributes="title" accesskey="&gt;">&#160;</button>
+    </span>
+  </kupu:part>
+
+  <kupu:part name="buttongroup-remove">
+    <span class="kupu-tb-buttongroup" id="kupu-bg-remove" tal:condition="filter/bg-remove">
+      <button type="button" class="kupu-removeimage invisible"
+              tal:condition="filter/removeimage-button"
+              id="kupu-removeimage-button" title="Remove image"
+              i18n:attributes="title">&#160;</button>
+      <button type="button" class="kupu-removelink invisible"
+              tal:condition="filter/removelink-button"
+              id="kupu-removelink-button" title="Remove link"
+              i18n:attributes="title">&#160;</button>
+    </span>
+  </kupu:part>
+
+  <kupu:part name="buttongroup-undo">
+    <span class="kupu-tb-buttongroup" id="kupu-bg-undo" tal:condition="filter/bg-undo">
+      <button type="button" class="kupu-undo" 
+              tal:condition="filter/undo-button"
+              id="kupu-undo-button" title="Undo: Access key (Alt or Ctrl) + Z"
+              i18n:attributes="title" accesskey="z">&#160;</button>
+      <button type="button" class="kupu-redo" 
+              tal:condition="filter/redo-button"
+              id="kupu-redo-button" title="Redo: Access key (Alt or Ctrl) + Y"
+              i18n:attributes="title" accesskey="y">&#160;</button>
+    </span>
+  </kupu:part>
+
   <kupu:part name="select-styles">
     <select class="kupu-tb-styles"
-        tal:define="gstyles here/kupu_library_tool/getParagraphStyles|python:[];
-                lstyles field/widget/parastyles|python:[];
-                allstyles python:list(gstyles)+list(lstyles);">
+            tal:condition="filter/styles"
+            tal:define="styles python:tool.getStyleList(field);">
       <option value="p" i18n:translate="">Normal</option>
-      <tal:block condition="allstyles|nothing" repeat="style allstyles">
+      <tal:block condition="styles" repeat="style styles">
         <option i18n:translate=""
-                tal:define="parts python:style.split('|',1)+['','']"
-                tal:attributes="value python:parts[1]" tal:content="python:parts[0]"/>
+                tal:attributes="value style/value" tal:content="style/content"/>
       </tal:block>
     </select>
   </kupu:part>
 
-  <kupu:part name="buttongroup-basicmarkup">
-    <span class="kupu-tb-buttongroup" id="kupu-bg-basicmarkup">
-      <button type="button" class="kupu-bold" id="kupu-bold-button" title="Bold: Access key (Alt or Ctrl) + B"
-              i18n:attributes="title" accesskey="b">&#160;</button>
-      <button type="button" class="kupu-italic" id="kupu-italic-button" title="Italic: Access key (Alt or Ctrl) + I"
-              i18n:attributes="title" accesskey="i">&#160;</button>
-    </span>
+  <kupu:part name="liststyles">
+    <select id="kupu-ulstyles" class="kupu-ulstyles" tal:condition="filter/ulstyles">
+      <option value="disc" i18n:translate="list-disc">&#9679;</option>
+      <option value="square" i18n:translate="list-square">&#9632;</option>
+      <option value="circle" i18n:translate="list-circle">&#9675;</option>
+      <option value="none" i18n:translate="list-nobullet">no bullet</option>
+    </select>
+    <select id="kupu-olstyles" class="kupu-olstyles" tal:condition="filter/olstyles">
+      <option value="decimal" 
+              i18n:translate="list-decimal">1</option>
+      <option value="upper-roman" 
+              i18n:translate="list-upperroman">I</option>
+      <option value="lower-roman" 
+              i18n:translate="list-lowerroman">i</option>
+      <option value="upper-alpha" 
+              i18n:translate="list-upperalpha">A</option>
+      <option value="lower-alpha" 
+              i18n:translate="list-loweralpha">a</option>
+    </select>
   </kupu:part>
-
 </kupu:feature>

Added: kupu/trunk/kupu/plone/zmi_toolbar.pt
==============================================================================
--- (empty file)
+++ kupu/trunk/kupu/plone/zmi_toolbar.pt	Fri Dec  8 14:20:38 2006
@@ -0,0 +1,77 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
+lang="en"
+metal:use-macro="here/kupu_config/macros/master"
+i18n:domain="plone">
+
+  <metal:cssslot fill-slot="css_slot">
+    <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:if condition="not:exists:portal/portal_javascripts"
+            metal:use-macro="context/kupu_wysiwyg_support/macros/kupu_js_include">
+    </tal:if>
+    <script type="text/javascript"
+            tal:attributes="src portal/kupu_kjax.js/absolute_url_path"
+            ></script>
+  </metal:cssslot>
+  <body>
+
+    <div class="documentContent" metal:fill-slot="kupu_content">
+      <h3 i18n:translate="heading_configuration">Kupu Toolbar Configuration</h3>
+      <form action=""
+            name="configure_kupu_toolbar"
+            method="post"
+            tal:attributes="action here/absolute_url">
+
+        <fieldset>
+          <legend i18n:translate="legend_link_options">Button visibility</legend>
+          <div class="formHelp" i18n:translate="help_link_uid">Control the global visibility of toolbar buttons from this screen.
+            If no expression is entered, only checked buttons are visible. Enter an expression for finer control of visibility.
+            Individual fields may also whitelist or blacklist buttons: see the field schema.
+            <div>Values available in expressions includes 'field' as well as the usual names</div>
+            <!-- object_url folder_url portal_url object folder portal nothing request modules member -->
+          </div>
+
+          <table class="listing nosort">
+            <thead>
+              <th>Id</th>
+              <th>Title</th>
+              <th>Visible<br/>
+                <input title="Select all items"
+                 onclick="toggleSelect(this, 'filters.visible:records:int', true);"
+                 type="checkbox" checked="checked" />
+              </th>
+              <th>Expression</th>
+            </thead>
+            <tbody>
+              <tr tal:repeat="opt context/getFilterOptions">
+                <td><span tal:content="opt/id" />
+                  <input type="hidden" name="filters.id:records" tal:attributes="value opt/id" />
+                </td>
+                <td tal:content="opt/title">
+                </td>
+                <td>
+                  <input type="checkbox" name="filters.visible:records:int" value="1" tal:attributes="checked opt/visible" />
+                </td>
+                <td>
+                  <input type="text" style="width:30em" tal:attributes="value opt/override|nothing" name="filters.override:records" />
+                </td>
+              </tr>
+            </tbody>
+          </table>
+
+        </fieldset>
+
+        <input class="context"
+               tabindex=""
+               type="submit"
+               name="set_toolbar_filters:method"
+               value="Save"
+               i18n:attributes="value"
+               tal:attributes="tabindex tabindex|nothing;"
+               />
+      </form>
+    </div>
+  </body>
+</html>
+


More information about the kupu-checkins mailing list