Skip to content

Commit

Permalink
VFS: Moved some files around and introduced new namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Jan 27, 2016
1 parent f24f5aa commit fea7e1a
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 96 deletions.
16 changes: 8 additions & 8 deletions dist-dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@
<script type="text/javascript" charset="utf-8" src="client/javascript/handler.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/_file.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/_null.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/_dav.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/apps.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/osjs.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/user.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/googledrive.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/dropbox.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/onedrive.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/internal.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/webdav.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/mounts/apps.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/mounts/osjs.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/mounts/user.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/mounts/googledrive.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/mounts/dropbox.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/vfs/mounts/onedrive.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/helpers/date.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/helpers/iframe-application.js"></script>
<script type="text/javascript" charset="utf-8" src="client/javascript/helpers/default-application.js"></script>
Expand Down
14 changes: 8 additions & 6 deletions src/client/javascript/vfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@
*
*/

OSjs.VFS = OSjs.VFS || {};
OSjs.VFS.Modules = OSjs.VFS.Modules || {};
OSjs.VFS = OSjs.VFS || {};
OSjs.VFS.Modules = OSjs.VFS.Modules || {};
OSjs.VFS.Transports = OSjs.VFS.Transports || {};

var DefaultModule = 'User';
var MountsRegistered = false;
Expand Down Expand Up @@ -1426,9 +1427,9 @@
options: moduleOptions,
request: function(name, args, callback, options) {
if ( opts.type === 'internal' ) {
OSjs.VFS._NullModule.request.apply(null, arguments);
OSjs.VFS.Transports.Internal.request.apply(null, arguments);
} else if ( opts.type === 'webdav' ) {
OSjs.VFS._DAVModule.request.apply(null, arguments);
OSjs.VFS.Transports.WebDAV.request.apply(null, arguments);
} else {
callback(API._('ERR_VFSMODULE_INVALID_TYPE_FMT', opts.type));
}
Expand Down Expand Up @@ -1511,7 +1512,8 @@
internal: true,
match: createMatch(key + '://'),
unmount: function(cb) {
OSjs.VFS._NullModule.unmount(cb);
cb = cb || function() {};
cb(API._('ERR_VFS_UNAVAILABLE'), false);
},
mounted: function() {
return true;
Expand All @@ -1521,7 +1523,7 @@
},
request: function() {
// This module uses the same API as public
OSjs.VFS._NullModule.request.apply(null, arguments);
OSjs.VFS.Transports.Internal.request.apply(null, arguments);
}
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
(function(Utils, API) {
'use strict';

window.OSjs = window.OSjs || {};
OSjs.VFS = OSjs.VFS || {};
OSjs.VFS.Modules = OSjs.VFS.Modules || {};
window.OSjs = window.OSjs || {};
OSjs.VFS = OSjs.VFS || {};
OSjs.VFS.Transports = OSjs.VFS.Transports || {};

/////////////////////////////////////////////////////////////////////////////
// API
/////////////////////////////////////////////////////////////////////////////

var _NullModule = {};
var internalTransport = {};

_NullModule.scandir = function(item, callback, options) {
internalTransport.scandir = function(item, callback, options) {
OSjs.VFS.internalCall('scandir', [item.path], function(error, result) {
var list = [];
if ( result ) {
Expand All @@ -53,7 +53,7 @@
});
};

_NullModule.write = function(item, data, callback, options) {
internalTransport.write = function(item, data, callback, options) {
options = options || {};
options.onprogress = options.onprogress || function() {};

Expand Down Expand Up @@ -90,7 +90,7 @@
});
};

_NullModule.read = function(item, callback, options) {
internalTransport.read = function(item, callback, options) {
options = options || {};
options.onprogress = options.onprogress || function() {};

Expand Down Expand Up @@ -137,45 +137,45 @@
});
};

_NullModule.copy = function(src, dest, callback) {
internalTransport.copy = function(src, dest, callback) {
OSjs.VFS.internalCall('copy', [src.path, dest.path], callback);
};

_NullModule.move = function(src, dest, callback) {
internalTransport.move = function(src, dest, callback) {
OSjs.VFS.internalCall('move', [src.path, dest.path], callback);
};

_NullModule.unlink = function(item, callback) {
internalTransport.unlink = function(item, callback) {
OSjs.VFS.internalCall('delete', [item.path], callback);
};

_NullModule.mkdir = function(item, callback) {
internalTransport.mkdir = function(item, callback) {
OSjs.VFS.internalCall('mkdir', [item.path], callback);
};

_NullModule.exists = function(item, callback) {
internalTransport.exists = function(item, callback) {
OSjs.VFS.internalCall('exists', [item.path], callback);
};

_NullModule.fileinfo = function(item, callback) {
internalTransport.fileinfo = function(item, callback) {
OSjs.VFS.internalCall('fileinfo', [item.path], callback);
};

_NullModule.url = function(item, callback) {
internalTransport.url = function(item, callback) {
var path = typeof item === 'string' ? item : item.path;
var fsuri = API.getConfig('Connection.FSURI');
callback(false, path ? (fsuri + path) : fsuri);
};

_NullModule.trash = function(item, callback) {
internalTransport.trash = function(item, callback) {
callback(API._('ERR_VFS_UNAVAILABLE'));
};

_NullModule.untrash = function(item, callback) {
internalTransport.untrash = function(item, callback) {
callback(API._('ERR_VFS_UNAVAILABLE'));
};

_NullModule.emptyTrash = function(item, callback) {
internalTransport.emptyTrash = function(item, callback) {
callback(API._('ERR_VFS_UNAVAILABLE'));
};

Expand All @@ -187,36 +187,26 @@
args = args || [];
callback = callback || {};

if ( !_NullModule[name] ) {
throw new Error('Invalid _NullModule API call name');
if ( !internalTransport[name] ) {
throw new Error('Invalid internalTransport API call name');
}

var fargs = args;
fargs.push(callback);
fargs.push(options);
_NullModule[name].apply(_NullModule, fargs);
internalTransport[name].apply(internalTransport, fargs);
}

/////////////////////////////////////////////////////////////////////////////
// EXPORTS
/////////////////////////////////////////////////////////////////////////////

/**
* This is the internal HTTP VFS Module wrapper
* This is the WebDAV VFS Module wrapper
*
* @api OSjs.VFS.Modules._NullModule
* @api OSjs.VFS.Transports.WebDAV
*/
OSjs.VFS._NullModule = {
unmount: function(cb) {
cb = cb || function() {};
cb(API._('ERR_VFS_UNAVAILABLE'), false);
},
mounted: function() {
return true;
},
enabled: function() {
return true;
},
OSjs.VFS.Transports.Internal = {
request: makeRequest
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
visible: true,
internal: true,
unmount: function(cb) {
OSjs.VFS._NullModule.unmount(cb);
cb = cb || function() {};
cb(API._('ERR_VFS_UNAVAILABLE'), false);
},
mounted: function() {
return true;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
} else if ( restricted.indexOf(name) !== -1 ) {
return callback(API._('ERR_VFS_UNAVAILABLE'));
}
OSjs.VFS._NullModule.request.apply(null, arguments);
OSjs.VFS.Transports.Internal.request.apply(null, arguments);
}

/////////////////////////////////////////////////////////////////////////////
Expand All @@ -76,7 +76,7 @@
/**
* This is a virtual module for showing 'dist' files in OS.js
*
* @see OSjs.VFS.Modules._NullModule
* @see OSjs.VFS.Transports.Internal
* @api OSjs.VFS.Modules.OSjs
*/
OSjs.VFS.Modules.OSjs = OSjs.VFS.Modules.OSjs || {
Expand All @@ -88,7 +88,8 @@
visible: true,
internal: true,
unmount: function(cb) {
OSjs.VFS._NullModule.unmount(cb);
cb = cb || function() {};
cb(API._('ERR_VFS_UNAVAILABLE'), false);
},
mounted: function() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/**
* This is a virtual module for showing 'dist' files in OS.js
*
* @see OSjs.VFS.Modules._NullModule
* @see OSjs.VFS.Transports.Internal
* @api OSjs.VFS.Modules.User
*/
OSjs.VFS.Modules.User = OSjs.VFS.Modules.User || {
Expand All @@ -53,18 +53,16 @@
visible: true,
internal: true,
unmount: function(cb) {
OSjs.VFS._NullModule.unmount(cb);
cb = cb || function() {};
cb(API._('ERR_VFS_UNAVAILABLE'), false);
},
mounted: function() {
return true;
},
enabled: function() {
return true;
},
request: function() {
// This module uses the same API as public
OSjs.VFS._NullModule.request.apply(null, arguments);
}
request: OSjs.VFS.Transports.Internal.request
};

})(OSjs.Utils, OSjs.API);
Loading

0 comments on commit fea7e1a

Please sign in to comment.