twingle/twingle/content/navigation navigation.js,1.1.1.1,1.2

[email protected] Thu, 6 Mar 2003 13:37:44 -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-serv14092/navigation

Modified Files:
	navigation.js 
Log Message:
Moved to a moztop-style RDF wrapper

Index: navigation.js
===================================================================
RCS file: /cvs/root/twingle/twingle/content/navigation/navigation.js,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** navigation.js	5 Mar 2003 19:30:31 -0000	1.1.1.1
--- navigation.js	6 Mar 2003 20:37:42 -0000	1.2
***************
*** 1,3 ****
--- 1,112 ----
  
+ 
+ 
+ function getProfileDirURL ()
+ {
+ 
+   // First get the directory service and query interface it to
+   // nsIProperties
+   var dirService = Components.
+       classes['@mozilla.org/file/directory_service;1'].
+       getService(Components.interfaces.nsIProperties);
+ 
+   // Next get the "ProfD" property of type nsIFile from the directory
+   // service, FYI this constant is defined in
+   // mozilla/xpcom/io/nsAppDirectoryServiceDefs.h
+ 
+   const NS_APP_USER_PROFILE_50_DIR = "ProfD";
+   profileDir = dirService.get(NS_APP_USER_PROFILE_50_DIR,
+ 	Components.interfaces.nsIFile);
+ 
+   // Now that we have it we can show it's path. See nsIFile for the
+   // other things you that can be done with profileDir
+ 
+ 	var io_service =
+ 	Components.classes["@mozilla.org/network/io-service;1"].
+ 	getService(Components.interfaces.nsIIOService);
+    
+   var url = io_service.newFileURI(profileDir)
+      .QueryInterface(Components.interfaces.nsIFileURL);
+    
+   return url.spec;
+ }
+ 
+ 
+ 
+ function SitesDataSource () {
+ 
+   /* A prototype to manage the sites database and datasources */
+ 
+   this.dcns = "http://www.purl.org/dc/1.1#";
+   this.oscomrdfns = "http://www.oscom.org/rdf#";
+   this.ncns ="http://home.netscape.com/NC-rdf#";
+ 
+   this.titleprop = this.dcns + "title";
+   this.descriptionprop = this.dcns + "description";
+   this.resourcetypeprop = this.oscomrdfns + "resourcetype";
+   this.urlprop = this.oscomrdfns + "url";
+   this.usernameprop = this.oscomrdfns + "username";
+   this.passwordprop = this.oscomrdfns + "password";
+   this.sitetypeprop = this.oscomrdfns + "sitetype";
+   this.styleidprop = this.oscomrdfns + "styleid";
+   this.subitemsprop = this.ncns + "subitems";
+ 
+   this.profileurl = getProfileDirURL();
+   this.elementid = null;
+ 
+ 
+   this.ds = new RDFDataSource(this.profileurl + "/twinglesites.rdf",null);
+   this.commontypesds = new RDFDataSource();
+   // this.commontypesds.parseFromString(commontypes_data,"http://www.zope.org/rdf");
+   this.elementid = 'navigation-tree';
+ 
+   this.sitedatasources = new Array();
+ 
+   /* Attach these (potentially empty) datasources */
+   var tree=document.getElementById(this.elementid);
+   tree.database.AddDataSource(this.ds.getRawDataSource());
+   // tree.database.AddDataSource(this.commontypesds.getRawDataSource());
+   tree.builder.rebuild();		
+ }
+ 
+ 
+ 
+ 
+ /* Detect if this is an initial install.  If so, initialize. */
+ SitesDataSource.prototype.initializeProfileDatabases=
+   function ()
+ {
+ 
+     /* Are there databases in profile dir?  If so, log a message and return */
+     var allres = this.ds.getAllResources();
+     if (allres.hasMoreElements()) {
+ 	dump("\nFound existing twingle sites database");
+ 	return;
+     }
+ 
+ 
+     /* If we make it here, it means we need to create twingle databases */
+     var rootnode = this.ds.getNode("urn:twingle:sites");
+     var subitems = this.ds.getNode("urn:twingle:sites:subitems");
+     subitems.makeSeq();
+     rootnode.addTarget(this.subitemsprop,subitems);
+ 
+     /* Just to be fun, let's add two sites by default, local and OSCOM */
+ 
+     
+ 
+     this.ds.save();
+     return;
+ }
+ 
+ 
+ function initNavigator () 
+ {
+     sitesds = new SitesDataSource();
+     sitesds.initializeProfileDatabases();
+     return;   
+ }
+ 
+ 
  function openSelectedResource () 
  {
***************
*** 16,18 ****
  
      return;    
! }
\ No newline at end of file
--- 125,127 ----
  
      return;    
! }