Author: jmorliaguet
Date: Sat Jun  3 13:15:59 2006
New Revision: 3291

Modified:
   cpsskins/branches/paris-sprint-2006/DEPENDENCIES.txt
   cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.css
   cpsskins/branches/paris-sprint-2006/ui/screens/common/authoring.js
   cpsskins/branches/paris-sprint-2006/ui/screens/common/configure.zcml
   cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py
   cpsskins/branches/paris-sprint-2006/ui/screens/definitions.py
   cpsskins/branches/paris-sprint-2006/ui/screens/editor.pt
   cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/configure.zcml
   
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt
   cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/configure.zcml
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py

Log:

- some code reorganisation.

- added a link from the context menu to the format editors



Modified: cpsskins/branches/paris-sprint-2006/DEPENDENCIES.txt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/DEPENDENCIES.txt        (original)
+++ cpsskins/branches/paris-sprint-2006/DEPENDENCIES.txt        Sat Jun  3 
13:15:59 2006
@@ -4,7 +4,7 @@
 Dependencies
 ============
 
-[1] Zope3 (trunk rev >= 67956) (svn://svn.zope.org/repos/main/Zope3/trunk)
+[1] Zope3 (trunk rev >= 68358) (svn://svn.zope.org/repos/main/Zope3/trunk)
 
 
 Optional products

Modified: cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.css
==============================================================================
--- cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.css   
(original)
+++ cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.css   Sat Jun 
 3 13:15:59 2006
@@ -31,7 +31,7 @@
 /* Contextual menu */
 
 .contextMenu {
-  font: 11px Verdana, Arial, Helvetica, sans-serif;
+  font: 13px Verdana, Arial, Helvetica, sans-serif;
   border-width: 1px;
   border-style: solid;
   border-color: #999 #000 #000 #999;
@@ -45,7 +45,7 @@
   vertical-align: middle;
   color: #000;
   padding: 3px 15px 4px 5px;
-  width: 108px;
+  width: 128px;
 }
 
 .contextMenu a img {

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/common/authoring.js
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/common/authoring.js  
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/common/authoring.js  Sat Jun 
 3 13:15:59 2006
@@ -50,6 +50,18 @@
   if (style_editor_model) style_editor_model.updateData({widget: ''});
 }
 
+function editFormat(info) {
+  var data = info.model.getData();
+  var id = data.id;
+  var options = info.options;
+  CPSSkins.getModelById('element-editor').updateData({
+    form: {id: id, display: data.display, format: data.format, uri: data.uri,
+           tab: options.choice}
+  });
+  CPSSkins.getControllerById('main-editor-perspectives').switchTo(
+  'element-editor');
+}
+
 function duplicateElement(info) {
   var url = '@@duplicateElement';
   var args = {
@@ -88,19 +100,8 @@
   'duplicate element': duplicateElement,
   'delete element': deleteElement,
   'edit element': editElement,
-  'cancel event': function(e) {Event.stop(e); return false;},
-  'activate area': function(e) {
-     var target = e.currentTarget;
-     target._before_activate = target.getStyle('background-color');
-     target.setStyle({'background-color': '#ff6'})
-
-  },
-  'deactivate area': function(e) {
-     var target = e.currentTarget;
-     if (target._before_activate) {
-       e.currentTarget.setStyle({'background-color': target._before_activate})
-     }
-  }
+  'edit format': editFormat,
+  'cancel event': function(e) {Event.stop(e); return false;}
 });
 
 /* Register widgets */

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/common/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/common/configure.zcml        
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/common/configure.zcml        
Sat Jun  3 13:15:59 2006
@@ -112,10 +112,9 @@
   <view
     for="*"
     name="authoring"
-    provides=".views.IAuthoring"
     class=".views.Authoring"
+    provides=".views.IAuthoring"
     permission="zope.ManageContent"
-    allowed_interface=".views.IAuthoring"
     layer="cpsskins.browser.skin.cpsskins"
   />
 

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py      
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py      Sat Jun 
 3 13:15:59 2006
@@ -37,8 +37,8 @@
 from cpsskins.elements.theme import Theme
 from cpsskins.elements.themepage import ThemePage
 from cpsskins.elements.interfaces import IPresentable, IDisplayable
-from cpsskins.elements.interfaces import IInnerNode
-from cpsskins.setup.interfaces import IResourceManager
+from cpsskins.elements.interfaces import IInnerNode, IFormattable
+from cpsskins.setup.interfaces import IResourceManager, IIdentifiable, IType
 from cpsskins.ui.screens.definitions import MODELS, VIEWS, CONTROLLERS
 from cpsskins.utils import getThemeManager
 
@@ -69,6 +69,7 @@
         self.context = context
         self.request = request
 
+
     def getId(self):
         return self.context.identifier
 
@@ -89,8 +90,15 @@
         context = self.context
         request = self.request
         id = context.identifier
+
         authoring = getMultiAdapter((context, request), IAuthoring,
-                                    name='authoring')
+                                         name='authoring')
+        negotiation = getMultiAdapter((context, request),
+                                           INegotiation, 'negotiation')
+        perspective = negotiation.getPerspective()
+        display = IDisplayable(context).getEffectiveDisplay(perspective)
+        formats = IFormattable(display).getFormats(resolve=False)
+
         return json.write({
             'id': u'm%s' % id,
             'data': {
@@ -98,8 +106,17 @@
                 'editable': True,
                 'order': authoring.getElementOrder(id),
                 'container': IInnerNode.providedBy(context),
-                }
-            })
+                'display': str(display),
+                'uri': IIdentifiable(context).getURI(),
+                'formattable': True,
+                'formats': [
+                    {'choice': IType(f).getTypeName(),
+                     'label': _(IType(f).getTypeName()),
+                     'format': str(f),
+                    } for f in formats
+                ],
+            },
+        })
 
 class Rendering(object):
     """Rendering of page elements
@@ -120,7 +137,7 @@
         return viewer(engine=engine)
 
 class IAuthoring(Interface):
-    """Authoring views"""
+    """ """
 
 class Authoring(object):
     """Authoring views"""
@@ -391,7 +408,7 @@
         duplicating = getMultiAdapter((container, request), INodeDuplicating)
         return str(duplicating.duplicate(element))
 
-class JSONViews:
+class JSONViews(object):
     """JSON views"""
 
     def __init__(self, context, request):

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/definitions.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/definitions.py       
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/definitions.py       Sat Jun 
 3 13:15:59 2006
@@ -343,7 +343,7 @@
         'controllers': ['main-editor-perspectives', 'disable-links',
                         'page-mode-perspectives', 'element-mover',
                         'portlet-factory', 'main-editor-actions',
-                        'menu-actions', 'reveal-areas'],
+                        'menu-actions'],
     },
 
     'layout-mode': {
@@ -471,14 +471,14 @@
             'action': 'edit element',
             'visible': 'editable',
            },
+           {'type': 'separator',
+           },
            {'type': 'item',
             'label': _('Duplicate'),
             'icon': '++resource++duplicate-16.png',
             'action': 'duplicate element',
             'visible': 'editable',
            },
-           {'type': 'separator',
-           },
            {'type': 'item',
             'label': _('Copy'),
             'icon': '++resource++copy-16.png',
@@ -495,9 +495,10 @@
            {'type': 'submenu',
             'label': _('Format'),
             'visible': 'formattable',
+            'icon': '++resource++format-16.png',
             'items': [
               {'type': 'selection',
-               'action': 'format element',
+               'action': 'edit format',
                'choices': 'formats',
               },
             ]
@@ -626,15 +627,4 @@
         },
     },
 
-    # reveal active areas
-    'reveal-areas': {
-        'id': 'reveal-areas',
-        'type': 'behaviour',
-        'rules': {
-            'div.editable': {
-                'mouseover': 'activate area',
-                'mouseout': 'deactivate area',
-            },
-        },
-    },
 }

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/editor.pt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/editor.pt    (original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/editor.pt    Sat Jun  3 
13:15:59 2006
@@ -38,8 +38,6 @@
            tal:content="python: controller('main-editor-actions')" />
       <ins class="controller"
            tal:content="python: controller('disable-links')" />
-      <ins class="controller"
-           tal:content="python: controller('reveal-areas')" />
 
       <!-- top tabs -->
       <ins class="model" tal:content="python: model('theme-tabs')" />

Modified: 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/configure.zcml 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/configure.zcml 
Sat Jun  3 13:15:59 2006
@@ -19,8 +19,8 @@
 
   <view
       for="cpsskins.elements.interfaces.IElement"
-      name="editpanel"
-      class=".views.EditPanel"
+      name="edittabs"
+      class=".views.Tabs"
       permission="zope.ManageContent"
       layer="cpsskins.browser.skin.cpsskins"
   />
@@ -28,7 +28,7 @@
   <pages
       for="cpsskins.elements.interfaces.IElement"
       layer="cpsskins.browser.skin.cpsskins"
-      class=".views.ElementForm"
+      class=".views.Form"
       permission="zope.ManageContent">
 
     <page
@@ -44,6 +44,29 @@
   </pages>
 
   <pages
+      for="cpsskins.elements.interfaces.IElement"
+      layer="cpsskins.browser.skin.cpsskins"
+      class=".views.Presets"
+      permission="zope.ManageContent">
+
+    <page
+        name="createPreset"
+        attribute="createPreset"
+    />
+
+    <page
+        name="usePreset"
+        attribute="usePreset"
+    />
+
+    <page
+        name="stopUsingPreset"
+        attribute="stopUsingPreset"
+    />
+
+  </pages>
+
+  <pages
       for="*"
       layer="cpsskins.browser.skin.cpsskins"
       permission="zope.ManageContent">

Modified: 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt
==============================================================================
--- 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt  
    (original)
+++ 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt  
    Sat Jun  3 13:15:59 2006
@@ -3,7 +3,7 @@
   mode request/form/mode|string:edit;
   tmutil context/@@getThemeManager;
   element python: tmutil.getElementById(id);
-  info element/@@editpanel/getInfo;
+  info element/@@edittabs/getInfo;
   display nocall:info/display;
   display_id display/identifier;
   preset nocall:info/preset;

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py       
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py       
Sat Jun  3 13:15:59 2006
@@ -18,17 +18,25 @@
 __docformat__ = "reStructuredText"
 
 from zope.formlib import form
-from zope.component import getMultiAdapter
-from zope.interface import implements, Interface
+from zope.component import getMultiAdapter, getUtility
+from zope.location.pickling import locationCopy
+from zope.traversing.api import getParent
+from zope.security.proxy import removeSecurityProxy
 
 from cpsskins.browser.negotiation.interfaces import INegotiation
 from cpsskins.browser.rendering.interfaces import IViewer
+from cpsskins.elements.interfaces import IDisplay, IFormat
 from cpsskins.elements.interfaces import IDisplayable, IFormattable
-from cpsskins.setup.interfaces import IResource, IPreset
+from cpsskins.relations import DyadicRelation
+from cpsskins.relations.interfaces import IRelationTool
 from cpsskins.setup.interfaces import IType, IIdentifiable
+from cpsskins.setup.interfaces import IResourceManager, IResource, IPreset
+from cpsskins.setup.io import importSite, exportSite
+from cpsskins.setup.snapshot import Snapshot
+from cpsskins.storage.interfaces import IStorage
 from cpsskins.utils import getThemeManager
 
-class ElementForm:
+class Form(object):
     """An edit form for elements.
     """
     def __init__(self, context, request):
@@ -49,7 +57,7 @@
         changed = form.applyChanges(self.context, self.form_fields, data)
         return u''
 
-class EditPanel:
+class Tabs(object):
 
     def __init__(self, context, request):
         self.context = context
@@ -128,3 +136,118 @@
             'preview': preview,
             }
 
+class Presets(object):
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+    def createPreset(self, title=u'', uri=u'', use=False):
+        """Create a preset from an element referred to by its URI.
+        if 'use' is True the preset will be used; in that case the context
+        must be the display.
+        """
+        context = self.context
+        resources = getUtility(IResourceManager)
+        element = resources.resolve(uri, context)
+        if element is None:
+            raise ValueError("no such element: %s" % uri)
+        container = getParent(element)
+        if not IStorage.providedBy(container):
+            raise TypeError("The element is not located in a storage.")
+
+        resource = locationCopy(removeSecurityProxy(element))
+        getThemeManager(context).registerElement(resource)
+
+        preset = resources.register(title=title, resource=resource,
+                                    context=context)
+        if use:
+            self.usePreset(uri=IIdentifiable(preset).getURI())
+
+    def usePreset(self, uri=u'', current_uri=u''):
+        """Use a preset referred to by its URI
+
+        The context is the display
+
+        """
+        context = self.context
+        if uri == u'_':
+            uri = u''
+        if not uri and not current_uri:
+            raise ValueError("Must specify a URI to use or a URI to stop 
using")
+        if not uri:
+            return self.stopUsingPreset(current_uri)
+
+        if not IDisplay.providedBy(context):
+            raise TypeError("The context must be a display.")
+
+        resources = getUtility(IResourceManager)
+        preset = resources.lookup(uri=uri, context=context)
+        if preset is None:
+            raise KeyError("No such preset: '%s'." % uri)
+
+        resource = IResource(preset).getResource()
+        if not IFormat.providedBy(resource):
+            raise TypeError("The resource must be a format.")
+
+        # remove the existing display <--> format relation
+        reltool = IRelationTool(context)
+        predicate = resource.predicate
+        old_rel = reltool.search(first=context, predicate=predicate)
+        reltool.remove(old_rel)
+
+        # create a new display <--> preset relation
+        relation = DyadicRelation(first=context, second=preset,
+                                  predicate=predicate)
+        reltool.add(relation)
+
+    def stopUsingPreset(self, uri=u''):
+        """Stop using a preset referred to by its URI
+
+        The context is the display.
+        """
+        context = self.context
+        if not uri:
+            raise KeyError("Must specify a preset's URI.")
+
+        if not IDisplay.providedBy(context):
+            raise TypeError("The context must be a display.")
+
+        resources = getUtility(IResourceManager)
+        preset = resources.lookup(uri=uri, context=context)
+        if preset is None:
+            raise KeyError("No such preset: '%s'." % uri)
+
+        formats = getThemeManager(context).getFormatStorage()
+        resource = IResource(preset).getResource()
+
+        # remove the old display <-> preset relation
+        reltool = IRelationTool(context)
+        predicate = resource.predicate
+        old_rel = reltool.search(first=context, predicate=predicate)
+        reltool.remove(old_rel)
+
+        format = locationCopy(removeSecurityProxy(resource))
+        formats.add(format)
+
+        relation = DyadicRelation(first=context, second=format,
+                                  predicate=predicate)
+        reltool.add(relation)
+
+    ### Sites  #########################################################
+
+    def importSite(self, file=None):
+        importSite(file, self.context)
+
+    def exportSite(self):
+        return exportSite(self.context)
+
+    ### Snapshots  #####################################################
+
+    def getSnapshotStorage(self):
+        return getThemeManager(self.context).getSnapshotStorage()
+
+    def createSnapshot(self):
+        data = exportSite(self.context)
+        snapshots = self.getSnapshotStorage()
+        snapshot = Snapshot(data=data)

Modified: 
cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/configure.zcml   
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/configure.zcml   
Sat Jun  3 13:15:59 2006
@@ -53,21 +53,6 @@
     />
 
     <page
-        name="createPreset"
-        attribute="createPreset"
-    />
-
-    <page
-        name="usePreset"
-        attribute="usePreset"
-    />
-
-    <page
-        name="stopUsingPreset"
-        attribute="stopUsingPreset"
-    />
-
-    <page
         name="createSnapshot"
         attribute="createSnapshot"
     />

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py Sat Jun 
 3 13:15:59 2006
@@ -18,20 +18,13 @@
 __docformat__ = "reStructuredText"
 
 from zope.component import getUtility
-from zope.location.pickling import locationCopy
-from zope.traversing.api import getParent
-from zope.security.proxy import removeSecurityProxy
 
 from cpsskins import minjson as json
-from cpsskins.elements.interfaces import IDisplay, IFormat
-from cpsskins.relations import DyadicRelation
-from cpsskins.relations.interfaces import IRelationTool
 from cpsskins.setup.interfaces import IType, IIdentifiable
 from cpsskins.setup.interfaces import IResourceManager, IResource
 from cpsskins.setup.io import importSite, exportSite
 from cpsskins.setup.registration import refreshPresets
 from cpsskins.setup.snapshot import Snapshot
-from cpsskins.storage.interfaces import IStorage
 from cpsskins.utils import getThemeManager
 
 class SiteDesignerView:
@@ -81,98 +74,6 @@
         """
         refreshPresets()
 
-    def createPreset(self, title=u'', uri=u'', use=False):
-        """Create a preset from an element referred to by its URI.
-        if 'use' is True the preset will be used; in that case the context
-        must be the display.
-        """
-        context = self.context
-        resources = getUtility(IResourceManager)
-        element = resources.resolve(uri, context)
-        if element is None:
-            raise ValueError("no such element: %s" % uri)
-        container = getParent(element)
-        if not IStorage.providedBy(container):
-            raise TypeError("The element is not located in a storage.")
-
-        resource = locationCopy(removeSecurityProxy(element))
-        getThemeManager(context).registerElement(resource)
-
-        preset = resources.register(title=title, resource=resource,
-                                    context=context)
-        if use:
-            self.usePreset(uri=IIdentifiable(preset).getURI())
-
-    def usePreset(self, uri=u'', current_uri=u''):
-        """Use a preset referred to by its URI
-
-        The context is the display
-
-        """
-        context = self.context
-        if uri == u'_':
-            uri = u''
-        if not uri and not current_uri:
-            raise ValueError("Must specify a URI to use or a URI to stop 
using")
-        if not uri:
-            return self.stopUsingPreset(current_uri)
-
-        if not IDisplay.providedBy(context):
-            raise TypeError("The context must be a display.")
-
-        resources = getUtility(IResourceManager)
-        preset = resources.lookup(uri=uri, context=context)
-        if preset is None:
-            raise KeyError("No such preset: '%s'." % uri)
-
-        resource = IResource(preset).getResource()
-        if not IFormat.providedBy(resource):
-            raise TypeError("The resource must be a format.")
-
-        # remove the existing display <--> format relation
-        reltool = IRelationTool(context)
-        predicate = resource.predicate
-        old_rel = reltool.search(first=context, predicate=predicate)
-        reltool.remove(old_rel)
-
-        # create a new display <--> preset relation
-        relation = DyadicRelation(first=context, second=preset,
-                                  predicate=predicate)
-        reltool.add(relation)
-
-    def stopUsingPreset(self, uri=u''):
-        """Stop using a preset referred to by its URI
-
-        The context is the display.
-        """
-        context = self.context
-        if not uri:
-            raise KeyError("Must specify a preset's URI.")
-
-        if not IDisplay.providedBy(context):
-            raise TypeError("The context must be a display.")
-
-        resources = getUtility(IResourceManager)
-        preset = resources.lookup(uri=uri, context=context)
-        if preset is None:
-            raise KeyError("No such preset: '%s'." % uri)
-
-        formats = getThemeManager(context).getFormatStorage()
-        resource = IResource(preset).getResource()
-
-        # remove the old display <-> preset relation
-        reltool = IRelationTool(context)
-        predicate = resource.predicate
-        old_rel = reltool.search(first=context, predicate=predicate)
-        reltool.remove(old_rel)
-
-        format = locationCopy(removeSecurityProxy(resource))
-        formats.add(format)
-
-        relation = DyadicRelation(first=context, second=format,
-                                  predicate=predicate)
-        reltool.add(relation)
-
     ### Sites  #########################################################
 
     def importSite(self, file=None):
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to