1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-08 23:03:50 +00:00

fix missuse of system environment variable

This commit is contained in:
Mario Pietsch 2014-09-12 17:37:37 +02:00
parent f187122c35
commit 1b11e4e949
2 changed files with 20 additions and 21 deletions

23
bin/serve.cmd Normal file → Executable file
View File

@ -1,11 +1,10 @@
:: This script allows you to serve different TiddlyWiki editions. :: This script allows you to serve different TiddlyWiki editions.
:: ::
:: It respects the TIDDLYWIKI_EDITION_PATH variable described :: It respects a TW_SERVE_EDITION_PATH environment variable.
:: at: # http://tiddlywiki.com/#Environment%20Variables%20on%20Node.js :: If this variable is set it will be used. A command line parameter will overwrite it.
:: ::
:: Ensure your server tiddlywiki.info configuration contains :: Ensure your server tiddlywiki.info configuration contains
:: these plugins, otherwise saving is not possible: :: these plugins, otherwise saving is not possible:
::
:: - "tiddlywiki/tiddlyweb" :: - "tiddlywiki/tiddlyweb"
:: - "tiddlywiki/filesystem" :: - "tiddlywiki/filesystem"
@ -29,7 +28,7 @@ if "%1" == "help" (
exit 0 exit 0
:version :version
echo TiddlyWiki serve.cmd script version 0.0.1" echo TiddlyWiki serve.cmd script version 0.0.2"
echo. echo.
exit 0 exit 0
goto:eof goto:eof
@ -59,21 +58,21 @@ goto:eof
:main :main
if [%1] NEQ [] ( if [%1] NEQ [] (
:: if there is a editions parameter .. use it. :: if there is a editions parameter .. use it.
set TIDDLYWIKI_EDITION_PATH=%1 set TW_SERVE_EDITION_PATH=%1
) else ( ) else (
if [%TIDDLYWIKI_EDITION_PATH%] == [] ( if [%TW_SERVE_EDITION_PATH%] == [] (
echo Please provide an edition path as your first parameter or echo Please provide an edition path as your first parameter or
echo define a valid TIDDLYWIKI_EDITION_PATH environment variable. echo define a valid TW_SERVE_EDITION_PATH environment variable.
echo. echo.
echo Using default edition path 'editions\tw5.com-server' because no environment variable is set echo Using default edition path 'editions\tw5.com-server' because no environment variable is set
echo. echo.
set TIDDLYWIKI_EDITION_PATH= editions\tw5.com-server set TW_SERVE_EDITION_PATH= editions\tw5.com-server
) )
) )
:: The editions path must exist! :: The editions path must exist!
if not exist %TIDDLYWIKI_EDITION_PATH%\nul ( if not exist %TW_SERVE_EDITION_PATH%\nul (
echo The Path: "%TIDDLYWIKI_EDITION_PATH%" does not exist echo The Path: "%TW_SERVE_EDITION_PATH%" does not exist
exit 1 exit 1
) )
@ -85,11 +84,11 @@ if [%5] == [] (
set PORT=%5 set PORT=%5
) )
echo Using edition: %TIDDLYWIKI_EDITION_PATH% echo Using edition: %TW_SERVE_EDITION_PATH%
echo. echo.
node .\tiddlywiki.js ^ node .\tiddlywiki.js ^
%TIDDLYWIKI_EDITION_PATH% ^ %TW_SERVE_EDITION_PATH% ^
--verbose ^ --verbose ^
--server %PORT% $:/core/save/all text/plain text/html %2 %3 %4^ --server %PORT% $:/core/save/all text/plain text/html %2 %3 %4^
|| exit 1 || exit 1

View File

@ -2,8 +2,8 @@
# #
# This script allows you to serve different TiddlyWiki editions. # This script allows you to serve different TiddlyWiki editions.
# #
# It respects the TIDDLYWIKI_EDITION_PATH variable described # It respects a TW_SERVE_EDITION_PATH environment variable.
# at: # http://tiddlywiki.com/#Environment%20Variables%20on%20Node.js # If this variable is set it will be used. A command line parameter will overwrite it.
# #
# Ensure your server tiddlywiki.info configuration contains # Ensure your server tiddlywiki.info configuration contains
# these plugins, otherwise saving is not possible: # these plugins, otherwise saving is not possible:
@ -21,7 +21,7 @@ ARG0=$(basename $0)
# ---- helper functions ---- # ---- helper functions ----
version () { version () {
echo "$ARG0, TiddlyWiki serve script version 0.0.1" echo "$ARG0, TiddlyWiki serve script version 0.0.2"
echo echo
} }
@ -75,8 +75,8 @@ serve () {
check_edition_directory () { check_edition_directory () {
# The editions directory must exist and should contain a tiddlywiki.info file # The editions directory must exist and should contain a tiddlywiki.info file
if [ ! -d $TIDDLYWIKI_EDITION_PATH ]; then if [ ! -d $TW_SERVE_EDITION_PATH ]; then
_log "Edition directory: '$TIDDLYWIKI_EDITION_PATH' does not exist" _log "Edition directory: '$TW_SERVE_EDITION_PATH' does not exist"
exit 1 exit 1
fi fi
} }
@ -100,13 +100,13 @@ shift $(expr $OPTIND - 1)
# If no edition parameter is provided, use Jeremy's defaults # If no edition parameter is provided, use Jeremy's defaults
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
# check if the edition path environment variable is set. If yes use it. # check if the edition path environment variable is set. If yes use it.
[ -z $TIDDLYWIKI_EDITION_PATH ] && TIDDLYWIKI_EDITION_PATH="./editions/tw5.com-server" [ -z $TW_SERVE_EDITION_PATH ] && TW_SERVE_EDITION_PATH="./editions/tw5.com-server"
# directory must exist # directory must exist
check_edition_directory check_edition_directory
# serve the default settings. # serve the default settings.
serve "$TIDDLYWIKI_EDITION_PATH" "" "" localhost 8080 serve "$TW_SERVE_EDITION_PATH" "" "" localhost 8080
else else
if [ -z "$5" ]; then if [ -z "$5" ]; then
PORT=8080 PORT=8080
@ -115,10 +115,10 @@ else
fi fi
# If the 1st parameter (edition) is set, it has priority. # If the 1st parameter (edition) is set, it has priority.
TIDDLYWIKI_EDITION_PATH=$1 TW_SERVE_EDITION_PATH=$1
# directory must exist # directory must exist
check_edition_directory check_edition_directory
serve "$TIDDLYWIKI_EDITION_PATH" "$2" "$3" "$4" $PORT serve "$TW_SERVE_EDITION_PATH" "$2" "$3" "$4" $PORT
fi fi