[
    {
        "text": "{\n    \"tiddlers\": {\n        \"$:/plugins/iilyak/static/adaptor.js\": {\n            \"title\": \"$:/plugins/iilyak/static/adaptor.js\",\n            \"text\": \"/*\\\\\\ntitle: $:/plugins/iilyak/static/adaptor.js\\ntype: application/javascript\\nmodule-type: syncadaptor\\n\\nA sync adaptor module for synchronising with TiddlyWeb compatible servers\\n\\n\\\\*/\\n(function(){\\n\\n/*jslint node: true, browser: true */\\n/*global $tw: false */\\n\\\"use strict\\\";\\n\\nvar CONFIG_HOST_TIDDLER = \\\"$:/config/tiddlyweb/host\\\",\\n\\tDEFAULT_HOST_TIDDLER = \\\"$protocol$//$host$/\\\";\\n\\nfunction StaticWebAdaptor(options) {\\n\\n\\tthis.wiki = options.wiki;\\n\\tthis.host = this.getHost();\\n\\tthis.recipe = undefined;\\n\\tthis.hasStatus = false;\\n\\tthis.logger = new $tw.utils.Logger(\\\"StaticWebAdaptor\\\");\\n\\tthis.isLoggedIn = false;\\n\\tthis.isReadOnly = true;\\n}\\n\\nStaticWebAdaptor.prototype.name = \\\"static\\\";\\n\\nStaticWebAdaptor.prototype.isReady = function() {\\n\\treturn this.hasStatus;\\n};\\n\\nStaticWebAdaptor.prototype.getHost = function() {\\n\\tvar text = this.wiki.getTiddlerText(CONFIG_HOST_TIDDLER,DEFAULT_HOST_TIDDLER),\\n\\t\\tsubstitutions = [\\n\\t\\t\\t{name: \\\"protocol\\\", value: document.location.protocol},\\n\\t\\t\\t{name: \\\"host\\\", value: document.location.host}\\n\\t\\t];\\n\\tfor(var t=0; t<substitutions.length; t++) {\\n\\t\\tvar s = substitutions[t];\\n\\t\\ttext = $tw.utils.replaceString(text,new RegExp(\\\"\\\\\\\\$\\\" + s.name + \\\"\\\\\\\\$\\\",\\\"mg\\\"),s.value);\\n\\t}\\t\\n\\treturn text;\\n};\\n\\nStaticWebAdaptor.prototype.getTiddlerInfo = function(tiddler) {\\n\\treturn {\\n\\t\\tbag: tiddler.fields.bag\\n\\t};\\n};\\n\\n/*\\nGet the current status of the TiddlyWeb connection\\n*/\\nStaticWebAdaptor.prototype.getStatus = function(callback) {\\n\\tvar self = this;\\n\\tself.isLoggedIn = false;\\n\\tself.isReadOnly = true;\\n\\tself.isAnonymous = true;\\n\\tself.hasStatus = true;\\n\\t// Invoke the callback if present\\n\\tif(callback) {\\n\\t\\tcallback(null,self.isLoggedIn,\\\"UNAUTHENTICATED\\\",self.isReadOnly,self.isAnonymous);\\n\\t}\\n};\\n\\n/*\\nAttempt to login and invoke the callback(err)\\n*/\\nStaticWebAdaptor.prototype.login = function(username,password,callback) {\\n\\tif(callback) {\\n\\t\\tcallback(null);\\n\\t};\\n};\\n\\n/*\\n*/\\nStaticWebAdaptor.prototype.logout = function(callback) {\\n\\tif(callback) {\\n\\t\\tcallback(null);\\n\\t};\\n};\\n\\n/*\\nGet an array of skinny tiddler fields from the server\\n*/\\nStaticWebAdaptor.prototype.getSkinnyTiddlers = function(callback) {\\n\\tvar self = this;\\n\\t$tw.utils.httpRequest({\\n\\t\\turl: this.host + \\\"tiddlers.json\\\",\\n\\t\\tcallback: function(err,data) {\\n\\t\\t\\t// Check for errors\\n\\t\\t\\tif(err) {\\n\\t\\t\\t\\treturn callback(err);\\n\\t\\t\\t}\\n\\t\\t\\t// Process the tiddlers to make sure the revision is a string\\n\\t\\t\\tvar tiddlers = JSON.parse(data);\\n\\t\\t\\tfor(var t=0; t<tiddlers.length; t++) {\\n\\t\\t\\t\\ttiddlers[t] = self.convertTiddlerFromTiddlyWebFormat(tiddlers[t]);\\n\\t\\t\\t}\\n\\t\\t\\t// Invoke the callback with the skinny tiddlers\\n\\t\\t\\tcallback(null,tiddlers);\\n\\t\\t}\\n\\t});\\n};\\n\\n/*\\nSave a tiddler and invoke the callback with (err,adaptorInfo,revision)\\n*/\\nStaticWebAdaptor.prototype.saveTiddler = function(tiddler,callback) {\\n\\treturn callback(null);\\n};\\n\\n/*\\nLoad a tiddler and invoke the callback with (err,tiddlerFields)\\n*/\\nStaticWebAdaptor.prototype.loadTiddler = function(title,callback) {\\n\\tvar self = this;\\n\\t$tw.utils.httpRequest({\\n\\t\\turl: this.host + \\\"tiddlers/\\\" + encodeURIComponent(title),\\n\\t\\tcallback: function(err,data,request) {\\n\\t\\t\\tif(err) {\\n\\t\\t\\t\\treturn callback(err);\\n\\t\\t\\t}\\n\\t\\t\\t// Invoke the callback\\n\\t\\t\\tcallback(null,self.convertTiddlerFromTiddlyWebFormat(JSON.parse(data)));\\n\\t\\t}\\n\\t});\\n};\\n\\n/*\\nDelete a tiddler and invoke the callback with (err)\\noptions include:\\ntiddlerInfo: the syncer's tiddlerInfo for this tiddler\\n*/\\nStaticWebAdaptor.prototype.deleteTiddler = function(title,callback,options) {\\n\\treturn callback(null);\\n};\\n\\n/*\\nConvert a field set in TiddlyWeb format into ordinary TiddlyWiki5 format\\n*/\\nStaticWebAdaptor.prototype.convertTiddlerFromTiddlyWebFormat = function(tiddlerFields) {\\n\\tvar self = this,\\n\\t\\tresult = {};\\n\\t\\t\\n\\t// Transfer the fields, pulling down the `fields` hashmap\\n\\t$tw.utils.each(tiddlerFields,function(element,title,object) {\\n\\t\\tif(title === \\\"fields\\\") {\\n\\t\\t\\t$tw.utils.each(element,function(element,subTitle,object) {\\n\\t\\t\\t\\tresult[subTitle] = element;\\n\\t\\t\\t});\\n\\t\\t} else {\\n\\t\\t\\tresult[title] = tiddlerFields[title];\\n\\t\\t}\\n\\t});\\n\\t// Make sure the revision is expressed as a string\\n\\tif(typeof result.revision === \\\"number\\\") {\\n\\t\\tresult.revision = result.revision.toString();\\n\\t}\\n\\t// Some unholy freaking of content types\\n\\tif(result.type === \\\"text/javascript\\\") {\\n\\t\\tresult.type = \\\"application/javascript\\\";\\n\\t} else if(!result.type || result.type === \\\"None\\\") {\\n\\t\\tresult.type = \\\"text/x-tiddlywiki\\\";\\n\\t}\\n\\treturn result;\\n};\\n\\nif($tw.browser && document.location.protocol.substr(0,4) === \\\"http\\\" ) {\\n\\texports.adaptorClass = StaticWebAdaptor;\\n}\\n\\n})();\\n\",\n            \"type\": \"application/javascript\",\n            \"module-type\": \"syncadaptor\"\n        }\n    }\n}",
        "version": "5.1.22-prerelease",
        "type": "application/json",
        "title": "$:/plugins/iilyak/static",
        "plugin-type": "plugin",
        "name": "Static",
        "list": "",
        "description": "Read-only sync adapter to host static web site",
        "dependents": ""
    }
]