Author: jmorliaguet
Date: Wed Oct 12 21:44:42 2005
New Revision: 28220

Added:
   z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/filters/
   
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/filters/__init__.py
   (contents, props changed)
   
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/filters/configure.zcml
   (contents, props changed)
Removed:
   
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/interfaces.py
Modified:
   z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/configure.zcml
Log:

- began moving engines (jsr168) to settings.engines



Modified: 
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/__init__.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/__init__.py    
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/__init__.py    
    Wed Oct 12 21:44:42 2005
@@ -16,6 +16,8 @@
 $Id$
 """
 __docformat__ = "reStructuredText"
-# make this directory a package
 
-pass
+from cpsskins.configuration.engines.interfaces import IEngine
+
+class IJSR168(IEngine):
+    """A JSR-168 like theme engine"""

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/configure.zcml
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/configure.zcml 
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/configure.zcml 
    Wed Oct 12 21:44:42 2005
@@ -1,9 +1,12 @@
 <configure
-    xmlns="http://namespaces.zope.org/cpsskins";>
+    xmlns="http://namespaces.zope.org/cpsskins";
+    xmlns:zope="http://namespaces.zope.org/zope";>
+
+  <include package=".filters" />
 
   <engine
       name="jsr168"
-      interface=".interfaces.IJSR168"
+      interface=".IJSR168"
   />
 
   <renderer
@@ -67,7 +70,7 @@
     />
 
     <filter
-        name="jsr168"
+        name="jsr168 controls"
     />
 
   </renderer>

Added: 
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/filters/__init__.py
==============================================================================
--- (empty file)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/filters/__init__.py
        Wed Oct 12 21:44:42 2005
@@ -0,0 +1,78 @@
+##############################################################################
+#
+# Copyright (c) 2005 Nuxeo and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+from zope.app.traversing.api import getParent
+from zope.component import adapts
+from zope.interface import implements
+from zope.publisher.interfaces import IRequest
+
+from cpsskins.browser.renderers.filters.interfaces import IFilter
+from cpsskins.elements.interfaces import ISlot
+from cpsskins.elements.interfaces import IDisplay
+
+OPEN = 0
+CLOSED = 1
+
+class BoxControls(object):
+    """Adds a JSR-168 like portlet box controls to objects.
+    """
+
+    adapts(IDisplay, IRequest)
+    implements(IFilter)
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+    def __call__(self, data='', info=None, **kw):
+        """Apply the filter"""
+
+        element = info.element
+        # We only apply decoration to portlets located in slots
+        if not ISlot.providedBy(getParent(element)):
+            return data
+
+        id = element.getIdentifier()
+        state = self.getState(id)
+
+        markup = '<div class="box">'
+        markup += '<div class="title">%s %s</div>' % (
+            STATE_BUTTON[state] % id, info.input.title
+            )
+        if state == OPEN:
+            markup += '<div class="body">%s</div>' % data
+        markup += '</div>'
+        return markup
+
+    def getState(self, id):
+        return int(self.request.cookies.get(self._getCookieName(id), OPEN))
+
+    def setState(self, id, state):
+        request = self.request
+        request.response.setCookie(self._getCookieName(id), state)
+        target = request.get('HTTP_REFERER', '.')
+        request.response.redirect(target)
+
+    def _getCookieName(self, id):
+        return 'cpsskins_state_%s' % id
+
+STATE_BUTTON = {
+    OPEN: '<a class="button" href="@@setState?state=1&id=%s">[-]</a>',
+    CLOSED: '<a class="button" href="@@setState?state=0&id=%s">[+]</a>'
+    }

Added: 
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/filters/configure.zcml
==============================================================================
--- (empty file)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/settings/engines/jsr168/filters/configure.zcml
     Wed Oct 12 21:44:42 2005
@@ -0,0 +1,21 @@
+<configure
+    xmlns="http://namespaces.zope.org/cpsskins";
+    xmlns:browser="http://namespaces.zope.org/browser";>
+
+  <!-- JSR-168 filter: adds JSR168-like portlet box decorations -->ยท
+
+  <filter
+      name="jsr168 controls"
+      for="cpsskins.elements.displays.interfaces.IDisplay"
+      factory=".BoxControls"
+  />
+
+  <browser:page
+      for="*"
+      permission="zope.Public"
+      name="setState"
+      class=".BoxControls"
+      attribute="setState"
+  />
+
+</configure>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to