From 05dfddeb046f7913dc624ee36b83e25eede538de Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Thu, 11 Sep 2014 10:22:54 +0200 Subject: [PATCH 1/4] make serve.cmd useful for everyone and use sensible defaults, so it works for different editions out of the box --- bin/serve.cmd | 70 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/bin/serve.cmd b/bin/serve.cmd index 0f663ec5e..6aa6616c7 100644 --- a/bin/serve.cmd +++ b/bin/serve.cmd @@ -1,11 +1,73 @@ +:: This file uses the default settings for Jeremy and +:: provides some help and more parameters for the rest of us. + @echo off +echo. -rem serve TiddlyWiki5 over HTTP +if "%1" == "--help" ( + call :help +) -rem Optional parameter is the username for signing edits +if "%1" == "help" ( + call :help +) else ( + echo %1 %2 %3 %4 %5 + call :main %1 %2 %3 %4 %5 +) +exit 0 + +:help +echo Serve TiddlyWiki5 over HTTP +echo. +echo Optional parameters +echo - %%1 .. editions directory .. full path or relative to current directory +echo - %%2 .. username for signing edits - can be empty like this: '""' +echo - %%3 .. password - can be empty like this: '""' +echo - %%4 .. IP address or HOST name .. defaults to localhost +echo - %%5 .. PORT .. defaults to 8080 +echo. +echo Example 1 .\serve .\edition\tw5.com-server username +echo Example 2 .\serve .\edition\tw5.com-server '""' '""' localhost 9090 +echo .. Example 2 defines: empty username, empty password +echo. +goto:eof + +:main +if [%1] NEQ [] ( + :: if there is a editions parameter .. use it. + set TIDDLYWIKI_EDITION_PATH=%1 +) else ( + if [%TIDDLYWIKI_EDITION_PATH%] == [] ( + echo Provide an edition path as your first parameter or + echo Define a valid TIDDLYWIKI_EDITION_PATH environment variable. + echo. + echo No environment variable set, using the default settings! + echo. + set TIDDLYWIKI_EDITION_PATH= editions\tw5.com-server + ) +) + +:: The editions path must exist! +if not exist %TIDDLYWIKI_EDITION_PATH%\nul ( + echo The Path: "%TIDDLYWIKI_EDITION_PATH%" doesn't exist. Create it! + exit 1 +) + +if [%5] == [] ( + echo Using default port 8080 + set PORT=8080 +) else ( + echo Using port %5 + set PORT=%5 +) + +echo Usging edition: %TIDDLYWIKI_EDITION_PATH% !! +echo. node .\tiddlywiki.js ^ - editions\tw5.com-server ^ + %TIDDLYWIKI_EDITION_PATH% ^ --verbose ^ - --server 8080 $:/core/save/all text/plain text/html "%1" "%2" "%3"^ + --server %PORT% $:/core/save/all text/plain text/html %2 %3 %4^ || exit 1 +goto:eof + From ed4597f12d63ea3d42fc67e3d9d0d1266fbf2202 Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Thu, 11 Sep 2014 11:08:48 +0200 Subject: [PATCH 2/4] remove debug info --- bin/serve.cmd | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/serve.cmd b/bin/serve.cmd index 6aa6616c7..807947f05 100644 --- a/bin/serve.cmd +++ b/bin/serve.cmd @@ -11,7 +11,6 @@ if "%1" == "--help" ( if "%1" == "help" ( call :help ) else ( - echo %1 %2 %3 %4 %5 call :main %1 %2 %3 %4 %5 ) exit 0 From 53511029902680fb49067a27184fc17e19eea4ea Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Fri, 12 Sep 2014 12:31:03 +0200 Subject: [PATCH 3/4] better help text, more params to be the same with serve.sh. typo fixes --- bin/serve.cmd | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/bin/serve.cmd b/bin/serve.cmd index 807947f05..493dc66cc 100644 --- a/bin/serve.cmd +++ b/bin/serve.cmd @@ -4,9 +4,14 @@ @echo off echo. -if "%1" == "--help" ( - call :help -) +:: Help wanted!! +:: If someone knows, how to improve -help and -version handling tell me :) + +if "%1" == "--help" call :help +if "%1" == "-h" call :help + +if "%1" == "--version" call :version +if "%1" == "-v" call :version if "%1" == "help" ( call :help @@ -15,20 +20,32 @@ if "%1" == "help" ( ) exit 0 +:version +echo TiddlyWiki serve.cmd script version 0.0.1" +echo. +exit 0 +goto:eof + :help echo Serve TiddlyWiki5 over HTTP echo. echo Optional parameters -echo - %%1 .. editions directory .. full path or relative to current directory -echo - %%2 .. username for signing edits - can be empty like this: '""' -echo - %%3 .. password - can be empty like this: '""' -echo - %%4 .. IP address or HOST name .. defaults to localhost -echo - %%5 .. PORT .. defaults to 8080 +echo - %%1 .. editions directory .. full path or relative to current directory +echo - %%2 .. username .. for signing edits - can be empty like this: '""' +echo - %%3 .. password .. can be empty like this: '""' +echo - %%4 .. IP address or HOST .. defaults to localhost +echo - %%5 .. PORT .. defaults to 8080 echo. echo Example 1 .\serve .\edition\tw5.com-server username echo Example 2 .\serve .\edition\tw5.com-server '""' '""' localhost 9090 echo .. Example 2 defines: empty username, empty password echo. +echo Help information +echo -v, --version .. shows the script version +echo -h, --help, help .. shows this help information +echo. + +exit 0 goto:eof :main @@ -60,7 +77,7 @@ if [%5] == [] ( set PORT=%5 ) -echo Usging edition: %TIDDLYWIKI_EDITION_PATH% !! +echo Using edition: %TIDDLYWIKI_EDITION_PATH% !! echo. node .\tiddlywiki.js ^ From c430f9d2c3f709cb553a5cd65345153f1996e695 Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Fri, 12 Sep 2014 12:42:20 +0200 Subject: [PATCH 4/4] more docs --- bin/serve.cmd | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/serve.cmd b/bin/serve.cmd index 493dc66cc..50c4480a1 100644 --- a/bin/serve.cmd +++ b/bin/serve.cmd @@ -1,6 +1,14 @@ :: This file uses the default settings for Jeremy and :: provides some help and more parameters for the rest of us. +:: This script allows you to serve different TiddlyWiki editions. +:: It respects the TIDDLYWIKI_EDITION_PATH variable described +:: at: # http://tiddlywiki.com/#Environment%20Variables%20on%20Node.js +:: +:: Be sure your server tiddlywiki.info configuration contains the plugins: +:: - "tiddlywiki/tiddlyweb" and the "tiddlywiki/filesystem" +:: - Otherwise saving is not possible. + @echo off echo.