From bd7db62da052ec6262c3319eaa11f00e5c452a7b Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sun, 29 Dec 2013 13:07:06 +0000 Subject: [PATCH] Added support for specifying hostname for the --server command Fixes #301 --- core/modules/commands/server.js | 11 ++++++----- editions/tw5.com/tiddlers/commands/ServerCommand.tid | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/modules/commands/server.js b/core/modules/commands/server.js index 47071a044..3b0ddc32e 100644 --- a/core/modules/commands/server.js +++ b/core/modules/commands/server.js @@ -79,7 +79,7 @@ SimpleServer.prototype.checkCredentials = function(request,incomingUsername,inco } } -SimpleServer.prototype.listen = function(port) { +SimpleServer.prototype.listen = function(port,host) { var self = this; http.createServer(function(request,response) { // Compose the state object @@ -125,7 +125,7 @@ SimpleServer.prototype.listen = function(port) { }); break; } - }).listen(port); + }).listen(port,host); }; var Command = function(params,commander,callback) { @@ -264,7 +264,8 @@ Command.prototype.execute = function() { renderType = this.params[2] || "text/plain", serveType = this.params[3] || "text/html", username = this.params[4], - password = this.params[5]; + password = this.params[5], + host = this.params[6]; this.server.set({ rootTiddler: rootTiddler, renderType: renderType, @@ -272,8 +273,8 @@ Command.prototype.execute = function() { username: username, password: password }); - this.server.listen(port); - console.log("Serving on port " + port); + this.server.listen(port,host); + console.log("Serving on " + host + ":" + port); console.log("(press ctrl-C to exit)"); return null; }; diff --git a/editions/tw5.com/tiddlers/commands/ServerCommand.tid b/editions/tw5.com/tiddlers/commands/ServerCommand.tid index 750cb91f6..4d282083d 100644 --- a/editions/tw5.com/tiddlers/commands/ServerCommand.tid +++ b/editions/tw5.com/tiddlers/commands/ServerCommand.tid @@ -1,5 +1,5 @@ created: 20131219163923630 -modified: 20131222150651114 +modified: 20131229130513478 tags: command title: ServerCommand type: text/vnd.tiddlywiki @@ -9,7 +9,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: @@ -20,6 +20,7 @@ The parameters are: * ''servetype'' - the content type with which the root tiddler should be served (defaults to "text/html") * ''username'' - the default username for signing edits * ''password'' - optional password for basic authentication +* ''host'' - optional hostname to serve from (defaults to "0.0.0.0") 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.