1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +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:
Jeremy Ruston 2013-03-24 12:22:21 +00:00
parent 6eb48e7058
commit 7df3d48451
3 changed files with 63 additions and 1 deletions

View File

@ -1,6 +1,7 @@
{
"plugins": [
"tiddlywiki/tiddlyweb"
"tiddlywiki/tiddlyweb",
"tiddlywiki/filesystem"
],
"parentWiki": "../tw5.com"
}

View 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;
}
})();

View File

@ -0,0 +1,7 @@
{
"title": "$:/plugins/tiddlywiki/filesystem",
"description": "File system synchronisation",
"author": "JeremyRuston",
"version": "0.0.0",
"coreVersion": ">=5.0.0"
}