twingle/twingle/content/navigation navigation.js,1.4,1.5
[email protected] Mon, 10 Mar 2003 03:45:47 -0700 (MST)
| Newsgroups | gmane.comp.cms.oscom.twingle.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/root/twingle/twingle/content/navigation
In directory alpha.oscom.org:/tmp/cvs-serv24078/navigation
Modified Files:
navigation.js
Log Message:
We now have a twingle directory in profile dir that contains a localsite subdir, where you can create content by clicking on the New button in the toolbar
Index: navigation.js
===================================================================
RCS file: /cvs/root/twingle/twingle/content/navigation/navigation.js,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** navigation.js 9 Mar 2003 18:58:38 -0000 1.4
--- navigation.js 10 Mar 2003 10:45:45 -0000 1.5
***************
*** 74,88 ****
! SitesDataSource.prototype.getSelectedResource = function ()
{
! /* For all trees, this returns a selected resource as an RDFNode */
var tree = document.getElementById(this.elementid);
- var index = tree.view.selection.currentIndex;
-
- /* We need to work with the composite DS */
var treedb = tree.database;
var compositeds = new RDFDataSource();
compositeds.Init(treedb);
if (index == -1) return false;
var rdf = tree.view.getItemAtIndex(index).resource;
--- 74,95 ----
! SitesDataSource.prototype.getCompositeDS = function ()
{
! /* We need to work with the composite DS on the navigator tree */
var tree = document.getElementById(this.elementid);
var treedb = tree.database;
var compositeds = new RDFDataSource();
compositeds.Init(treedb);
+ return compositeds;
+ }
+
+
+ SitesDataSource.prototype.getSelectedResource = function ()
+ {
+ /* For all trees, this returns a selected resource as an RDFNode */
+ var tree = document.getElementById(this.elementid);
+ var index = tree.view.selection.currentIndex;
+ var compositeds = this.getCompositeDS();
if (index == -1) return false;
var rdf = tree.view.getItemAtIndex(index).resource;
***************
*** 114,117 ****
--- 121,167 ----
return;
+ }
+
+
+ SitesDataSource.prototype.PUT = function (containerurn, targeturn, content)
+ {
+ /* Create or update a resource, both the source and in the graph */
+
+ var compositeds = this.getCompositeDS();
+ var containernode = compositeds.getNode(containerurn);
+
+ /* Create the "content" file on disk */
+ var du = new DirUtils;
+ var prefsdirpath = du.getPrefsDir();
+ localsitedirpath = prefsdirpath + "/twingle/localsitecontent";
+
+ if (targeturn) {
+ /* For creates, targeturn is null, thus this is an update */
+ dump("\nUpdating " + targeturn);
+ var node = compositeds.getNode(urn);
+ }
+ else {
+ /* targeturn is null, so we are creating a new resource */
+ var d = new Date();
+ var now = d.getTime() + ".html";
+ var newurn = "urn:twingle:sites:localsite:" + now;
+
+ var localfile = new File(localsitedirpath + "/" + now);
+ localfile.open("w");
+ localfile.write(content);
+ localfile.close();
+
+ /* Now add a node to the tree */
+ var node = compositeds.getNode(newurn);
+ var articleprop = "urn:oscom:resourcetypes:article";
+ var articleres = compositeds.getNode(articleprop);
+ node.addTarget(this.resourcetypeprop,articleres);
+ node.addTarget(this.titleprop,"New Doc");
+ var subitems = containernode.getTarget(this.subitemsprop);
+ subitems.addChild(node);
+
+ this.localsiteds.save();
+ return;
+ }
}