Author: jmorliaguet
Date: Sat May  6 23:22:58 2006
New Revision: 3063

Modified:
   cpsskins/branches/paris-sprint-2006/elements/interfaces.py
   cpsskins/branches/paris-sprint-2006/elements/theme.py
   cpsskins/branches/paris-sprint-2006/elements/themepage.py
   cpsskins/branches/paris-sprint-2006/thememanager.py
   cpsskins/branches/paris-sprint-2006/ui/authoring/authoring.css
   cpsskins/branches/paris-sprint-2006/ui/authoring/configure.zcml
   cpsskins/branches/paris-sprint-2006/ui/authoring/views.py
   cpsskins/branches/paris-sprint-2006/ui/panels/page_tabs.pt
   cpsskins/branches/paris-sprint-2006/ui/panels/theme_tabs.pt
   cpsskins/branches/paris-sprint-2006/ui/screens/layoutdesigner/filters/cell.pt
   cpsskins/branches/paris-sprint-2006/utils.py

Log:

- made it possible to add pages and themes with the '+' tab

- pages are registered as utilities



Modified: cpsskins/branches/paris-sprint-2006/elements/interfaces.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/interfaces.py  (original)
+++ cpsskins/branches/paris-sprint-2006/elements/interfaces.py  Sat May  6 
23:22:58 2006
@@ -21,6 +21,7 @@
 from zope.app.container.constraints import contains, containers
 from zope.app.container.interfaces import IContained
 from zope.app.container.interfaces import IOrderedContainer, IItemContainer
+from zope.component.interfaces import IComponents
 from zope.i18nmessageid import MessageFactory
 from zope.interface import Interface, Attribute
 from zope.interface.interfaces import IInterface
@@ -213,7 +214,7 @@
         utility.)
         """
 
-class ITheme(ICanvas, IInnerNode):
+class ITheme(ICanvas, IInnerNode, IComponents):
     """A theme.
     """
 

Modified: cpsskins/branches/paris-sprint-2006/elements/theme.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/theme.py       (original)
+++ cpsskins/branches/paris-sprint-2006/elements/theme.py       Sat May  6 
23:22:58 2006
@@ -56,7 +56,7 @@
     def getPages(self):
         """Return the list of pages
         """
-        return [v for v in self.values() if IThemePage.providedBy(v)]
+        return getThemeManager(self).getPages(self)
 
     def setAsDefault(self):
         return getThemeManager(self).setAsDefault(self)

Modified: cpsskins/branches/paris-sprint-2006/elements/themepage.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/themepage.py   (original)
+++ cpsskins/branches/paris-sprint-2006/elements/themepage.py   Sat May  6 
23:22:58 2006
@@ -17,6 +17,7 @@
 """
 __docformat__ = "reStructuredText"
 
+from zope.traversing.api import getParent
 from zope.interface import implements
 from zope.component import getUtilitiesFor
 from zope.component.factory import Factory
@@ -47,7 +48,8 @@
         return tmutil.isDefault(self)
 
     def getPageName(self):
-        for k, v in getUtilitiesFor(IThemePage, self):
+        theme = getParent(self)
+        for k, v in getUtilitiesFor(IThemePage, theme):
             if v == self:
                 return k
         return None

Modified: cpsskins/branches/paris-sprint-2006/thememanager.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/thememanager.py (original)
+++ cpsskins/branches/paris-sprint-2006/thememanager.py Sat May  6 23:22:58 2006
@@ -21,8 +21,8 @@
 
 from zope.app import zapi
 from zope.app.container.interfaces import INameChooser
-from zope.component.persistentregistry import PersistentComponents
 from zope.component import getUtility
+from zope.component.persistentregistry import PersistentComponents
 from zope.traversing.api import getParent
 from zope.interface import implements, Interface
 from zope.i18nmessageid import MessageFactory
@@ -104,6 +104,9 @@
     def addTheme(theme):
         """Add a theme."""
 
+    def addPage(theme, page):
+        """Add a page."""
+
     def getThemes():
         """Return the list of available themes."""
 
@@ -240,15 +243,28 @@
 
         name = INameChooser(self).chooseName(u'', theme)
         self[name] = theme
-        # register the theme as a local utility
         self.registerUtility(theme, ITheme, name)
         return name
 
+    def addPage(self, theme=None, page=None):
+        if not IThemePage.providedBy(page):
+            raise("Must specify a theme page.")
+
+        name = INameChooser(theme).chooseName(u'', page)
+        theme[name] = page
+        theme.registerUtility(page, IThemePage, name)
+        return name
+
     def getThemes(self):
         """Return the list of themes
         """
         return [theme for name, theme in self.getUtilitiesFor(ITheme)]
 
+    def getPages(self, theme):
+        """Return the list of pages of a theme.
+        """
+        return [page for name, page in theme.getUtilitiesFor(IThemePage)]
+
     def deleteTheme(self, name=u''):
         """Delete a theme
         """

Modified: cpsskins/branches/paris-sprint-2006/ui/authoring/authoring.css
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/authoring/authoring.css      
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/authoring/authoring.css      Sat May 
 6 23:22:58 2006
@@ -187,6 +187,7 @@
 
 .pageTabs li {
   display: inline;
+  text-decoration: none;
   padding: 0 0 0 20px;
   background: #e3e3e3 url(/++skin++cpsskins/@@/tl-tab.png) top left no-repeat;
 }

Modified: cpsskins/branches/paris-sprint-2006/ui/authoring/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/authoring/configure.zcml     
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/authoring/configure.zcml     Sat May 
 6 23:22:58 2006
@@ -59,6 +59,16 @@
       />
 
       <browser:page
+          name="addTheme"
+          attribute="addTheme"
+      />
+
+      <browser:page
+          name="addPage"
+          attribute="addPage"
+      />
+
+      <browser:page
           name="clonePresentation"
           attribute="clonePresentation"
       />

Modified: cpsskins/branches/paris-sprint-2006/ui/authoring/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/authoring/views.py   (original)
+++ cpsskins/branches/paris-sprint-2006/ui/authoring/views.py   Sat May  6 
23:22:58 2006
@@ -19,20 +19,22 @@
 
 from zope.lifecycleevent import ObjectCreatedEvent
 from zope.app.session.interfaces import ISession
-from zope.app.zapi import getParent, getMultiAdapter
-from zope.component import adapts, getUtility, createObject
+from zope.app.zapi import getParent
+from zope.component import adapts, getUtility, createObject, getMultiAdapter
 from zope.event import notify
 from zope.interface import implements, Interface
 from zope.i18nmessageid import MessageFactory
 
 from cpsskins import minjson as json
+from cpsskins.browser.negotiation.interfaces import INegotiation
 from cpsskins.browser.tree.interfaces import INodeAdding, INodeRemoving
 from cpsskins.browser.tree.interfaces import INodeMoving, INodeOrdering
 from cpsskins.browser.tree.interfaces import INodeDuplicating
 from cpsskins.browser.rendering.interfaces import IViewer
+from cpsskins.elements.theme import Theme
+from cpsskins.elements.themepage import ThemePage
 from cpsskins.elements.interfaces import IElement, IPresentable, IDisplayable
 from cpsskins.elements.interfaces import IInnerNode
-from cpsskins.browser.rendering.interfaces import IViewer
 from cpsskins.setup.interfaces import IResourceManager
 from cpsskins.ui.authoring.definitions import MODELS, VIEWS, CONTROLLERS
 from cpsskins.utils import getThemeManager
@@ -62,12 +64,6 @@
     def getThemeManager(self):
         return self.tmutil
 
-    def getGlobalThemeManager(self):
-        try:
-            return getThemeManager()
-        except ValueError:
-            return None
-
     def _redirect(self):
         request = self.request
         target = request.get('HTTP_REFERER', '.')
@@ -115,9 +111,26 @@
         response.setCookie('cpsskins_page', name)
         response.redirect('.')
 
-    ###################################################################
-    # Presentation
-    ###################################################################
+    def addTheme(self):
+        """Add a theme.
+        """
+        response = self.request.response
+        theme = Theme()
+        self.tmutil.addTheme(theme)
+        response.redirect('.')
+
+    def addPage(self):
+        """Add a page.
+        """
+        response = self.request.response
+        negotiation = getMultiAdapter((self.context, self.request),
+                                      INegotiation, 'negotiation')
+        theme = negotiation.getTheme()
+        page = ThemePage()
+        self.tmutil.addPage(theme, page)
+        response.redirect('.')
+
+    ### Presentation  #################################################
 
     def clonePresentation(self, perspective=None):
         """Clone a view in a given perspective by:
@@ -146,9 +159,7 @@
         IPresentable(self.context).removePresentation(perspective)
         self._redirect()
 
-    ###################################################################
-    # Format
-    ###################################################################
+    ### Format  #######################################################
 
     def customizeFormat(self, name=u'', perspective=None):
         perspectives = getUtility(IResourceManager, 'perspectives')
@@ -162,9 +173,7 @@
         IPresentable(self.context).uncustomizeFormat(name, perspective)
         self._redirect()
 
-    ###################################################################
-    # Elements
-    ###################################################################
+    ### Elements  #####################################################
 
     def _getElementById(self, id):
         """Return an element by id.

Modified: cpsskins/branches/paris-sprint-2006/ui/panels/page_tabs.pt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/panels/page_tabs.pt  (original)
+++ cpsskins/branches/paris-sprint-2006/ui/panels/page_tabs.pt  Sat May  6 
23:22:58 2006
@@ -7,8 +7,8 @@
   <tal:block repeat="page pages">
     <li tal:define="selected python: page == effective_page"
         tal:attributes="class python: selected and 'selected' or None">
-      <a tal:content="page/title"
-         tal:attributes="href string:@@setWorkPage?name=${page/name}" />
-    </li>
+      <a tal:content="python: page.title or 'No title'"
+         tal:attributes="href string:@@setWorkPage?name=${page/name}" /></li>
   </tal:block>
+  <li><a href="./@@addPage">+</a></li>
 </ul>

Modified: cpsskins/branches/paris-sprint-2006/ui/panels/theme_tabs.pt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/panels/theme_tabs.pt (original)
+++ cpsskins/branches/paris-sprint-2006/ui/panels/theme_tabs.pt Sat May  6 
23:22:58 2006
@@ -7,19 +7,24 @@
     <tal:block repeat="theme themes">
       <tal:block define="selected python: theme == effective_theme">
         <td tal:attributes="class python: selected and 'ltabselected' or 
'ltab'">
-          <img alt="" width="5" height="5"
-               src="++resource++ltab.png" />
+          <img alt="" width="5" height="5" src="++resource++ltab.png" />
         </td>
         <td tal:attributes="class python: selected and 'tabselected' or 'tab'">
-          <a tal:content="theme/title"
+          <a tal:content="python: theme.title or 'No title'"
              tal:attributes="href string:@@setWorkTheme?name=${theme/name}" />
         </td>
         <td tal:attributes="class python: selected and 'rtabselected' or 
'rtab'">
-          <img alt="" width="5" height="5"
-               src="++resource++rtab.png" />
+          <img alt="" width="5" height="5" src="++resource++rtab.png" />
         </td>
         <td class="separator"></td>
       </tal:block>
     </tal:block>
+    <td class="ltab">
+      <img alt="" width="5" height="5" src="++resource++ltab.png" />
+    </td>
+    <td class="tab" style="width:40px"><a href="./@@addTheme">+</a></td>
+    <td class="rtab">
+      <img alt="" width="5" height="5" src="++resource++rtab.png" />
+    </td>
   </tr>
 </table>

Modified: 
cpsskins/branches/paris-sprint-2006/ui/screens/layoutdesigner/filters/cell.pt
==============================================================================
--- 
cpsskins/branches/paris-sprint-2006/ui/screens/layoutdesigner/filters/cell.pt   
    (original)
+++ 
cpsskins/branches/paris-sprint-2006/ui/screens/layoutdesigner/filters/cell.pt   
    Sat May  6 23:22:58 2006
@@ -30,6 +30,14 @@
     tal:attributes="value python: width and width or '?'" />
   </form>
 
+<!-- for testing: move to a view -->
+<ins class="model">
+{"id": "m1",
+ "data": {
+   "editable":true
+}}
+</ins>
+
   <div class="container portletTarget" focus="1" destination="cellcontained"
        tal:attributes="targetid cell_id"
        tal:content="structure options/markup" />

Modified: cpsskins/branches/paris-sprint-2006/utils.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/utils.py        (original)
+++ cpsskins/branches/paris-sprint-2006/utils.py        Sat May  6 23:22:58 2006
@@ -55,26 +55,26 @@
     from cpsskins.elements.slot import Slot
 
     theme = Theme()
-    name= context.addTheme(theme)
+    name = context.addTheme(theme)
     theme.title = name.replace('-', ' ')
 
     # Add a page
-    theme[u'page'] = ThemePage(u'Default page')
+    page = ThemePage(u'Default page')
+    context.addPage(theme, page)
+
     # Add the page blocks
-    theme[u'page'][u'top'] = PageBlock(u'Top')
-    theme[u'page'][u'main'] = PageBlock(u'Main')
-    theme[u'page'][u'bottom'] = PageBlock(u'Bottom')
+    page[u'top'] = PageBlock(u'Top')
+    page[u'main'] = PageBlock(u'Main')
+    page[u'bottom'] = PageBlock(u'Bottom')
     # Add the cells
-    theme[u'page'][u'top'][u'main'] = Cell(u'Top')
-    theme[u'page'][u'main'][u'left'] = Cell(u'Left')
-    theme[u'page'][u'main'][u'main'] = Cell(u'Main')
-    theme[u'page'][u'main'][u'right'] = Cell(u'Right')
-    theme[u'page'][u'bottom'][u'bottom'] = Cell(u'Bottom')
+    page[u'top'][u'main'] = Cell(u'Top')
+    page[u'main'][u'left'] = Cell(u'Left')
+    page[u'main'][u'main'] = Cell(u'Main')
+    page[u'main'][u'right'] = Cell(u'Right')
+    page[u'bottom'][u'bottom'] = Cell(u'Bottom')
     # Add the slots
-    theme[u'page'][u'main'][u'left'][u'left'] = Slot(u'Left slot', u'',
-                                                     u'left')
-    theme[u'page'][u'main'][u'right'][u'right'] = Slot(u'Right slot', u'',
-                                                           u'right')
+    page[u'main'][u'left'][u'left'] = Slot(u'Left slot', u'', u'left')
+    page[u'main'][u'right'][u'right'] = Slot(u'Right slot', u'', u'right')
 
     # Some basic layout formatting
     def set_width(element, width):
@@ -82,12 +82,12 @@
             IDisplayable(element).getDisplay()
         ).getFormat(u'layout')[u'width'] = width
 
-    set_width(theme[u'page'][u'top'], u'100%')
-    set_width(theme[u'page'][u'main'], u'100%')
-    set_width(theme[u'page'][u'bottom'], u'100%')
-
-    set_width(theme[u'page'][u'main'][u'left'], u'20%')
-    set_width(theme[u'page'][u'main'][u'main'], u'60%')
-    set_width(theme[u'page'][u'main'][u'right'], u'20%')
+    set_width(page[u'top'], u'100%')
+    set_width(page[u'main'], u'100%')
+    set_width(page[u'bottom'], u'100%')
+
+    set_width(page[u'main'][u'left'], u'20%')
+    set_width(page[u'main'][u'main'], u'60%')
+    set_width(page[u'main'][u'right'], u'20%')
 
     return theme
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to