mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-28 15:34:53 +00:00
Add a file system sync adaptor for the server
It's going to save tiddler changes to the file system
This commit is contained in:
54
plugins/tiddlywiki/filesystem/filesystemadaptor.js
Normal file
54
plugins/tiddlywiki/filesystem/filesystemadaptor.js
Normal file
@@ -0,0 +1,54 @@
|
||||
/*\
|
||||
title: $:/plugins/tiddlywiki/filesystem/filesystemadaptor.js
|
||||
type: application/javascript
|
||||
module-type: syncadaptor
|
||||
|
||||
A sync adaptor module for synchronising with the local filesystem via node.js APIs
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
// Get a reference to the file system
|
||||
var fs = !$tw.browser ? require("fs") : null;
|
||||
|
||||
function FileSystemAdaptor(syncer) {
|
||||
this.syncer = syncer;
|
||||
}
|
||||
|
||||
FileSystemAdaptor.prototype.getTiddlerInfo = function(tiddler) {
|
||||
return {};
|
||||
};
|
||||
|
||||
/*
|
||||
Save a tiddler and invoke the callback with (err,adaptorInfo,revision)
|
||||
*/
|
||||
FileSystemAdaptor.prototype.saveTiddler = function(tiddler,callback) {
|
||||
console.log("FileSystem: Saving",tiddler.fields);
|
||||
callback(null,{},0);
|
||||
};
|
||||
|
||||
/*
|
||||
Load a tiddler and invoke the callback with (err,tiddlerFields)
|
||||
*/
|
||||
FileSystemAdaptor.prototype.loadTiddler = function(title,callback) {
|
||||
console.log("FileSystem: Loading",title);
|
||||
callback(null,{title: title, text: "Fake tiddler: " + title});
|
||||
};
|
||||
|
||||
/*
|
||||
Delete a tiddler and invoke the callback with (err)
|
||||
*/
|
||||
FileSystemAdaptor.prototype.deleteTiddler = function(title,callback) {
|
||||
console.log("FileSystem: Deleting",title);
|
||||
callback(null);
|
||||
};
|
||||
|
||||
if(fs) {
|
||||
exports.adaptorClass = FileSystemAdaptor;
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user