๐Ÿ“๐Ÿ–ผ๏ธ๐Ÿน A small thing where I can upload a file and get a link back. https://media.strawmelonjuice.com/
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Let the client show versions.


Signed-off-by: MLC Bloeiman <mar@strawmelonjuice.com>

+61 -6
+3
.envrc
··· 1 + if nix flake show &> /dev/null; then 2 + use flake 3 + fi
+4
.gitignore
··· 2 2 node_modules 3 3 prelude.d.ts 4 4 prelude.mjs 5 + dashboard/src/prelude.mjs 5 6 6 7 # output 7 8 out ··· 65 66 # and can be added to the global gitignore or merged into this file. For a more nuclear 66 67 # option (not recommended) you can uncomment the following to ignore the entire idea folder. 67 68 #.idea/ 69 + 70 + # Ignore direnv cache 71 + .direnv/
+1 -1
Justfile
··· 30 30 # HTML Assembly 31 31 printf '<!DOCTYPE html><html><head><title>Strawmediajuice dashboard</title><style>' > ./dist/dashboard/dashboard.html 32 32 cat ./dist/dashboard/dashboard.min.css >> ./dist/dashboard/dashboard.html 33 - printf '</style><script>' >> ./dist/dashboard/dashboard.html 33 + printf '</style><script>const internalServerVersion = "old";\n\n' >> ./dist/dashboard/dashboard.html 34 34 cat ./dist/dashboard/dashboard.min.mjs >> ./dist/dashboard/dashboard.html 35 35 printf '</script></head><body><div id="app"><h1>Dashboard failed to load!</h1></div></body></html>' >> ./dist/dashboard/dashboard.html 36 36
+1 -1
dashboard/gleam.toml
··· 1 1 name = "strawmediajuice_fe" 2 - version = "1.0.0" 2 + version = "1.0.1-dev" 3 3 description = "Dashboard for my file upload server" 4 4 target = "javascript" 5 5
+14
dashboard/src/ffi.ts
··· 1 1 // noinspection JSUnusedGlobalSymbols: JetBrains IDEs do not detect FFI imports from Gleam code. 2 2 import { Result$Error } from "./prelude"; 3 + // Path's all the way out of the build folder. 4 + import appManifest from "../../../../gleam.toml"; 5 + 6 + export function app_version(): string { 7 + return appManifest.version 8 + } 9 + export function srv_version(): string { 10 + //@ts-ignore 11 + let v: string = internalServerVersion; 12 + if (v == "old") { 13 + return "Old TS version (version undocumented)" 14 + } 15 + return v; 16 + } 3 17 4 18 export async function get_uploaded_file() { 5 19 const fileInput = document.getElementById(
+34
dashboard/src/strawmediajuice_fe.gleam
··· 1306 1306 Some(_) -> view_home(model) 1307 1307 None -> view_login_form(model) 1308 1308 }, 1309 + footer() 1309 1310 ]) 1311 + } 1312 + 1313 + @external(javascript,"./ffi", "srv_version") 1314 + fn server_version() -> String 1315 + 1316 + @external(javascript,"./ffi", "app_version") 1317 + fn client_version() -> String 1318 + 1319 + fn footer() -> Element(Msg) { 1320 + html.footer( 1321 + [ 1322 + attribute.class("footer sm:footer-horizontal bg-neutral text-neutral-content items-center p-4"), 1323 + ], 1324 + [ 1325 + html.aside( 1326 + [attribute.class("grid-flow-col items-center")], 1327 + [ 1328 + html.p( 1329 + [], 1330 + [ 1331 + html.text("Client: " <> client_version() <> "; Server: " <> server_version()<>";"), 1332 + ], 1333 + ), 1334 + ], 1335 + ), 1336 + html.nav( 1337 + [ 1338 + attribute.class("grid-flow-col gap-4 md:place-self-center md:justify-self-end"), 1339 + ], 1340 + [], 1341 + ), 1342 + ], 1343 + ) 1310 1344 } 1311 1345 1312 1346 /// Gets uploaded filename
+1 -1
server-rs/Cargo.lock
··· 1461 1461 1462 1462 [[package]] 1463 1463 name = "strawmediajuice-server" 1464 - version = "0.1.0" 1464 + version = "0.1.0-rs-dev" 1465 1465 dependencies = [ 1466 1466 "anyhow", 1467 1467 "base64",
+1 -1
server-rs/Cargo.toml
··· 1 1 [package] 2 2 name = "strawmediajuice-server" 3 - version = "0.1.0" 3 + version = "0.1.0-rs-dev" 4 4 edition = "2024" 5 5 6 6 [dependencies]
+2 -2
server-rs/src/routes.rs
··· 4 4 use rocket::{State, http::Status, response::content::RawHtml}; 5 5 6 6 #[get("/")] 7 - pub(super) fn index() -> RawHtml<&'static str> { 8 - RawHtml(include_str!("../../dist/dashboard/dashboard.html")) 7 + pub(super) fn index() -> RawHtml<String> { 8 + RawHtml(include_str!("../../dist/dashboard/dashboard.html").replace("internalServerVersion = \"old\"", format!("internalServerVersion = \"{0}\"", env!("CARGO_PKG_VERSION")).as_str()).clone()) 9 9 } 10 10 11 11 #[get("/file/<id..>")]