Skip to content

Commit

Permalink
Upstream Sandstorm support
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdtrekkie committed Oct 25, 2023
1 parent 3cefbaa commit aae2e24
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 3 deletions.
1 change: 1 addition & 0 deletions .sandstorm/launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .sandstorm/sandstorm-pkgdef.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
108 changes: 107 additions & 1 deletion client-data/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,114 @@
<!DOCTYPE html>
<html lang="{{language}}">
<head>
<meta http-equiv="refresh" content="0; url=boards/board" />
<meta charset="utf-8" />
<title>WBO — {{translations.collaborative_whiteboard}}</title>
<link rel="stylesheet" href="index.css" />
<meta name="description" content="{{translations.tagline}}" />
<meta
name="keywords"
content="whiteboard,collaborative,online,draw,paint,shared,realtime,wbo,whitebophir,open-source,GPL,javascript"
/>
<link rel="icon" type="image/x-icon" sizes="16x16" href="favicon.ico" />
<link rel="apple-touch-icon" href="favicon.svg" />
<link rel="mask-icon" href="favicon.svg" color="black" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta property="og:url" content="https://wbo.ophir.dev" />
<meta property="og:image" content="{{baseUrl}}/favicon.svg" />
<link rel="canonical" href="?lang={{language}}" />
{{#languages}}
<link rel="alternate" hreflang="{{.}}" href="?lang={{.}}" />
{{/languages}}
<link rel="manifest" href="manifest.json" />
<meta name="theme-color" content="#C4DFFF" />
</head>

<body>
<header>
<h1>WBO</h1>
<nav class="lang-selector">
<span>{{language}}</span>
<ul>
{{#languages}}
<li>
<a href="?lang={{.}}" hreflang="{{.}}" rel="alternate">{{.}}</a>
</li>
{{/languages}}
</ul>
</nav>
</header>

<main>
<div id="description">
<img
src="frontpage-illustration.svg"
alt="Public board illustration"
with="700"
height="560"
/>
<div class="text">
<h3>{{translations.index_title}}</h3>
<p>{{{translations.introduction_paragraph}}}</p>
<p>{{{translations.share_instructions}}}</p>
</div>
</div>

<div id="actions">
<div>
<p>{{{translations.public_board_description}}}</p>
<a href="boards/anonymous" class="wbo-button"
>{{{translations.open_public_board}}}</a
>
</div>

<div>
<p>{{{translations.private_board_description}}}</p>
<a href="random" class="wbo-button"
>{{{translations.create_private_board}}}</a
>
</div>

<div>
<p>
<label for="board"
>{{{translations.named_private_board_description}}}</label
>
</p>
<form id="named-board-form" action="boards" method="GET">
<input
type="text"
id="board"
name="board"
required
placeholder="{{{translations.board_name_placeholder}}}"
/>
<input type="submit" value="Go" />
</form>
</div>

<div id="recent-boards" class="hidden">
<h3>{{{translations.recent_boards}}}</h3>
</div>

<footer>
<a
href="https://www.instagram.com/wbo_whiteboard/"
class="smallink"
rel="external"
title="Instagram"
><img alt="instagram" src="instagram.svg" width="30" height="30"
/></a>
<a
href="https://github.com/lovasoa/whitebophir"
class="smallink"
rel="external"
title="{{translations.view_source}}"
><img alt="github" src="github.svg" width="30" height="30" />
</a>
</footer>
</div>
</main>
</body>

<script src="../js/index.js" async defer></script>
</html>
7 changes: 6 additions & 1 deletion server/check_output_directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, "{}");
Expand Down
3 changes: 3 additions & 0 deletions server/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),

};
4 changes: 4 additions & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit aae2e24

Please sign in to comment.