1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Allow username to be set for the built-in server

This commit is contained in:
Jeremy Ruston 2013-08-21 09:53:45 +01:00
parent 9345078926
commit a427702628
3 changed files with 16 additions and 15 deletions

View File

@ -157,7 +157,7 @@ var Command = function(params,commander,callback) {
handler: function(request,response,state) { handler: function(request,response,state) {
response.writeHead(200, {"Content-Type": "application/json"}); response.writeHead(200, {"Content-Type": "application/json"});
var text = JSON.stringify({ var text = JSON.stringify({
username: "ANONYMOUS", username: state.server.get("username"),
space: { space: {
recipe: "default" recipe: "default"
}, },
@ -221,11 +221,13 @@ Command.prototype.execute = function() {
var port = this.params[0] || "8080", var port = this.params[0] || "8080",
rootTiddler = this.params[1] || "$:/core/templates/tiddlywiki5.template.html", rootTiddler = this.params[1] || "$:/core/templates/tiddlywiki5.template.html",
renderType = this.params[2] || "text/plain", 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({ this.server.set({
rootTiddler: rootTiddler, rootTiddler: rootTiddler,
renderType: renderType, renderType: renderType,
serveType: serveType serveType: serveType,
username: username
}); });
this.server.listen(port); this.server.listen(port);
if(this.commander.verbose) { if(this.commander.verbose) {

View File

@ -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`. 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> --server <port> <roottiddler> <rendertype> <servetype> <username>
```
For example:
```
--server 8080 $:/core/tiddlywiki5.template.html text/plain text/html
``` ```
The parameters are: The parameters are:
```
--server <port> <roottiddler> <rendertype> <servetype>
```
* ''port'' - port number to serve from (defaults to "8080") * ''port'' - port number to serve from (defaults to "8080")
* ''roottiddler'' - the tiddler to serve at the root (defaults to "$:/core/tiddlywiki5.template.html") * ''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") * ''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") * ''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
```

View File

@ -2,8 +2,10 @@
# serve TiddlyWiki5 over HTTP # serve TiddlyWiki5 over HTTP
# Optional parameter is the username for signing edits
node ./tiddlywiki.js \ node ./tiddlywiki.js \
editions/clientserver \ editions/clientserver \
--verbose \ --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 || exit 1