[Zope-CVS] CVS: Packages/Moztop/moztop/content/Explorer - Explorer.js:1.7

Paul Everitt paul@zope.com
Tue, 18 Feb 2003 10:36:38 -0500


Update of /cvs-repository/Packages/Moztop/moztop/content/Explorer
In directory cvs.zope.org:/tmp/cvs-serv8020/Explorer

Modified Files:
	Explorer.js 
Log Message:
Added discover to the New Site wizard

=== Packages/Moztop/moztop/content/Explorer/Explorer.js 1.6 => 1.7 ===
--- Packages/Moztop/moztop/content/Explorer/Explorer.js:1.6	Sat Feb 15 06:02:00 2003
+++ Packages/Moztop/moztop/content/Explorer/Explorer.js	Tue Feb 18 10:36:38 2003
@@ -17,6 +17,12 @@
 
 ******************************************************************************/
 
+
+/* Some regular expressions to fix the case-sensitivity of Moz RDF */
+var fixer1 = /rdf:rdf/g;
+var fixer2 = /rdf:description/g;
+var fixer3 = /rdf:seq/g;
+
 function SitesManager () {
 
   /* A prototype to manage the sites database and datasources */
@@ -120,6 +126,7 @@
     {
 	/* Local anonymous function for handling the async data */
 	if (p.statusText) {
+	    dump("\nhere\n");
 
 	    /* If p.ds is empty, we'll have to attach and rebuild */
 	    var needsReload = false;
@@ -128,18 +135,22 @@
 	    }
 
 	    p.ds.refresh(true);
-	    p.ds.parseFromString(p.responseText,siteurl);
+
+	    var newrdf = p.responseText;
+	    var newrdf = newrdf.replace(fixer1,"rdf:RDF");
+	    var newrdf = newrdf.replace(fixer2,"rdf:Description");
+	    var newrdf = newrdf.replace(fixer3,"rdf:Seq");
+	    dump("\ngoober is " + newrdf);
+
+	    p.ds.parseFromString(newrdf,siteurl);
 	    logmanager.addMessage("Retrieved remote contents.rdf",
 				  "Explorer.js, retrieveSiteContents",
 				  p.ds.serializeToString());
 
 	    /* todo: don't rebuild tree if you don't have to */
-	    if (1 == 1) {
-		dump("1==1 " + p.ds.serializeToString());
-		var tree=document.getElementById("explorertree");
-		tree.database.AddDataSource(p.ds.getRawDataSource());
-		tree.builder.rebuild();
-	    }
+	    var tree=document.getElementById("explorertree");
+	    tree.database.AddDataSource(p.ds.getRawDataSource());
+	    tree.builder.rebuild();
 	}
     }
 
@@ -151,13 +162,14 @@
     p.send(null);
 }
 
-
 SitesManager.prototype.addSite=
-  function (site_name, site_url, site_username, site_password)
+    function (site_name, site_realm, site_url, 
+	      site_username, site_password)
 {
+    /* The realm is used in URNs while the name is for the display */
     var sc=this.ds.getNode("urn:moztop:sites")
                .getTarget(this.subitemsprop);
-    var newsite=this.ds.getNode("urn:moztop:sites:" + site_name);
+    var newsite=this.ds.getNode("urn:moztop:sites:" + site_realm);
     var siteres = this.ds.getNode("urn:moztop:resourcetypes:site");
     sc.addChild(newsite);
 
@@ -170,7 +182,7 @@
     newsite.addTarget(this.resourcetypeprop,siteres);
 
     // Prepare the area for psuedo-folders (Configurations, Content, etc.)
-    var subitemsurn = "urn:moztop:sites:" + site_name + ":subitems";
+    var subitemsurn = "urn:moztop:sites:" + site_realm + ":subitems";
     var subitems = this.ds.getNode(subitemsurn);
     subitems.makeSeq();
     newsite.addTarget(this.subitemsprop,subitems);
@@ -181,11 +193,13 @@
 
 	/* vf is the current virtual folder */
 	var vf = vfs[i];
-	var vfurn = "urn:moztop:sites:" + site_name + ":" + vf.toLowerCase();
+	var vfurn = "urn:moztop:sites:" + site_realm + ":" + vf.toLowerCase();
 
 	/* Create a new node for this virtual folder and append to subitems */
 	var newvf = this.ds.getNode(vfurn);
 	subitems.addChild(newvf);
+
+	// todo: get rid of the following line
 	newvf.addTarget(this.titleprop,vf);
 
 	/* Fill in the rest of the info for the virtual folder */