[Repoze-checkins] r1164 - repoze.debug/trunk/repoze/debug/static
Paul Everitt
paul at agendaless.com
Sat Jun 28 15:57:25 EDT 2008
Author: Paul Everitt <paul at agendaless.com>
Date: Sat Jun 28 15:57:25 2008
New Revision: 1164
Log:
Much of the XUL version is now working, albeit with static data. You can edit the sample feed, click the reload button, and see the updated tree. Clicking on an entry in the tree shows the item on the right-hand side, rendered into an HTML view.
Modified:
repoze.debug/trunk/repoze/debug/static/debugui-xul.js
repoze.debug/trunk/repoze/debug/static/debugui-xul.xsl
repoze.debug/trunk/repoze/debug/static/debugui.css
repoze.debug/trunk/repoze/debug/static/debugui.xul
Modified: repoze.debug/trunk/repoze/debug/static/debugui-xul.js
==============================================================================
--- repoze.debug/trunk/repoze/debug/static/debugui-xul.js (original)
+++ repoze.debug/trunk/repoze/debug/static/debugui-xul.js Sat Jun 28 15:57:25 2008
@@ -1,12 +1,13 @@
var gm;
-var cl = console.log;
function GuiModel (tree_id, atom_url) {
this.tree_id = tree_id;
this.atom_url = atom_url;
this.tree = document.getElementById(tree_id);
+ this.viewer = document.getElementById("selected-entry");
this.processor = null;
+ this.viewerprocessor = null;
this.atom_doc = null;
this.curr_tree_selection = 0;
this.ns = {
@@ -35,6 +36,7 @@
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", url, false);
+ xmlhttp.setRequestHeader("Cache-Control","no-cache");
xmlhttp.send('');
return xmlhttp.responseXML;
}
@@ -49,25 +51,33 @@
}
+GuiModel.prototype.loadViewerProcessor = function (xslurl) {
+ /* Load the XSLT that views selected entries */
+
+ this.viewerxsldoc = this.loadURL(xslurl);
+ this.viewerprocessor = new XSLTProcessor();
+ this.viewerprocessor.importStylesheet(this.viewerxsldoc);
+}
+
GuiModel.prototype.reloadModel = function () {
/* Fetch the atom data, then update various trees */
// Grab the target, which is the document element on the tree
- var target = this.tree.builder.datasource.documentElement;
+ var target = gm.tree.builder.datasource.documentElement;
// Get new data, transform it, and import into the document
- this.atom_doc = this.loadURL(this.atom_url);
- var result = this.processor.transformToDocument(this.atom_doc);
+ gm.atom_doc = gm.loadURL(gm.atom_url);
+ var result = gm.processor.transformToDocument(gm.atom_doc);
var iresult = document.importNode(result.documentElement, true);
// Update the tree datasource and rebuild
Sarissa.moveChildNodes(iresult, target);
- this.tree.builder.rebuild();
+ gm.tree.builder.rebuild();
// Reset the selection to the last-known selection
- this.tree.view.selection.select(this.curr_tree_selection);
- this.tree.view.toggleOpenState(this.curr_tree_selection);
+ gm.tree.view.selection.select(0);
+ gm.tree.view.toggleOpenState(0);
}
@@ -80,13 +90,11 @@
gm.curr_entryid = entryid;
gm.curr_tree_selection = gm.tree.view.selection.currentIndex;
- // Change the browser url on the right
- var this_id = "urn:uuid:32736";
- var xp = "/*/atom:entry[atom:id='" + entryid + "']/atom:link";
- var href= selectSingleNode(xp).getAttribute("href");
- var iframe = document.getElementById("selected-entry");
- iframe.setAttribute("src", href);
-
+ // Change the contents of the viewer
+ gm.viewerprocessor.setParameter(null, "entryid", entryid);
+ var result = gm.viewerprocessor.transformToDocument(gm.atom_doc);
+ var iresult = document.importNode(result.documentElement, true);
+ Sarissa.moveChildNodes(iresult, gm.viewer);
}
@@ -101,6 +109,7 @@
}
gm = new GuiModel("xui-logtree", atom_url);
gm.loadProcessor("debugui-xul.xsl");
+ gm.loadViewerProcessor("debugui-entryviewer.xsl");
gm.reloadModel();
}
Modified: repoze.debug/trunk/repoze/debug/static/debugui-xul.xsl
==============================================================================
--- repoze.debug/trunk/repoze/debug/static/debugui-xul.xsl (original)
+++ repoze.debug/trunk/repoze/debug/static/debugui-xul.xsl Sat Jun 28 15:57:25 2008
@@ -1,17 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Convert the feed into various representations used for
Firefox 3 XML datasources attached to XUL trees and whatnot. -->
-<xsl:stylesheet xmlns:atom="http://www.w3.org/2005/Atom" exclude-result-prefixes="atom"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:template match="/">
+<xsl:stylesheet xmlns:atom="http://www.w3.org/2005/Atom" xmlns:rz="http://repoze.org/namespace"
+ exclude-result-prefixes="atom rz" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:output indent="yes"/>
+ <xsl:key name="getsubentry" match="atom:entry" use="atom:content/rz:entry/rz:request/@tid"/>
+ <xsl:template match="/" priority="99">
+ <xsl:choose>
+ <xsl:when test="/atom:feed">
+ <xsl:apply-templates select="atom:feed" mode="tree"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <main><!--<xsl:apply-templates select="." mode="viewer"/>--></main>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+ <xsl:template match="atom:feed" mode="tree">
+ <!-- Recurse into the feed and make data to load into the tree -->
<log>
- <xsl:for-each select="/atom:feed/atom:entry">
- <entry entryid="{atom:id}" name="/somerequest.html" elapsed="22.0">
- <item entryid="{atom:id}-1" name="App Result" elapsed="4.3"/>
- <item entryid="{atom:id}-2" name="Siteconfig" elapsed="3.9"/>
- <item entryid="{atom:id}-3" name="User" elapsed="0.8"/>
- </entry>
- </xsl:for-each>
+ <xsl:apply-templates select="atom:entry[atom:content/rz:entry/rz:response/@tid]"
+ mode="entry"/>
</log>
</xsl:template>
+ <xsl:template match="atom:entry" mode="entry">
+ <!-- The parent request is the one with a @tid on the response -->
+ <entry entryid="{atom:id}" name="{atom:title}" elapsed="{atom:content/rz:entry/@elapsed}">
+ <xsl:variable name="thistid" select="atom:content/rz:entry/rz:response/@tid"/>
+ <xsl:apply-templates select="key('getsubentry', $thistid)" mode="item"/>
+ <!-- <xsl:apply-templates
+ select="/atom:feed/atom:entry[atom:content/rz:entry/rz:request/@tid=$thistid]" mode="item"/>-->
+ </entry>
+ </xsl:template>
+ <xsl:template match="atom:entry" mode="item">
+ <item entryid="{atom:id}" name="{atom:title}" elapsed="{atom:content/rz:entry/@elapsed}"/>
+ </xsl:template>
</xsl:stylesheet>
Modified: repoze.debug/trunk/repoze/debug/static/debugui.css
==============================================================================
--- repoze.debug/trunk/repoze/debug/static/debugui.css (original)
+++ repoze.debug/trunk/repoze/debug/static/debugui.css Sat Jun 28 15:57:25 2008
@@ -1,4 +1,49 @@
-
body {
font-family: sans-serif;
+}
+
+#selected-entry {
+ background-color: white;
+ padding: 0.5em;
+}
+
+.xmlverb-default {
+ color: #333333;
+ background-color: #ffffff;
+ font-family: monospace
+}
+.xmlverb-element-name {
+ color: #990000
+}
+.xmlverb-element-nsprefix {
+ color: #666600
+}
+.xmlverb-attr-name {
+ color: #660000
+}
+.xmlverb-attr-content {
+ color: #000099;
+ font-weight: bold
+}
+.xmlverb-ns-name {
+ color: #666600
+}
+.xmlverb-ns-uri {
+ color: #330099
+}
+.xmlverb-text {
+ color: #000000;
+ font-weight: bold
+}
+.xmlverb-comment {
+ color: #006600;
+ font-style: italic
+}
+.xmlverb-pi-name {
+ color: #006600;
+ font-style: italic
+}
+.xmlverb-pi-content {
+ color: #006666;
+ font-style: italic
}
\ No newline at end of file
Modified: repoze.debug/trunk/repoze/debug/static/debugui.xul
==============================================================================
--- repoze.debug/trunk/repoze/debug/static/debugui.xul (original)
+++ repoze.debug/trunk/repoze/debug/static/debugui.xul Sat Jun 28 15:57:25 2008
@@ -1,13 +1,14 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="debugui.css" type="text/css"?>
<window id="example-window" title="Include Xui" orient="horizontal"
- xmlns:rz="http://repoze.org/namespaces"
+ xmlns:html="http://www.w3.org/1999/xhtml" xmlns:rz="http://repoze.org/namespaces"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="sarissa.js"/>
<script src="debugui-xul.js"/>
<vbox flex="1">
<tree id="xui-logtree" datasources="samplelogentries.xml" ref="*" querytype="xml"
- seltype="single" rows="10" flex="1">
+ seltype="single" rows="10" flex="1" maxwidth="250" minwidth="250">
<treecols>
<treecol id="title" primary="true" label="Title" flex="1"/>
<treecol id="elapsed" label="Elapsed"/>
@@ -31,6 +32,9 @@
<button id="reloadEntries" label="Reload"/>
</vbox>
<vbox flex="4">
- <iframe id="selected-entry" flex="1"/>
+ <html:div id="selected-entry" flex="1">
+ <html:h1>Yes</html:h1>
+ <html:p>no</html:p>
+ </html:div>
</vbox>
</window>
More information about the Repoze-checkins
mailing list