Permalink
Browse files

renamed simpleDirectory to simpleCollection (used by CardDAV for exam…

…ple)
  • Loading branch information...
1 parent bbada37 commit 48de4c42a9219eb048559327d48813d220823b40 @mikedeboer committed Feb 4, 2013
Showing with 21 additions and 19 deletions.
  1. +2 −2 lib/DAV/plugins/browser.js
  2. +16 −14 lib/DAV/server.js
  3. +3 −3 lib/DAV/{simpleDirectory.js → simpleCollection.js}
@@ -12,7 +12,7 @@ var jsDAV_Server = require("./../server");
var jsDAV_ServerPlugin = require("./../plugin");
var jsDAV_iFile = require("./../interfaces/iFile");
var jsDAV_iCollection = require("./../interfaces/iCollection");
-var jsDAV_SimpleDirectory = require("./../simpleDirectory");
+var jsDAV_SimpleCollection = require("./../simpleCollection");
var jsDAVACL_iPricipal = require("./../../DAVACL/interfaces/iPrincipal");
//var jsCalDAV_iCalendar = require("./../../CalDAV/interfaces/iCalendar");
var jsCardDAV_iAddressBook = require("./../../CardDAV/interfaces/iAddressBook");
@@ -415,7 +415,7 @@ var jsDAV_Browser_Plugin = module.exports = jsDAV_ServerPlugin.extend({
// We also know fairly certain that if an object is a non-extended
// SimpleCollection, we won't need to show the panel either.
- if (node.hasFeature(jsDAV_SimpleDirectory))
+ if (node.hasFeature(jsDAV_SimpleCollection))
return e.next();
output.push('<tr><td colspan="2"><form method="post" action="">' +
View
@@ -15,7 +15,7 @@ var Util = require("./../shared/util");
// DAV classes used directly by the Server object
var jsDAV_Handler = require("./handler");
-var jsDAV_SimpleDirectory = require("./simpleDirectory");
+var jsDAV_SimpleCollection = require("./simpleCollection");
var jsDAV_ObjectTree = require("./objectTree");
var jsDAV_Tree_Filesystem = require("./backends/fs/tree");
// interfaces to check for:
@@ -86,20 +86,11 @@ function Server(options) {
}
}
+ var root;
// setup the filesystem tree for this server instance.
if (typeof options.type == "string") {
- if (options.type == "sftp") {
- var jsDAV_Tree_Sftp = require("./backends/sftp/tree").jsDAV_Tree_Sftp;
- this.tree = jsDAV_Tree_Sftp.new(options);
- }
- else if (options.type == "ftp") {
- var jsDAV_Tree_Ftp = require("./backends/ftp/tree").jsDAV_Tree_Ftp;
- this.tree = jsDAV_Tree_Ftp.new(options);
- }
- else if (options.type == "dropbox") {
- var jsDAV_Tree_Dropbox = require("./backends/dropbox/tree").jsDAV_Tree_Dropbox;
- this.tree = jsDAV_Tree_Dropbox.new(options);
- }
+ var TreeClass = require("./backends/" + options.type + "/tree");
+ this.tree = TreeClass.new(options);
}
else if (typeof options.node == "string" && options.node.indexOf("/") > -1) {
this.tree = jsDAV_Tree_Filesystem.new(options.node, options);
@@ -110,13 +101,24 @@ function Server(options) {
else if (options.node && options.node.hasFeature(jsDAV_iNode)) {
this.tree = jsDAV_ObjectTree.new(options.node, options);
}
+ else if (options.node && Array.isArray(options.node)) {
+ // If it's an array, a list of nodes was passed, and we need to
+ // create the root node.
+ options.node.forEach(function(node) {
+ if (!node.hasFeature(jsDAV_iNode))
+ throw new Error("Invalid argument passed to constructor. If you're passing an array, all the values must implement jsDAV_iNode");
+ });
+
+ root = new jsDAV_SimpleCollection("root", options.node);
+ this.tree = new jsDAV_ObjectTree(root);
+ }
else {
if (exports.debugMode) {
Util.log("Invalid argument passed to constructor. "
+ "Argument must either be an instance of jsDAV_Tree, jsDAV_iNode, "
+ "a valid path to a location on the local filesystem or null", "error");
}
- var root = jsDAV_SimpleDirectory.new("root");
+ root = jsDAV_SimpleCollection.new("root");
this.tree = jsDAV_ObjectTree.new(root, options);
}
@@ -14,9 +14,9 @@ var jsDAV_iNode = require("./interfaces/iNode");
var Exc = require("./../shared/exceptions");
/**
- * SimpleDirectory
+ * jsDAV_SimpleCollection
*
- * The SimpleDirectory is used to quickly setup static directory structures.
+ * The SimpleCollection is used to quickly setup static directory structures.
* Just create the object with a proper name, and add children to use it.
*
* The name of the node must be passed, child nodes can also be bassed.
@@ -26,7 +26,7 @@ var Exc = require("./../shared/exceptions");
* @param array children
* @return void
*/
-var jsDAV_SimpleDirectory = module.exports = jsDAV_Collection.extend({
+var jsDAV_SimpleCollection = module.exports = jsDAV_Collection.extend({
initialize: function(name, children) {
children = children || [];
this.name = name;

0 comments on commit 48de4c4

Please sign in to comment.