From eee3a0cf8e5aa047f8596df06e28194409f38b01 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Fri, 13 Jun 2014 14:44:34 +0100 Subject: [PATCH] Extend server command to allow a path prefix Thereby making the number of parameters to the command ludicrous --- core/language/en-GB/Help/server.tid | 3 ++- core/modules/commands/server.js | 20 ++++++++++++++++--- ... prefix with the client-server edition.tid | 14 +++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 editions/tw5.com/tiddlers/howtos/Using a custom path prefix with the client-server edition.tid diff --git a/core/language/en-GB/Help/server.tid b/core/language/en-GB/Help/server.tid index ef900b5bd..0f2b0e63a 100644 --- a/core/language/en-GB/Help/server.tid +++ b/core/language/en-GB/Help/server.tid @@ -6,7 +6,7 @@ The server built in to TiddlyWiki5 is very simple. Although compatible with Tidd At the root, it serves a rendering of a specified tiddler. Away from the root, it serves individual tiddlers encoded in JSON, and supports the basic HTTP operations for `GET`, `PUT` and `DELETE`. ``` ---server +--server ``` The parameters are: @@ -18,6 +18,7 @@ The parameters are: * ''username'' - the default username for signing edits * ''password'' - optional password for basic authentication * ''host'' - optional hostname to serve from (defaults to "127.0.0.1" aka "localhost") +* ''pathprefix'' - optional prefix for paths If the password parameter is specified then the browser will prompt the user for the username and password. Note that the password is transmitted in plain text so this implementation isn't suitable for general use. diff --git a/core/modules/commands/server.js b/core/modules/commands/server.js index eb78bfa67..e724aa53f 100644 --- a/core/modules/commands/server.js +++ b/core/modules/commands/server.js @@ -50,10 +50,22 @@ SimpleServer.prototype.addRoute = function(route) { }; SimpleServer.prototype.findMatchingRoute = function(request,state) { + var pathprefix = this.get("pathprefix") || ""; for(var t=0; t