From a427702628627a110e61f82b947779bf1ee742fe Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 21 Aug 2013 09:53:45 +0100 Subject: [PATCH] Allow username to be set for the built-in server --- core/modules/commands/server.js | 8 +++++--- .../tiddlers/commands/ServerCommand.tid | 19 ++++++++----------- serve.sh | 4 +++- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core/modules/commands/server.js b/core/modules/commands/server.js index 330504807..78e3f5962 100644 --- a/core/modules/commands/server.js +++ b/core/modules/commands/server.js @@ -157,7 +157,7 @@ var Command = function(params,commander,callback) { handler: function(request,response,state) { response.writeHead(200, {"Content-Type": "application/json"}); var text = JSON.stringify({ - username: "ANONYMOUS", + username: state.server.get("username"), space: { recipe: "default" }, @@ -221,11 +221,13 @@ Command.prototype.execute = function() { var port = this.params[0] || "8080", rootTiddler = this.params[1] || "$:/core/templates/tiddlywiki5.template.html", renderType = this.params[2] || "text/plain", - serveType = this.params[3] || "text/html"; + serveType = this.params[3] || "text/html", + username = this.params[4] || "ANONYMOUS"; this.server.set({ rootTiddler: rootTiddler, renderType: renderType, - serveType: serveType + serveType: serveType, + username: username }); this.server.listen(port); if(this.commander.verbose) { diff --git a/editions/tw5.com/tiddlers/commands/ServerCommand.tid b/editions/tw5.com/tiddlers/commands/ServerCommand.tid index f41795f9a..5dcc49dce 100644 --- a/editions/tw5.com/tiddlers/commands/ServerCommand.tid +++ b/editions/tw5.com/tiddlers/commands/ServerCommand.tid @@ -6,22 +6,19 @@ 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 -``` - -For example: - -``` ---server 8080 $:/core/tiddlywiki5.template.html text/plain text/html +--server ``` The parameters are: -``` ---server -``` - * ''port'' - port number to serve from (defaults to "8080") * ''roottiddler'' - the tiddler to serve at the root (defaults to "$:/core/tiddlywiki5.template.html") * ''rendertype'' - the content type to which the root tiddler should be rendered (defaults to "text/plain") * ''servetype'' - the content type with which the root tiddler should be served (defaults to "text/html") +* ''username'' - the default username for signing edits + +For example: + +``` +--server 8080 $:/core/tiddlywiki5.template.html text/plain text/html MyUserName +``` diff --git a/serve.sh b/serve.sh index 8dabf2159..e50d2283b 100755 --- a/serve.sh +++ b/serve.sh @@ -2,8 +2,10 @@ # serve TiddlyWiki5 over HTTP +# Optional parameter is the username for signing edits + node ./tiddlywiki.js \ editions/clientserver \ --verbose \ - --server 8080 $:/core/templates/tiddlywiki5.template.html text/plain text/html \ + --server 8080 $:/core/templates/tiddlywiki5.template.html text/plain text/html $1\ || exit 1