mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Make the syncer more configurable, including names for sync adaptors
@danielo515 you may want to add a name to your sync adaptor 😄
This commit is contained in:
parent
ced9f315a1
commit
6c65aa2a6d
@ -12,6 +12,18 @@ The syncer tracks changes to the store. If a syncadaptor is used then individual
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Defaults
|
||||
*/
|
||||
Syncer.prototype.titleIsLoggedIn = "$:/status/IsLoggedIn";
|
||||
Syncer.prototype.titleUserName = "$:/status/UserName";
|
||||
Syncer.prototype.titleSyncFilter = "$:/config/SyncFilter";
|
||||
Syncer.prototype.titleSavedNotification = "$:/language/Notifications/Save/Done";
|
||||
Syncer.prototype.taskTimerInterval = 1 * 1000; // Interval for sync timer
|
||||
Syncer.prototype.throttleInterval = 1 * 1000; // Defer saving tiddlers if they've changed in the last 1s...
|
||||
Syncer.prototype.fallbackInterval = 10 * 1000; // Unless the task is older than 10s
|
||||
Syncer.prototype.pollTimerInterval = 60 * 1000; // Interval for polling for changes from the adaptor
|
||||
|
||||
/*
|
||||
Instantiate the syncer with the following options:
|
||||
syncadaptor: reference to syncadaptor to be used
|
||||
@ -21,8 +33,17 @@ function Syncer(options) {
|
||||
var self = this;
|
||||
this.wiki = options.wiki;
|
||||
this.syncadaptor = options.syncadaptor;
|
||||
this.titleIsLoggedIn = options.titleIsLoggedIn || this.titleIsLoggedIn;
|
||||
this.titleUserName = options.titleUserName || this.titleUserName;
|
||||
this.titleSyncFilter = options.titleSyncFilter || this.titleSyncFilter;
|
||||
this.titleSavedNotification = options.titleSavedNotification || this.titleSavedNotification;
|
||||
this.taskTimerInterval = options.taskTimerInterval || this.taskTimerInterval;
|
||||
this.throttleInterval = options.throttleInterval || this.throttleInterval;
|
||||
this.fallbackInterval = options.fallbackInterval || this.fallbackInterval;
|
||||
this.pollTimerInterval = options.pollTimerInterval || this.pollTimerInterval;
|
||||
this.logging = $tw.utils.hop(options,"logging") ? options.logging : true;
|
||||
// Make a logger
|
||||
this.logger = new $tw.utils.Logger("syncer" + ($tw.browser ? "-browser" : "") + ($tw.node ? "-server" : ""));
|
||||
this.logger = new $tw.utils.Logger("syncer" + ($tw.browser ? "-browser" : "") + ($tw.node ? "-server" : "") + (this.syncadaptor.name ? ("-" + this.syncadaptor.name) : ""));
|
||||
// Compile the dirty tiddler filter
|
||||
this.filterFn = this.wiki.compileFilter(this.wiki.getTiddlerText(this.titleSyncFilter));
|
||||
// Record information for known tiddlers
|
||||
@ -69,19 +90,6 @@ function Syncer(options) {
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
Constants
|
||||
*/
|
||||
Syncer.prototype.titleIsLoggedIn = "$:/status/IsLoggedIn";
|
||||
Syncer.prototype.titleUserName = "$:/status/UserName";
|
||||
Syncer.prototype.titleSyncFilter = "$:/config/SyncFilter";
|
||||
Syncer.prototype.titleSavedNotification = "$:/language/Notifications/Save/Done";
|
||||
Syncer.prototype.taskTimerInterval = 1 * 1000; // Interval for sync timer
|
||||
Syncer.prototype.throttleInterval = 1 * 1000; // Defer saving tiddlers if they've changed in the last 1s...
|
||||
Syncer.prototype.fallbackInterval = 10 * 1000; // Unless the task is older than 10s
|
||||
Syncer.prototype.pollTimerInterval = 60 * 1000; // Interval for polling for changes from the adaptor
|
||||
|
||||
|
||||
/*
|
||||
Read (or re-read) the latest tiddler info from the store
|
||||
*/
|
||||
|
@ -24,6 +24,8 @@ function FileSystemAdaptor(options) {
|
||||
$tw.utils.createDirectory($tw.boot.wikiTiddlersPath);
|
||||
}
|
||||
|
||||
FileSystemAdaptor.prototype.name = "filesystem";
|
||||
|
||||
FileSystemAdaptor.prototype.isReady = function() {
|
||||
// The file system adaptor is always ready
|
||||
return true;
|
||||
|
@ -23,6 +23,8 @@ function TiddlyWebAdaptor(options) {
|
||||
this.logger = new $tw.utils.Logger("TiddlyWebAdaptor");
|
||||
}
|
||||
|
||||
TiddlyWebAdaptor.prototype.name = "tiddlyweb";
|
||||
|
||||
TiddlyWebAdaptor.prototype.isReady = function() {
|
||||
return this.hasStatus;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user