diff --git a/Makefile b/Makefile index 0a1a32d..ca6c03f 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/backend/src/api.ts b/backend/src/api.ts index 8188d63..e917c4b 100644 --- a/backend/src/api.ts +++ b/backend/src/api.ts @@ -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) { diff --git a/backend/src/server.ts b/backend/src/server.ts index 8abea8f..8f31a62 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -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}`); } diff --git a/frontend/pages/app.html b/frontend/pages/app.ejs similarity index 83% rename from frontend/pages/app.html rename to frontend/pages/app.ejs index 12ccfd3..4b7849d 100644 --- a/frontend/pages/app.html +++ b/frontend/pages/app.ejs @@ -2,7 +2,7 @@ - Fast Sandbox + <%= name %> - Riju
+ Switch to a different language diff --git a/frontend/pages/index.ejs b/frontend/pages/index.ejs new file mode 100644 index 0000000..fd5ba8e --- /dev/null +++ b/frontend/pages/index.ejs @@ -0,0 +1,29 @@ + + + + + Riju + + + +

Riju: online access to any programming language

+ Select a language to get started immediately: +
+ <% for (const [id, {name}] of Object.entries(langs)) { %> + class="language"> +
+ <%= name %> +
+
+ <% } %> +
+

+ + Created by + Radon Rosborough. + Check out the project + on GitHub. + +

+ + diff --git a/frontend/pages/index.html b/frontend/pages/index.html deleted file mode 100644 index c0008f1..0000000 --- a/frontend/pages/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Fast Sandbox - - - Hello, world! - - diff --git a/frontend/styles/app.css b/frontend/styles/app.css index 5b320be..6adf8e0 100644 --- a/frontend/styles/app.css +++ b/frontend/styles/app.css @@ -26,3 +26,9 @@ body { top: 25px; right: calc(50% + 25px); } + +#backButton { + position: absolute; + left: 25px; + bottom: 25px; +} diff --git a/frontend/styles/index.css b/frontend/styles/index.css new file mode 100644 index 0000000..0b2d9a1 --- /dev/null +++ b/frontend/styles/index.css @@ -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; +} diff --git a/package.json b/package.json index 6999c00..ffe5304 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/docker-install.bash b/scripts/docker-install.bash index b109650..96cbbb2 100755 --- a/scripts/docker-install.bash +++ b/scripts/docker-install.bash @@ -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 diff --git a/yarn.lock b/yarn.lock index ecb6c2b..727f04b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"