Allow username to be set for the built-in server

print-window-tiddler
Jeremy Ruston 2013-08-21 09:53:45 +01:00
rodzic 9345078926
commit a427702628
3 zmienionych plików z 16 dodań i 15 usunięć

Wyświetl plik

@ -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) {

Wyświetl plik

@ -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 <port> <roottiddler> <rendertype> <servetype>
```
For example:
```
--server 8080 $:/core/tiddlywiki5.template.html text/plain text/html
--server <port> <roottiddler> <rendertype> <servetype> <username>
```
The parameters are:
```
--server <port> <roottiddler> <rendertype> <servetype>
```
* ''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
```

Wyświetl plik

@ -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