Created
March 14, 2009 20:38
-
-
Save FND/79178 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* make Bespin use the local file system for storage | |
* | |
* requires jquery.file.save and jquery.file.load: | |
* http://trac.tiddlywiki.org/browser/Trunk/core/jquery/plugins/ | |
*/ | |
(function() { | |
// provide jQuery functionality required by file-system code | |
jQuery = { | |
extend: function(target, obj1, obj2) { | |
return dojo.mixin(target, obj1, obj2); | |
}, | |
browser: { | |
msie: dojo.isIE | |
} | |
}; | |
// methods for accessing local file system | |
var localFS = { | |
newFile: function(project, path, onSuccess) { | |
}, | |
loadFile: function(project, path, onSuccess, dontStartSession) { | |
var filepath = path; // XXX: untested | |
jQuery.file.load(filepath); | |
}, | |
forceOpenFile: function(project, path, content) { | |
}, | |
projects: function(callback) { | |
}, | |
fileNames: function(project, callback) { | |
}, | |
saveFile: function(project, file) { | |
var filepath = project + "_" + file; | |
var contents = ""; // TODO | |
jQuery.file.save(filepath, contents); | |
}, | |
makeDirectory: function(project, path, onSuccess, onFailure) { | |
}, | |
removeDirectory: function(project, path, onSuccess, onFailure) { | |
}, | |
removeFile: function(project, path, onSuccess, onFailure) { | |
}, | |
closeFile: function(project, path, callback) { | |
}, | |
whenFileExists: function(project, path, callbacks) { | |
}, | |
whenFileDoesNotExist: function(project, path, callbacks) { | |
} | |
}; | |
// modify existing instance -- XXX: hacky; better to use an instance based on a subclass!? | |
var fs = bespin.get("files"); | |
for(var i in fs) { // XXX: unsafe? | |
fs[i] = localFS[i] || fs[i]; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment