From aae2e2409531f09979028c9091414784bcabaead Mon Sep 17 00:00:00 2001 From: Jacob Weisz Date: Wed, 25 Oct 2023 18:24:45 -0500 Subject: [PATCH] Upstream Sandstorm support --- .sandstorm/launcher.sh | 1 + .sandstorm/sandstorm-pkgdef.capnp | 2 +- client-data/index.html | 108 +++++++++++++++++++++++++++++- server/check_output_directory.js | 7 +- server/configuration.js | 3 + server/server.js | 4 ++ 6 files changed, 122 insertions(+), 3 deletions(-) diff --git a/.sandstorm/launcher.sh b/.sandstorm/launcher.sh index 2bd01c8c..31c9c3b0 100755 --- a/.sandstorm/launcher.sh +++ b/.sandstorm/launcher.sh @@ -36,5 +36,6 @@ export HOME=/opt/app export PORT=8000 export HOST=127.0.0.1 export WBO_HISTORY_DIR=/var/wbo_data/ +export WBO_DEFAULT_BOARD=board npm start diff --git a/.sandstorm/sandstorm-pkgdef.capnp b/.sandstorm/sandstorm-pkgdef.capnp index 9765cc7e..892f54c7 100644 --- a/.sandstorm/sandstorm-pkgdef.capnp +++ b/.sandstorm/sandstorm-pkgdef.capnp @@ -21,7 +21,7 @@ const pkgdef :Spk.PackageDefinition = ( appVersion = 0, # Increment this for every release. - appMarketingVersion = (defaultText = "0.0.1"), + appMarketingVersion = (defaultText = "1.19.2"), # Human-readable representation of appVersion. Should match the way you # identify versions of your app in documentation and marketing. diff --git a/client-data/index.html b/client-data/index.html index 088359cf..09dde0a2 100644 --- a/client-data/index.html +++ b/client-data/index.html @@ -1,8 +1,114 @@ - + + WBO — {{translations.collaborative_whiteboard}} + + + + + + + + + + + {{#languages}} + + {{/languages}} + + + +
+

WBO

+ +
+ +
+
+ Public board illustration +
+

{{translations.index_title}}

+

{{{translations.introduction_paragraph}}}

+

{{{translations.share_instructions}}}

+
+
+ +
+
+

{{{translations.public_board_description}}}

+ {{{translations.open_public_board}}} +
+ +
+

{{{translations.private_board_description}}}

+ {{{translations.create_private_board}}} +
+ +
+

+ +

+
+ + +
+
+ + + + +
+
+ + diff --git a/server/check_output_directory.js b/server/check_output_directory.js index bd8cd021..b80a2ed9 100644 --- a/server/check_output_directory.js +++ b/server/check_output_directory.js @@ -16,7 +16,12 @@ async function get_error(directory) { if (!fs.statSync(directory).isDirectory()) { error = "exists, but is not a directory"; } - const { uid, gid } = []; //SANDSTORM HACK + try { + const { uid, gid } = os.userInfo(); + } catch (e) { + console.error(`os.userInfo does not work in this environment.`); + const { uid, gid } = []; + } const tmpfile = path.join(directory, Math.random() + ".json"); try { fs.writeFileSync(tmpfile, "{}"); diff --git a/server/configuration.js b/server/configuration.js index 85820105..508beebf 100644 --- a/server/configuration.js +++ b/server/configuration.js @@ -57,5 +57,8 @@ module.exports = { /** Secret key for jwt */ AUTH_SECRET_KEY: (process.env["AUTH_SECRET_KEY"] || ""), + + /** If this variable is set, automatically redirect to this board. */ + DEFAULT_BOARD: (process.env["WBO_DEFAULT_BOARD"]), }; diff --git a/server/server.js b/server/server.js index 4e7ea716..adf2c0dc 100644 --- a/server/server.js +++ b/server/server.js @@ -223,7 +223,11 @@ function handleRequest(request, response) { case "": // Index page logRequest(request); + if (!config.DEFAULT_BOARD) indexTemplate.serve(request, response); + else + response.writeHead(302, { Location: 'boards/' + config.DEFAULT_BOARD }); + response.end(name); break; default: