[KSS-checkins] r47235 - in kukit/docs/creating-plugins-plone-conf-2007/src: KSSDemoPlugin/kssdemoplugin KSSDemoPlugin/kssdemoplugin/javascript plonedemo/plonedemo plonedemo/plonedemo/skins/plonedemo

jvloothuis at codespeak.net jvloothuis at codespeak.net
Sat Oct 6 13:33:56 CEST 2007


Author: jvloothuis
Date: Sat Oct  6 13:33:55 2007
New Revision: 47235

Added:
   kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/canvas.py
   kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/skins/plonedemo/canvas_commandset.pt
Modified:
   kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/commands.py
   kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/configure.zcml
   kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/interfaces.py
   kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/javascript/plugin.js
   kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/configure.zcml
   kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/plone-demo-plugin.kss
Log:
Added commandset demo

Modified: kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/commands.py
==============================================================================
--- kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/commands.py	(original)
+++ kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/commands.py	Sat Oct  6 13:33:55 2007
@@ -1,10 +1,14 @@
 from kss.core.kssview import CommandSet
 
-class KssdemopluginCommands(CommandSet):
+class KSSDemoPluginCommands(CommandSet):
 
-    # Add your own actions here, you can use the following code as
-    #  a starting point
-    def yourAction(self, selector, data):
-        command = self.commands.addCommand('yourAction', selector)
-        # Repeat for each parameter you need
-        command.addParam('parameter', data)
+    def canvasRect(self, selector, x, y, width, height, fillStyle=None):
+        command = self.commands.addCommand('demoplugin-canvasRect', selector)
+
+        command.addParam('x', str(int(x)))
+        command.addParam('y', str(int(y)))
+        command.addParam('width', str(int(width)))
+        command.addParam('height', str(int(height)))
+
+        if fillStyle is not None:
+            command.addParam('fillStyle', fillStyle)

Modified: kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/configure.zcml
==============================================================================
--- kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/configure.zcml	(original)
+++ kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/configure.zcml	Sat Oct  6 13:33:55 2007
@@ -19,12 +19,10 @@
   
 
     <!-- Event types -->
-    <!--
     <kss:eventtype
-        name="myCustomEventType"
-        jsfile="browser/my_plugins.js"
+        name="demoplugin-movement"
+        jsfile="javascript/plugin.js"
         />
-    -->
 
     <!-- Client actions & commands -->
     
@@ -37,17 +35,22 @@
         />
 
     <kss:paramprovider
-        name="demo-plugin-prompt"
+        name="demoplugin-random"
+        jsfile="javascript/plugin.js"
+        />
+
+    <kss:paramprovider
+        name="demoplugin-randomColor"
         jsfile="javascript/plugin.js"
         />
 
 
     <!-- Command sets -->
     <kss:commandset
-         name="demo-plugin"
+         name="demoplugin"
          for="kss.core.interfaces.IKSSView"
-         class=".commands.KssdemopluginCommands"
-         provides=".interfaces.IKssdemopluginCommands"
+         class=".commands.KSSDemoPluginCommands"
+         provides=".interfaces.IKSSDemoPluginCommands"
          />
 
 </configure>

Modified: kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/interfaces.py
==============================================================================
--- kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/interfaces.py	(original)
+++ kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/interfaces.py	Sat Oct  6 13:33:55 2007
@@ -1,7 +1,7 @@
 from zope.interface import Interface
 
-class IKssdemopluginCommands(Interface):
-    '''Documentation for your command set'''
+class IKSSDemoPluginCommands(Interface):
+    '''Demo plugin'''
 
-    def yourAction(selector, data):
-        '''Documentation on yourAction'''
+    def canvasRect(self, selector, x, y, width, height, fillStyle=None):
+        '''Draw a rectangle on a cavas node'''

Modified: kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/javascript/plugin.js
==============================================================================
--- kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/javascript/plugin.js	(original)
+++ kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/javascript/plugin.js	Sat Oct  6 13:33:55 2007
@@ -48,14 +48,11 @@
 var RandomProvider = function() {};
 RandomProvider.prototype = {
 ;;; check: function(args) {
-;;;     // An example of what you could check is the argument length
 ;;;     if (args.length < 1) {
-;;;         // Raise an error in case something is wrong
 ;;;         throw new Error('demoplugin-random needs at least 1 argument [max]');
 ;;;     }
 ;;; },
     eval: function(args, node) {
-        // Return the value which for this provider
         if(args.length == 2){
             var min = args[0];
             var max = args[1];
@@ -66,7 +63,6 @@
         var range = max - min;
         var rand = (Math.random() * range) + min;
         return rand;
-                  
     }
 };
 kukit.pprovidersGlobalRegistry.register(
@@ -103,9 +99,7 @@
     this.y = 0;
 };
 
-    
 MovementEventBinder.prototype.__bind__ = function(name, func_to_bind, oper) {
-    // The following is used for logging
 ;;; oper.componentName = '[demoplugin-movement] event binding';
 
     var keyMovement = {
@@ -115,30 +109,26 @@
         40: [0, 1] // down
     };
 
-    oper.completeParms([], {'x': '0', 'y': '0', 'speed': '1'}, 'movement event binding');
+    oper.completeParms([], {'x': '0', 'y': '0', 'speed': '1'}, 
+                       'movement event binding');
     oper.evalInt('x');
     oper.evalInt('y');
     oper.evalInt('speed');
 
+    var self = this;
     var speed = oper.parms.speed;
 
     var f = oper.makeExecuteActionsHook();
 
-    var self = this;
-    // Set filter so that only the specified keys should trigger.
     func = function(e) {
         var keyCode = e.keyCode.toString();
-
-        // Ignore all non movement keys
         if(typeof(keyMovement[keyCode]) == 'undefined'){
             return;
         }
-
         self.x += keyMovement[keyCode][0] * speed;
         self.y += keyMovement[keyCode][1] * speed;
 
-        var parms = {'x': self.x, 'y': self.y};
-        f({defaultParameters: parms});
+        f({defaultParameters: {'x': self.x, 'y': self.y}});
     };
     kukit.ut.registerEventListener(document, 'keydown', func);
 };

Added: kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/canvas.py
==============================================================================
--- (empty file)
+++ kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/canvas.py	Sat Oct  6 13:33:55 2007
@@ -0,0 +1,12 @@
+from kss.core import kssaction, KSSView
+
+
+class CanvasView(KSSView):
+
+    @kssaction
+    def drawRectangle(self, size):
+        'In-place refreshment of the calendar.'
+        ksscore = self.getCommandSet('core')
+        selector = ksscore.getHtmlIdSelector('canvas-commandset')
+
+        self.getCommandSet('demoplugin').canvasRect(selector, 10, 10, size, size)

Modified: kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/configure.zcml
==============================================================================
--- kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/configure.zcml	(original)
+++ kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/configure.zcml	Sat Oct  6 13:33:55 2007
@@ -26,5 +26,13 @@
       recursive="True"
       />
 
-  
+
+  <browser:page
+      for="*"
+      name="drawRectangle"
+      attribute="drawRectangle"
+      class=".canvas.CanvasView"
+      permission="zope2.View"
+      />
+
 </configure>

Modified: kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/plone-demo-plugin.kss
==============================================================================
--- kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/plone-demo-plugin.kss	(original)
+++ kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/plone-demo-plugin.kss	Sat Oct  6 13:33:55 2007
@@ -5,17 +5,28 @@
 */
 
 
-/* #canvas:timeout { */
-/*     evt-timeout-delay: 1; */
-/*     evt-timeout-repeat: True; */
-
-/*     action-client: demoplugin-canvasRect; */
-/*     demoplugin-canvasRect-x: demoplugin-random(0, 300); */
-/*     demoplugin-canvasRect-y: demoplugin-random(0, 300); */
-/*     demoplugin-canvasRect-width: demoplugin-random(10, 30); */
-/*     demoplugin-canvasRect-height: demoplugin-random(10, 30); */
-/*     demoplugin-canvasRect-fillStyle: demoplugin-randomColor(); */
-/* } */
+#canvas:load {
+    action-client: demoplugin-canvasRect;
+    demoplugin-canvasRect-x: 10;
+    demoplugin-canvasRect-y: 10;
+    demoplugin-canvasRect-width: 200;
+    demoplugin-canvasRect-height: 200;
+    demoplugin-canvasRect-fillStyle: "rgb(0, 255, 0)";
+}
+
+
+
+#canvas:timeout {
+    evt-timeout-delay: 1;
+    evt-timeout-repeat: True;
+
+    action-client: demoplugin-canvasRect;
+    demoplugin-canvasRect-x: demoplugin-random(0, 300);
+    demoplugin-canvasRect-y: demoplugin-random(0, 300);
+    demoplugin-canvasRect-width: demoplugin-random(10, 30);
+    demoplugin-canvasRect-height: demoplugin-random(10, 30);
+    demoplugin-canvasRect-fillStyle: demoplugin-randomColor();
+}
 
 #canvas:demoplugin-movement {
     action-client: demoplugin-canvasRect;
@@ -25,4 +36,9 @@
     demoplugin-canvasRect-width: 10;
     demoplugin-canvasRect-height: 10;
     demoplugin-canvasRect-fillStyle: "rgb(255, 0, 255)";
-}
\ No newline at end of file
+}
+
+#canvas-commandset:load {
+    action-server: drawRectangle;
+    drawRectangle-size: 200;
+}

Added: kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/skins/plonedemo/canvas_commandset.pt
==============================================================================
--- (empty file)
+++ kukit/docs/creating-plugins-plone-conf-2007/src/plonedemo/plonedemo/skins/plonedemo/canvas_commandset.pt	Sat Oct  6 13:33:55 2007
@@ -0,0 +1,13 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"
+      lang="en-US"
+      metal:use-macro="here/main_template/macros/master"
+      i18n:domain="atcontenttypes">
+
+  <body>
+    <div metal:fill-slot="main">
+
+      <canvas id="canvas-commandset" width="300" height="300"></canvas>
+
+    </div>
+  </body>
+</html>
\ No newline at end of file


More information about the Kukit-checkins mailing list