diff --git a/core/modules/server/server.js b/core/modules/server/server.js index 258ddfa31..65fc6d475 100644 --- a/core/modules/server/server.js +++ b/core/modules/server/server.js @@ -43,6 +43,14 @@ function Server(options) { } } } + // Register server extensions + this.extensions = []; + $tw.modules.forEachModuleOfType("server-extension",function(title,exports) { + var extension = new exports.Extension(self); + self.extensions.push(extension); + }); + // Initialise server extensions + this.invokeExtensionHook("server-start-initialisation"); // Setup the default required plugins this.requiredPlugins = this.get("required-plugins").split(','); // Initialise CSRF @@ -96,8 +104,16 @@ function Server(options) { this.servername = $tw.utils.transliterateToSafeASCII(this.get("server-name") || this.wiki.getTiddlerText("$:/SiteTitle") || "TiddlyWiki5"); this.boot.origin = this.get("origin")? this.get("origin"): this.protocol+"://"+this.get("host")+":"+this.get("port"); this.boot.pathPrefix = this.get("path-prefix") || ""; + // Complete initialisation of server extensions + this.invokeExtensionHook("server-completed-initialisation"); } +Server.prototype.invokeExtensionHook = function(hookName) { + $tw.utils.each(this.extensions,function(extension) { + extension.hook(hookName); + }); +}; + /* Send a response to the client. This method checks if the response must be sent or if the client alrady has the data cached. If that's the case only a 304 diff --git a/plugins/tiddlywiki/multiwikiserver/modules/server-extension.js b/plugins/tiddlywiki/multiwikiserver/modules/server-extension.js new file mode 100644 index 000000000..41be69f00 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiserver/modules/server-extension.js @@ -0,0 +1,25 @@ +/*\ +title: $:/plugins/tiddlywiki/multiwikiserver/server-extension.js +type: application/javascript +module-type: server-extension + +Multi wiki server extension for the core server object + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +function Extension(server) { + this.server = server; +} + +Extension.prototype.hook = function(name) { + +}; + +exports.Extension = Extension; + +})();