[Checkins] SVN: grokui.introspector/branches/ulif-integrate-homework/src/grokui/introspector/content Make content browser better looking.

Uli Fouquet uli at gnufix.de
Mon Apr 20 18:55:36 EDT 2009


Log message for revision 99344:
  Make content browser better looking.

Changed:
  U   grokui.introspector/branches/ulif-integrate-homework/src/grokui/introspector/content.py
  U   grokui.introspector/branches/ulif-integrate-homework/src/grokui/introspector/content_templates/inspect.pt

-=-
Modified: grokui.introspector/branches/ulif-integrate-homework/src/grokui/introspector/content.py
===================================================================
--- grokui.introspector/branches/ulif-integrate-homework/src/grokui/introspector/content.py	2009-04-20 22:25:56 UTC (rev 99343)
+++ grokui.introspector/branches/ulif-integrate-homework/src/grokui/introspector/content.py	2009-04-20 22:55:35 UTC (rev 99344)
@@ -1,10 +1,13 @@
 import grok
+from hurry import yui
+from hurry.resource import NeededInclusions
 from zope import interface
 
 from zope.introspector.interfaces import IObjectInfo
 from zope.introspector.viewinfo import ViewInfo
 from grokui.introspector.util import dotted_name_url
 
+
 class Inspect(grok.View):
     grok.context(interface.Interface)
     
@@ -25,6 +28,35 @@
     def getTypeInspectURL(self):
         return dotted_name_url(self.getTypeName())
 
-    def getViews(self):
+    def getViews(self, order=(0,2,1)):
+        """Get all views for the context object.
+
+        Return a list of three-tuples describing a view (<skinname>,
+        <interface, <name>). The list is ordered by one of these
+        categories. The order number is:
+
+          0 for sort by skin
+          1 for sort by interface
+          2 for sort by name
+
+        So, if the result should be sort in skin name order first,
+        followed by interface name order, the order might be (0,1,2).
+        """
         info = ViewInfo(self.context)
-        return sorted(list(info.getAllViews()))
+        view_list = list(info.getAllViews())
+        return sorted(view_list,
+                      key=lambda x: (x[order[0]], x[order[1]], x[order[2]]))
+
+    def encode(self, text):
+        text = str(text)
+        text = text.replace(
+            '&', '&amp;').replace(
+            '<', '&lt;').replace(
+            '>', '&gt;')
+        return text
+    
+    def getYUIIncludes(self):
+        # XXX: This is most probably the wrong approach
+        needed = NeededInclusions()
+        needed.need(yui.datatable)
+        return needed.render()

Modified: grokui.introspector/branches/ulif-integrate-homework/src/grokui/introspector/content_templates/inspect.pt
===================================================================
--- grokui.introspector/branches/ulif-integrate-homework/src/grokui/introspector/content_templates/inspect.pt	2009-04-20 22:25:56 UTC (rev 99343)
+++ grokui.introspector/branches/ulif-integrate-homework/src/grokui/introspector/content_templates/inspect.pt	2009-04-20 22:55:35 UTC (rev 99344)
@@ -1,8 +1,40 @@
 <html>
+  <head>
+    <title>Grok Content Browser</title>
+    <link type="text/css" rel="stylesheet" 
+	  href="http://yui.yahooapis.com/2.7.0/build/datatable/assets/skins/sam/datatable.css">
+
+    <link tal:attributes="href static/content.css"
+	  rel="stylesheet" type="text/css" />
+  </head>
   <body>
-    <h1>Content browser</h1>
-    
-    <h2>Content</h2>
+    <div class="header">
+      <div class="title">
+	<img src="" alt="Grok"
+	     tal:attributes="src static/logo.gif" />
+	Content browser
+      </div>
+
+      <div class="globalnav">
+	<div id="globalnavwrapper">
+	  <ul>
+	    <li><a href="/++inspect++/">Introspector</a></li>
+	    <li><a href="/++inspect++/+registry/@@index">Registry Browser</a></li>
+
+	    <li><a href="/++inspect++/+code/@@index">Code Browser</a></li>
+	    <li><a href="/++inspect++/+content/@@index">Content Browser</a></li>
+	  </ul>
+
+	</div>
+      </div>
+    </div>
+
+    <div class="document">
+      <div class="documentwrapper">
+        <div class="bodywrapper">
+          <div class="body">
+
+    <h2 class="section">Content</h2>
     <tal:content define="content context/keys | nothing" >
       <span tal:condition="not: content">
 	No content found...
@@ -26,9 +58,67 @@
       </p>
     </div>
 
-    <h2>Available views</h2>
-    <div tal:repeat="info view/getViews" tal:content="info">
-      All views...
+    <h2>Available Views</h2>
+
+    <div class="yui-skin-sam">
+      <div tal:content="structure view/getYUIIncludes" />
+      <div id="myMarkedUpContainer">
+	<table id="myTable">
+          <thead>
+            <tr>
+              <th>Skin</th>
+              <th>Name</th>
+              <th>Interface</th>
+            </tr>
+          </thead>
+          <tbody>
+	    <tr tal:repeat="info view/getViews">
+	      <td tal:content="python:info[0]"></td>
+	      <td tal:content="python:info[2]"></td>
+	      <td tal:content="python:info[1]"></td>
+	    </tr>
+          </tbody>
+	</table>
+      </div>
     </div>
+    <script type="text/javascript">
+      var myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get("myTable"));
+      myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
+      myDataSource.responseSchema = {
+        fields: [{key:"skin",},
+                 {key:"name"},
+                 {key:"iface"}
+                ]
+      };
+
+      var myColumnDefs = [
+        {key:"skin", label:"Skin", sortable:true},
+        {key:"name", label:"Name", sortable:true},
+        {key:"iface", label:"Interface", sortable:true}
+      ];
+
+      var myDataTable = new YAHOO.widget.DataTable("myMarkedUpContainer", myColumnDefs, myDataSource);
+    </script>
+
+
+	  </div>
+	</div>
+      </div>
+      <div class="sphinxsidebar">
+        <div class="sphinxsidebarwrapper">
+          
+            <h3>Quick search</h3>
+
+            <form class="search" action="search.html" method="get">
+              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
+              <input type="hidden" name="check_keywords" value="yes" />
+              <input type="hidden" name="area" value="default" />
+            </form>
+        </div>
+      </div>
+      <div class="clearer"></div>
+
+    </div>
+
   </body>
 </html>



More information about the Checkins mailing list