[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib - datasourcemanager.js:1.16 jsdav.js:1.14 sitesmanager.js:1.18
Paul Everitt
paul@zope.com
Mon, 7 Apr 2003 07:22:10 -0400
Update of /cvs-repository/Packages/Moztop/moztop/content/lib
In directory cvs.zope.org:/tmp/cvs-serv22933/content/lib
Modified Files:
datasourcemanager.js jsdav.js sitesmanager.js
Log Message:
Start on properties work
=== Packages/Moztop/moztop/content/lib/datasourcemanager.js 1.15 => 1.16 ===
--- Packages/Moztop/moztop/content/lib/datasourcemanager.js:1.15 Thu Apr 3 04:02:05 2003
+++ Packages/Moztop/moztop/content/lib/datasourcemanager.js Mon Apr 7 07:21:39 2003
@@ -61,7 +61,7 @@
DataSourceManager.prototype.addDataSource = function(rdfurl, blocked) {
/* Add a new datasource to the tree.
- While we are trying to load data sources in blocked mode, it is
+ While we are trying not to load data sources in blocked mode, it is
sometimes necessary to do so.
*/
@@ -219,6 +219,8 @@
source = sources.getNext();
ds.Init(source);
node = ds.getNode(res.Value);
+
+ // XXX: This fails occassionally for weird reasons
if (node.propertyExists(this.titleprop)) {
dump("\nFound node in " + source.URI + " datasource");
return node;
@@ -234,50 +236,16 @@
}
-
-
-DataSourceManager.prototype.OOOOLLLLLDDDDgetSelectedResource = function() {
- /* Return the resource that is currently selected in the tree. */
-
- // get index of tree
- var tree = document.getElementById(this.treeId);
- var index = tree.view.selection.currentIndex;
-
- // get the selected resource
- if (index == -1)
- return false;
- var res = tree.view.getItemAtIndex(index).resource;
-
- // XXX: All of the following code should be eventually replaced by the
- // getNode() method.
- sources = tree.database.GetDataSources();
- // the first source is always Mozilla internal
- sources.getNext();
- // we need to create the RDFDataSource object only once
- var ds = new RDFDataSource();
- // Go through all registered datasources
- while (sources.hasMoreElements()) {
- // Create a rdfds RDFNode and see whether it exists in the datasource
- source = sources.getNext();
- ds.Init(source);
- node = ds.getNode(res.Value);
- if (node.propertyExists(this.titleprop))
- return node;
- }
- return false;
-}
-
-
DataSourceManager.prototype.getResource = function(urn) {
/* Grab a resource using its urn. This method looks through all
datasources to find the resource. */
var tree = document.getElementById(this.treeId);
/* XXX: a temporary hack by Paul!! Use composite to get resource */
- ds - new RDFDataSource();
- ds.Init(tree.database);
- resource = ds.getNode(urn);
- return resource;
+// ds - new RDFDataSource();
+// ds.Init(tree.database);
+// resource = ds.getNode(urn);
+// return resource;
var sources = tree.database.GetDataSources();
=== Packages/Moztop/moztop/content/lib/jsdav.js 1.13 => 1.14 ===
--- Packages/Moztop/moztop/content/lib/jsdav.js:1.13 Wed Apr 2 16:33:58 2003
+++ Packages/Moztop/moztop/content/lib/jsdav.js Mon Apr 7 07:21:39 2003
@@ -364,7 +364,7 @@
}
-DavClient.prototype.PUT = function(url, content, headers) {
+DavClient.prototype.PUT = function(url, content, headers, callback) {
/* Implementation of WebDAV command PUT.
See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.7
@@ -375,24 +375,10 @@
var typeheader = "X-Zope-Type-Name";
function handleResponse(error) {
- if (request.responseXML) {
-
- dump("\nin PUT handler\n" + response_str + "\n");
- var serializer = new XMLSerializer();
- var response = request.responseXML;
- var response_str = serializer.serializeToString(response);
- dump("\nleaving PUT handler\n" + response_str + "\n");
+ if (request.statusText) {
+ callback(request);
}
}
-
-// var x = document.implementation.createDocument("", "test", null);
-// x.documentElement.appendChild(document.createElement("Foo"));
-// x.documentElement.appendChild(document.createElement("Bar"));
-// x.documentElement.firstChild.appendChild(
-// document.createTextNode("My Stuff\nYeah"));
-
-// var s = new XMLSerializer();
-// str = xml_decl + s.serializeToString(x);
request.onload = handleResponse;
request.open("PUT", url);
=== Packages/Moztop/moztop/content/lib/sitesmanager.js 1.17 => 1.18 ===
--- Packages/Moztop/moztop/content/lib/sitesmanager.js:1.17 Thu Apr 3 04:02:05 2003
+++ Packages/Moztop/moztop/content/lib/sitesmanager.js Mon Apr 7 07:21:39 2003
@@ -71,25 +71,25 @@
sitessubitems.makeSeq();
rootnode.addTarget(this.subitemsprop, sitessubitems);
- /* Now create the localsite database for storing Drafts*/
- localsiteds = this.addDataSource(this.localsiteurl, true);
+// /* Now create the localsite database for storing Drafts*/
+// localsiteds = this.addDataSource(this.localsiteurl, true);
- /* Add an entry in the sites database */
- // XXX: This doesn't need to be recorded as an entry in moztop_sites.
- // Instead, we should copy an RDF file over to the profile dir and
- // let the moztop_localsites make an assertion about containment in sites.
- var newsite = sitesds.getNode(this.localsiteurn);
- newsite.addTarget(this.titleprop, "Drafts");
- newsite.addTarget(this.resourcetypeprop,
- 'urn:moztop:resourcetypes:site');
- sitessubitems.addChild(newsite);
-
- /* Put a container under "Drafts" */
- var newsite = localsiteds.getNode(this.localsiteurn);
- var localsitesubitems = localsiteds.getNode(this.localsiteurn+":subitems");
- localsitesubitems.makeSeq();
- newsite.addTarget(this.subitemsprop, localsitesubitems);
- localsiteds.save();
+// /* Add an entry in the sites database */
+// // XXX: This doesn't need to be recorded as an entry in moztop_sites.
+// // Instead, we should copy an RDF file over to the profile dir and
+// // let the moztop_localsites make an assertion about containment in sites.
+// var newsite = sitesds.getNode(this.localsiteurn);
+// newsite.addTarget(this.titleprop, "Drafts");
+// newsite.addTarget(this.resourcetypeprop,
+// 'urn:moztop:resourcetypes:site');
+// sitessubitems.addChild(newsite);
+
+// /* Put a container under "Drafts" */
+// var newsite = localsiteds.getNode(this.localsiteurn);
+// var localsitesubitems = localsiteds.getNode(this.localsiteurn+":subitems");
+// localsitesubitems.makeSeq();
+// newsite.addTarget(this.subitemsprop, localsitesubitems);
+// localsiteds.save();
sitesds.save();
logmanager.addMessage("Initialized profile databases",
@@ -109,7 +109,7 @@
sitesds = this.addDataSource(this.sitesurl, true);
/* Add localsite, which is NOT recorded as a site in the sitesdb */
- localsite = this.addDataSource(this.localsiteurl, true);
+ // localsite = this.addDataSource(this.localsiteurl, true);
var sites_node = sitesds.getNode(this.sitesurn).getTarget(
this.subitemsprop);
@@ -292,23 +292,16 @@
SitesManager.prototype.createResource = function(newtypeurn) {
- /* Create a resource in Drafts and open it */
-
- // First grab the drafts folder
- // localsiteds = this.getDataSource(this.localsiteurl);
- var localsiteds = new RDFDataSource(this.localsiteurl);
- drafts = localsiteds.getNode(this.localsiteurn).getTarget(this.subitemsprop);
-
- // We're going to make up a URN, it doesn't get set until the user
- // saves it. Then we create a resource in Drafts.
- var resourcetitle = "Untitled-1";
- var urn = "urn:moztop:sites:localsite:drafts:untitled1";
- // Create a new site and add it to the sites resource
- var newresource = localsiteds.getNode(urn);
- newresource.addTarget(this.titleprop, resourcetitle);
- newresource.addTarget(this.resourcetypeprop,newtypeurn);
- drafts.addChild(newresource);
+ /// We grab the currently-selected folder and make up a urn
+ var now = new Date().getTime();
+ folder = this.getSelectedResource();
+ if (!folder) {
+ alert("Please select a folder in which to add this resource");
+ return;
+ }
+ urn = folder.getValue() + "/" + now;
+ resourcetitle = "Untitled-1";
// Find viewer containers
var tabs = document.getElementById("active-contents-tabs");
@@ -316,21 +309,19 @@
// Do not open resource if already opened.
for (var i = 0; i < panels.childNodes.length; i++) {
- if (panels.childNodes[i].getAttribute('urn') == urn)
+ if (panels.childNodes[i].getAttribute("urn") == urn) {
alert(resourcetitle + " is already open");
return;
+ }
}
// Retrieving resource type resource for chosen resource type
type = this.getResource(newtypeurn);
- // XXX: The type registry should really have an attribute for this.
typeViewerName = type.getTarget(this.styleidprop).getValue() + "viewer";
-
- // Creating resource viewer
var viewer = document.createElement(typeViewerName);
// Setting initialization attributes
- viewer.id = typeViewerName + "-" + new Date().getTime();
+ viewer.id = typeViewerName + "-" + now;
viewer.setAttribute("urn", urn);
viewer.setAttribute("resourcetitle", resourcetitle);
@@ -385,36 +376,12 @@
// Deleting item from server
var dav = new DavClient();
- //dav.DELETE(resource.getValue());
-
- // Update RDF
-
- /* Hard wired for now to a certain container */
-// rdfseqprop = "http://www.w3.org/1999/02/22-rdf-syntax-ns#_1";
-// rdfseq = resource.getSource(rdfseqprop);
-// rdfseq.makeSeq();
-// rdfseq.removeChild(resourceurn);
-// var tree = document.getElementById(this.treeId);
-// tree.builder.rebuild();
-// return;
-
-/*
-
-rdfseq = resource.getTarget(this.subitemsprop)
-rdfseq.getSource(this.subitemsprop).getValue()
+ dav.DELETE(resource.getValue());
-*/
-
-
-// rooturn = "http://127.0.0.1:8380/"
-// rootnode = this.getResource(rooturn);
-// container = rootnode.getTarget(this.subitemsprop);
-
- container = resource.getTarget(this.subitemsprop);
- container.makecontain();
- container.removeChild(resourceurn);
- var tree = document.getElementById(this.treeId);
- tree.builder.rebuild();
+ // Careful, the rdfds method for refresh eats exceptions!
+ ds = this.getDataSource(resource.datasource.URI);
+ alert("Reloading contents.rdf");
+ ds.refresh(false)
return;
}