Rename, ejs, homepage, build errors, css

This commit is contained in:
Radon Rosborough 2020-06-09 14:39:45 -06:00
parent 846caf2ad8
commit f9e183e58e
11 changed files with 121 additions and 27 deletions

View File

@ -10,5 +10,5 @@ help: ## Show this message
.PHONY: docker
docker: ## Run shell with source code and deps inside Docker
scripts/docker.bash build . -t fast-sandbox --build-arg "UID=$(UID)"
scripts/docker.bash run -it --rm -v "$(PWD):/home/docker/src" -p 6119:6119 fast-sandbox
scripts/docker.bash build . -t riju --build-arg "UID=$(UID)"
scripts/docker.bash run -it --rm -v "$(PWD):/home/docker/src" -p 6119:6119 riju

View File

@ -78,7 +78,7 @@ export class Session {
}
};
run = async () => {
const { repl, main, suffix, compile, run, hacks } = this.config;
const { name, repl, main, suffix, compile, run, hacks } = this.config;
if (this.term.pty) {
this.term.pty.kill();
this.term.live = false;
@ -119,12 +119,12 @@ export class Session {
);
cmdline = run;
if (compile) {
cmdline = compile + " && " + run;
cmdline = `( ${compile} ) && ( ${run} )`;
}
} else if (repl) {
cmdline = repl;
} else {
return;
cmdline = `echo '${name} has no REPL, press Run to see it in action'`;
}
if (hacks && hacks.includes("ghci-config") && run) {
if (this.code) {

View File

@ -14,6 +14,7 @@ const host = process.env.HOST || "localhost";
const port = parseInt(process.env.PORT) || 6119;
app.set("query parser", (qs: string) => new URLSearchParams(qs));
app.set("view engine", "ejs");
function getQueryParams(req: Request): URLSearchParams {
// This is safe because we set the query parser for Express to
@ -23,11 +24,13 @@ function getQueryParams(req: Request): URLSearchParams {
app.use(sslRedirect());
app.get("/", (_, res) => {
res.sendFile(appRoot.path + "/frontend/pages/index.html");
res.render(appRoot.path + "/frontend/pages/index", { langs });
});
app.get("/:lang", (req, res) => {
if (langs[req.params.lang]) {
res.sendFile(appRoot.path + "/frontend/pages/app.html");
res.render(appRoot.path + "/frontend/pages/app", {
name: langs[req.params.lang].name,
});
} else {
res.send(`No such language: ${req.params.lang}`);
}

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Fast Sandbox</title>
<title><%= name %> - Riju</title>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
@ -17,6 +17,7 @@
<div id="editor" class="column"></div>
<div id="terminal" class="column"></div>
<button type="button" class="btn btn-success" id="runButton">Run</button>
<a href="/" class="btn btn-secondary" id="backButton">Switch to a different language</a>
</div>
</body>
</html>

29
frontend/pages/index.ejs Normal file
View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Riju</title>
<link rel="stylesheet" href="/css/index.css" />
</head>
<body>
<h1>Riju: online access to any programming language</h1>
<i>Select a language to get started immediately:</i>
<div class="grid">
<% for (const [id, {name}] of Object.entries(langs)) { %>
<a href=<%= "/" + encodeURIComponent(id) %> class="language">
<div class="language">
<%= name %>
</div>
</a>
<% } %>
</div>
<p>
<i>
Created by
<a href="https://github.com/raxod502">Radon Rosborough</a>.
Check out the project
<a href="https://github.com/raxod502/riju">on GitHub</a>.
</i>
</p>
</body>
</html>

View File

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Fast Sandbox</title>
</head>
<body>
Hello, world!
</body>
</html>

View File

@ -26,3 +26,9 @@ body {
top: 25px;
right: calc(50% + 25px);
}
#backButton {
position: absolute;
left: 25px;
bottom: 25px;
}

33
frontend/styles/index.css Normal file
View File

@ -0,0 +1,33 @@
body {
display: flex;
flex-direction: column;
align-items: center;
font-family: sans-serif;
text-align: center;
padding-bottom: 20px;
}
.grid {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin-top: 20px;
}
div.language {
width: 120px;
height: 60px;
border: solid;
margin: 5px;
padding: 5px;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
font-size: 18px;
}
a.language {
text-decoration: none;
color: black;
}

View File

@ -1,5 +1,5 @@
{
"name": "fast-sandbox",
"name": "riju",
"version": "0",
"license": "MIT",
"private": true,
@ -10,6 +10,7 @@
"@types/tmp": "^0.2.0",
"app-root-path": "^3.0.0",
"css-loader": "^3.5.3",
"ejs": "^3.1.3",
"express": "^4.17.1",
"express-ws": "^4.0.0",
"file-loader": "^6.0.0",

View File

@ -73,7 +73,7 @@ algol68g
# ARM
gcc-arm-linux-gnueabihf
qemu-system-static
qemu-user-static
# ATS
ats2-lang
@ -170,7 +170,7 @@ lua5.3
# MIPS
gcc-mips64-linux-gnuabi64
qemu-system-static
qemu-user-static
# MUMPS
fis-gtm
@ -215,7 +215,7 @@ racket
# RISC-V
gcc-riscv64-linux-gnu
qemu-system-static
qemu-user-static
# Ruby
ruby
@ -309,7 +309,7 @@ npm install -g ts-node typescript
pip3 install whitespace
# Wolfram Language
python3.7 -m pip install install mathics
python3.7 -m pip install mathics
# Needed for project infrastructure
cd /tmp
@ -320,6 +320,8 @@ rm watchexec-*.deb
# D
cd /tmp
wget -nv http://downloads.dlang.org/releases/2.x/2.092.0/dmd_2.092.0-0_amd64.deb
dpkg -i dmd_*.deb
rm dmd_*.deb
# Elm
cd /tmp
@ -327,7 +329,6 @@ wget -nv https://github.com/elm/compiler/releases/download/0.19.1/binary-for-lin
gunzip binary-for-linux-64-bit.gz
chmod +x binary-for-linux-64-bit
mv binary-for-linux-64-bit /usr/bin/elm
rm binary-for-linux-64-bit.gz
# Ink
cd /tmp
@ -353,15 +354,16 @@ wget -nv https://github.com/PowerShell/PowerShell/releases/download/v7.0.1/power
mkdir /opt/powershell
tar -xf powershell-*.tar.gz -C /opt/powershell
ln -s /opt/powershell/pwsh /usr/bin/pwsh
rm powershell-*.tar.gz
# SNOBOL
wget -nv ftp://ftp.snobol4.org/snobol/snobol4-2.0.tar.gz
tar -xf snobol4-*.tar.gz
rm snobol4-*.tar.gz
pushd snobol4-*
pushd snobol4-* >/dev/null
make || true
mv snobol4 /usr/bin/snobol4
popd
popd >/dev/null
rm -rf snobol4-*
# Swift
@ -380,7 +382,7 @@ stack build kalyn
mv "$(stack exec which kalyn)" /usr/bin/kalyn
mkdir /opt/kalyn
cp -R src-kalyn/Stdlib src-kalyn/Stdlib.kalyn /opt/kalyn/
popd
popd >/dev/null
rm -rf kalyn
# LOLCODE

View File

@ -378,6 +378,11 @@ async-limiter@~1.0.0:
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd"
integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==
async@0.9.x:
version "0.9.2"
resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d"
integrity sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=
atob@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
@ -991,6 +996,13 @@ ee-first@1.1.1:
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
ejs@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.3.tgz#514d967a8894084d18d3d47bd169a1c0560f093d"
integrity sha512-wmtrUGyfSC23GC/B1SMv2ogAUgbQEtDmTIhfqielrG5ExIM9TP4UoYdi90jLF1aTcsWCJNEO0UrgKzP0y3nTSg==
dependencies:
jake "^10.6.1"
elliptic@^6.0.0, elliptic@^6.5.2:
version "6.5.2"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.2.tgz#05c5678d7173c049d8ca433552224a495d0e3762"
@ -1237,6 +1249,13 @@ file-uri-to-path@1.0.0:
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==
filelist@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.1.tgz#f10d1a3ae86c1694808e8f20906f43d4c9132dbb"
integrity sha512-8zSK6Nu0DQIC08mUC46sWGXi+q3GGpKydAG36k+JDba6VRpkevvOWUW5a/PhShij4+vHT9M+ghgG7eM+a9JDUQ==
dependencies:
minimatch "^3.0.4"
fill-range@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7"
@ -1792,6 +1811,16 @@ isobject@^3.0.0, isobject@^3.0.1:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
jake@^10.6.1:
version "10.8.2"
resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.2.tgz#ebc9de8558160a66d82d0eadc6a2e58fbc500a7b"
integrity sha512-eLpKyrfG3mzvGE2Du8VoPbeSkRry093+tyNjdYaBbJS9v17knImYGNXQCUV0gLxQtF82m3E8iRb/wdSQZLoq7A==
dependencies:
async "0.9.x"
chalk "^2.4.2"
filelist "^1.0.1"
minimatch "^3.0.4"
json-parse-better-errors@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"