Author: jmorliaguet
Date: Mon Feb 13 23:45:45 2006
New Revision: 2380

Added:
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/feedbox.pt
   (contents, props changed)
Modified:
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/browser.py
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/configure.zcml
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/cpsskins_aggregator.pt
Log:

- converted the feed aggregator to templates



Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/browser.py
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/browser.py
        (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/browser.py
        Mon Feb 13 23:45:45 2006
@@ -7,19 +7,25 @@
 
 feeds_model_def = """{
     "id": "feed%(id)s",
-    "data": {
-        "%(id)s": {"text": ""}
-     },
-     "storage": {
-         "type": "remote",
-         "refresh": %(id)s,
-         "accessors": {
-             "get": "@@getFeed?id=%(id)s"
-         }
+    "data": {"title": "", "text": "", "updated": ""},
+    "storage": {
+        "type": "remote",
+        "refresh": %(id)s,
+        "accessors": {
+            "get": "@@getFeed?id=%(id)s"
+        }
     }
 }
 """
 
+feeds_view_def = """{
+    "widget": {
+        "template": "feedbox.html"
+    },
+    "model": "feed%(id)s"
+}
+"""
+
 feeds_data = {
     '1': "May you live every day of your life. Jonathan Swift",
     '2': "Only two things are infinite, the universe and human stupidity, "
@@ -34,15 +40,18 @@
 
 class Views(BrowserView):
 
-    def citeFeed(self, id=1):
+    def citeFeedModel(self, id=1):
         return feeds_model_def % {'id': id}
 
+    def citeFeedView(self, id=1):
+        return feeds_view_def % {'id': id}
+
     def getFeed(self, id=1):
         time.sleep(1)
-        data = {id: {
-            'text': feeds_data[id],
-            'updated': time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime())
-            }
+        data = {
+          'title': u'Feed #%s' % id,
+          'text': feeds_data[id],
+          'updated': time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime())
         }
         return json.write(data)
 

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/configure.zcml
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/configure.zcml
    (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/configure.zcml
    Mon Feb 13 23:45:45 2006
@@ -3,21 +3,34 @@
 
   <browser:page
       for="*"
-      layer="cpsskins"
+      layer="cpsskins-test"
       name="cpsskins_aggregator.html"
       permission="zope.Public"
       template="cpsskins_aggregator.pt"
   />
 
+  <browser:page
+      for="*"
+      layer="cpsskins-test"
+      name="feedbox.html"
+      permission="zope.Public"
+      template="feedbox.pt"
+  />
+
   <browser:pages
-      layer="cpsskins"
+      layer="cpsskins-test"
       for="*"
       class=".browser.Views"
       permission="zope.Public">
 
     <browser:page
-        name="citeFeed"
-        attribute="citeFeed"
+        name="citeFeedModel"
+        attribute="citeFeedModel"
+    />
+
+    <browser:page
+        name="citeFeedView"
+        attribute="citeFeedView"
     />
 
     <browser:page

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/cpsskins_aggregator.pt
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/cpsskins_aggregator.pt
    (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/cpsskins_aggregator.pt
    Mon Feb 13 23:45:45 2006
@@ -9,6 +9,8 @@
           type="text/javascript"></script>
   <script src="/++skin++cpsskins/@@/++resource++json.js"
           type="text/javascript"></script>
+  <script src="/++skin++cpsskins/@@/++resource++ctal.js"
+          type="text/javascript"></script>
   <script src="/++skin++cpsskins/@@/++resource++cpsskins.js"
           type="text/javascript"></script>
   <link rel="stylesheet" type="text/css"
@@ -31,52 +33,6 @@
   }
   </style>
 
-  <script type="text/javascript">
-
-    Object.extend(Widgets, {
-
-      feedbox: function(def) {
-        var widget = Canvas.createNode({
-          tag: "div",
-          classes: "feeds"
-        });
-
-        return new FeedBox(widget, def);
-      }
-
-    });
-
-    FeedBox = Class.create();
-    FeedBox.prototype = Object.extend(new CPSSkins.View(), {
-
-      render: function(data) {
-        var widget = this.widget;
-        widget.innerHTML = '';
-
-        $R(1, 6).each(function(feed) {
-          var info = data[feed];
-
-          var box = Canvas.createNode({
-              tag: "div",
-              classes: "feedbox",
-              text: feed + ": " + (info.text || 'fetching data ...')
-          });
-
-          box.appendChild(
-            Canvas.createNode({
-              tag: "p",
-              classes: "date",
-              text: info.updated || ''
-          }));
-
-          widget.appendChild(box);
-        });
-      }
-
-    });
-
-  </script>
-
 </head>
 <body>
 
@@ -84,7 +40,7 @@
 
   <p>6 different feeds are retrieved asynchronously from the server.</p>
 
-  <p>The view displays all feeds and it gets updated when the data arrives.</p>
+  <p>The views get updated when the data arrives.</p>
 
   <p>Each feed is refreshed on regular time interval. The refresh date is
      also displayed.</p>
@@ -94,32 +50,13 @@
     <!-- models -->
     <ins class="model"
          tal:repeat="id python: range(1, 7)"
-         tal:attributes="cite string:@@citeFeed?id=$id">
-    </ins>
-
-    <ins class="model">
-    {"id": "aggregator",
-     "data": {
-       "1": {},
-       "2": {},
-       "3": {},
-       "4": {},
-       "5": {},
-       "6": {}
-     },
-     "storage": {
-       "type": "compound",
-       "partitions": ["feed1", "feed2", "feed3", "feed4", "feed5", "feed6"]
-    }}
+         tal:attributes="cite string:@@citeFeedModel?id=$id">
     </ins>
 
     <!-- views -->
-    <ins class="view">
-    {"widget": {
-      "type": "feedbox"
-     },
-     "model": "aggregator"
-    }
+    <ins class="view"
+         tal:repeat="id python: range(1, 7)"
+         tal:attributes="cite string:@@citeFeedView?id=$id">
     </ins>
 
   </div>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/feedbox.pt
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/feedbox.pt
        Mon Feb 13 23:45:45 2006
@@ -0,0 +1,5 @@
+<div class="feedbox">
+  <span ctal:content="title">TITLE</span>
+  <em ctal:content="text">TEXT</em>
+  <p class="date" ctal:content="updated">...</p>
+</div>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to