[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib - sitesmanager.js:1.20
Paul Everitt
paul@zope.com
Mon, 28 Apr 2003 09:51:13 -0400
Update of /cvs-repository/Packages/Moztop/moztop/content/lib
In directory cvs.zope.org:/tmp/cvs-serv30691/content/lib
Modified Files:
sitesmanager.js
Log Message:
Now that I have a local in-mem datasource to make assertions, DELETE
mostly removes (just hides at this point) the deleted resource. No
need to refresh from the server. Also, New->ZPT Page works.
=== Packages/Moztop/moztop/content/lib/sitesmanager.js 1.19 => 1.20 ===
--- Packages/Moztop/moztop/content/lib/sitesmanager.js:1.19 Thu Apr 17 04:58:50 2003
+++ Packages/Moztop/moztop/content/lib/sitesmanager.js Mon Apr 28 09:50:42 2003
@@ -53,6 +53,11 @@
Mozilla profile directory with the right RDF files, etc. */
var tree = document.getElementById(this.treeId);
+
+ /* Attach database for local assertions */
+ this.inmemds = new RDFDataSource();
+ tree.database.AddDataSource(this.inmemds.getRawDataSource());
+
sitesds = new RDFDataSource(this.sitesurl);
/* Are there databases in profile dir? If so, log a message and return */
@@ -71,26 +76,6 @@
sitessubitems.makeSeq();
rootnode.addTarget(this.subitemsprop, sitessubitems);
-// /* 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();
-
sitesds.save();
logmanager.addMessage("Initialized profile databases",
"navigation.js, initNavigation",
@@ -105,6 +90,7 @@
SitesManager.prototype.initializeSites = function() {
/* Called during startup to find needed sites, fetch RDF, and build
tree */
+
// Get the sites resource from the data source
sitesds = this.addDataSource(this.sitesurl, true);
@@ -293,15 +279,20 @@
SitesManager.prototype.createResource = function(newtypeurn) {
- /// We grab the currently-selected folder and make up a urn
- var now = new Date().getTime();
+ // We grab the currently-selected folder and make up a urn
folder = this.getSelectedResource();
if (!folder) {
alert("Please select a folder in which to add this resource");
return;
}
- urn = folder.getValue() + "/" + now;
- resourcetitle = "Untitled-1";
+ urn = folder.getValue() + "Untitled-1";
+
+ // Create a new node in the inmemds scratchpad
+ var newresource = this.inmemds.getNode(urn);
+ newresource.addTarget(this.titleprop, "Untitled-1");
+ newresource.addTarget(this.resourcetypeprop,newtypeurn);
+ subitems = sitesds.getNode(folder+":subitems");
+ folder.addChild(newresource);
// Find viewer containers
var tabs = document.getElementById("active-contents-tabs");
@@ -321,14 +312,14 @@
var viewer = document.createElement(typeViewerName);
// Setting initialization attributes
- viewer.id = typeViewerName + "-" + now;
+ viewer.id = typeViewerName + "-Untitled-1";
viewer.setAttribute("urn", urn);
- viewer.setAttribute("resourcetitle", resourcetitle);
+ viewer.setAttribute("resourcetitle", "Untitled-1");
// Prepare tabs
var tab = document.createElement("tab");
- tab.setAttribute("label", resourcetitle);
- tab.setAttribute("id", resourcetitle + "-tab");
+ tab.setAttribute("label", "Untitled-1");
+ tab.setAttribute("id", "Untitled-1" + "-tab");
// Add new viewer to opened resources tabs
tabs.appendChild(tab);
@@ -366,9 +357,13 @@
var dav = new DavClient();
dav.DELETE(resource.getValue());
- // Careful, the rdfds method for refresh eats exceptions!
- ds = this.getDataSource(resource.datasource.URI);
- ds.refresh(false)
+ // Now make a local assertion to set this resource as deleted
+ subj = resource.source;
+ pred = RDF.GetResource("http://www.oscom.org/rdf#isdeleted");
+ obj = RDF.GetLiteral("1");
+ inmemds = this.inmemds.getRawDataSource();
+ inmemds.Assert(subj, pred, obj, true);
+
return;
}