From ae3c4099b341917dfabfd90c99e9feebc063b9f5 Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Sat, 17 Nov 2018 21:55:46 +0000 Subject: [PATCH 1/4] Enable serving the tiddlywiki at a non-root path --- Dockerfile | 1 + init-and-run-wiki | 21 ++++++++++++++++++++- tiddlyweb_host | 4 ++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tiddlyweb_host diff --git a/Dockerfile b/Dockerfile index a79b22f..34467d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ VOLUME /var/lib/tiddlywiki WORKDIR /var/lib/tiddlywiki # Add init-and-run script +ADD tiddlyweb_host /tiddlyweb_host_template ADD init-and-run-wiki /usr/local/bin/init-and-run-wiki # Meta diff --git a/init-and-run-wiki b/init-and-run-wiki index ce1fd5b..d5036e6 100755 --- a/init-and-run-wiki +++ b/init-and-run-wiki @@ -12,7 +12,26 @@ fi if [ ! -d /var/lib/tiddlywiki/mywiki ]; then /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --init server + + mkdir /var/lib/tiddlywiki/mywiki/tiddlers fi -exec /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --server 8080 $:/core/save/all text/plain text/html ${USERNAME:-user} ${PASSWORD:-'wiki'} 0.0.0.0 + +# Configure the tiddlywiki to be served on a path if it is given +WEBHOST_TID=/var/lib/tiddlywiki/mywiki/tiddlers/\$__config_tiddlyweb_host.tid +if [ -n "${SERVE_URI}" ] +then + cp /tiddlyweb_host_template ${WEBHOST_TID} + echo '$protocol$//$host$'${SERVE_URI}"/" >> ${WEBHOST_TID} + echo "tiddlywiki will be served at ${SERVE_URI}" +else + if [ -e ${WEBHOST_TID} ] + then + rm ${WEBHOST_TID} + fi +fi + +# Start the tiddlywiki server + +exec /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --server 8080 $:/core/save/all text/plain text/html ${USERNAME:-user} ${PASSWORD:-'wiki'} 0.0.0.0 ${SERVE_URI} diff --git a/tiddlyweb_host b/tiddlyweb_host new file mode 100644 index 0000000..ccc6b36 --- /dev/null +++ b/tiddlyweb_host @@ -0,0 +1,4 @@ +title: $:/config/tiddlyweb/host +type: text/vnd.tiddlywiki + + From a17d8616fbcf672b87ad7b6da465b45dc04dbf63 Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Sat, 17 Nov 2018 22:04:33 +0000 Subject: [PATCH 2/4] Added SERVE_URI docs --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a680df0..dea20ff 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,5 @@ Simply provide the USERNAME and PASSWORD env variables to customise. If you are in a memory-constrained environment, you can provide the `NODE_MEM` environment variable to specify the memory ceiling (in MB) + +To serve the tiddlywiki at a [non-root prefix path](https://tiddlywiki.com/static/Using%2520a%2520custom%2520path%2520prefix%2520with%2520the%2520client-server%2520edition.html) set the `SERVE_URI` environment variable: this variable ''must'' start with a forward slash character. The tiddlywiki will be served by the container at http:///${SERVE_URI} - the container initialization script takes care of setting the required host configuration tiddler. \ No newline at end of file From 77c1b6eff08d5b5b964d3393a07ef9e23e9c85d1 Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Mon, 10 Dec 2018 15:16:47 +0000 Subject: [PATCH 3/4] Update if/then style --- init-and-run-wiki | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/init-and-run-wiki b/init-and-run-wiki index d5036e6..b425c5d 100755 --- a/init-and-run-wiki +++ b/init-and-run-wiki @@ -19,8 +19,7 @@ fi # Configure the tiddlywiki to be served on a path if it is given WEBHOST_TID=/var/lib/tiddlywiki/mywiki/tiddlers/\$__config_tiddlyweb_host.tid -if [ -n "${SERVE_URI}" ] -then +if [ -n "${SERVE_URI}" ]; then cp /tiddlyweb_host_template ${WEBHOST_TID} echo '$protocol$//$host$'${SERVE_URI}"/" >> ${WEBHOST_TID} echo "tiddlywiki will be served at ${SERVE_URI}" From 4f8763266d71955ad84039e4d75e66750c2eb21d Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Wed, 12 Dec 2018 12:56:00 +0000 Subject: [PATCH 4/4] Change if/then style --- init-and-run-wiki | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/init-and-run-wiki b/init-and-run-wiki index b425c5d..67181ce 100755 --- a/init-and-run-wiki +++ b/init-and-run-wiki @@ -24,8 +24,7 @@ if [ -n "${SERVE_URI}" ]; then echo '$protocol$//$host$'${SERVE_URI}"/" >> ${WEBHOST_TID} echo "tiddlywiki will be served at ${SERVE_URI}" else - if [ -e ${WEBHOST_TID} ] - then + if [ -e ${WEBHOST_TID} ]; then rm ${WEBHOST_TID} fi fi