/*\ title: $:/plugins/tiddlywiki/multiwikiclient/multiwikiclientadaptor.js type: application/javascript module-type: syncadaptor A sync adaptor module for synchronising with MultiWikiServer-compatible servers \*/ (function(){ /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; var CONFIG_HOST_TIDDLER = "$:/config/multiwikiclient/host", DEFAULT_HOST_TIDDLER = "$protocol$//$host$/", BAG_STATE_TIDDLER = "$:/state/federatial/xememex/tiddlers/bag", REVISION_STATE_TIDDLER = "$:/state/federatial/xememex/tiddlers/revision"; function MultiWikiClientAdaptor(options) { this.wiki = options.wiki; this.host = this.getHost(); this.recipe = this.wiki.getTiddlerText("$:/config/multiwikiclient/recipe"); this.logger = new $tw.utils.Logger("MultiWikiClientAdaptor"); this.isLoggedIn = false; this.isReadOnly = false; this.logoutIsAvailable = true; } MultiWikiClientAdaptor.prototype.name = "multiwikiclient"; MultiWikiClientAdaptor.prototype.supportsLazyLoading = true; MultiWikiClientAdaptor.prototype.setLoggerSaveBuffer = function(loggerForSaving) { this.logger.setSaveBuffer(loggerForSaving); }; MultiWikiClientAdaptor.prototype.isReady = function() { return true; }; MultiWikiClientAdaptor.prototype.getHost = function() { var text = this.wiki.getTiddlerText(CONFIG_HOST_TIDDLER,DEFAULT_HOST_TIDDLER), substitutions = [ {name: "protocol", value: document.location.protocol}, {name: "host", value: document.location.host}, {name: "pathname", value: document.location.pathname} ]; for(var t=0; t/" ``` */ MultiWikiClientAdaptor.prototype.parseEtag = function(etag) { const PREFIX = "\"tiddler:"; if(etag.startsWith(PREFIX)) { const slashPos = etag.indexOf("/"); if(slashPos !== -1) { const bag_name = etag.slice(PREFIX.length,slashPos), revision = parseInt(etag.slice(slashPos + 1),10); if(!isNaN(revision)) { return { bag_name: bag_name, revision: revision }; } } } return null; }; if($tw.browser && document.location.protocol.substr(0,4) === "http" ) { exports.adaptorClass = MultiWikiClientAdaptor; } })();