From 4ccf8099a545a7b3f25948bc11eeac9f1b610bfb Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Fri, 30 Oct 2026 15:33:26 +0300 Subject: [PATCH] Web version on the site: /app/ from website/static/app, precompressed Brotli/gzip The site serves precompressed copies next to its files (the program is 19 MB, 6.3 MB in Brotli); the built program goes to website/static/app (ignored by git, taken into the image); the device page's screenshots by the site's own paths. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 3 +++ apps/web/check/serve.py | 2 +- apps/web/page/page.js | 2 +- website/server/src/main.rs | 9 ++++++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d878c7d..07b902c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ # A local run of the website from the repository root (website/README.md runs it from server/). /data-dev/ + +# The web version built for the site (apps/web/build.sh website/static/app) +website/static/app/ diff --git a/apps/web/check/serve.py b/apps/web/check/serve.py index b545637..122b287 100644 --- a/apps/web/check/serve.py +++ b/apps/web/check/serve.py @@ -23,7 +23,7 @@ class Handler(http.server.SimpleHTTPRequestHandler): def translate_path(self, path): path = path.split("?", 1)[0].split("#", 1)[0] - for prefix, base in (("/app/", APP), ("/static/", STATIC)): + for prefix, base in (("/app/", APP), ("/static/", STATIC), ("/screenshots/", STATIC / "screenshots")): if path.startswith(prefix): target = (base / path[len(prefix):]).resolve() if target == base or base in target.parents: diff --git a/apps/web/page/page.js b/apps/web/page/page.js index cbaa9f1..142f0c3 100644 --- a/apps/web/page/page.js +++ b/apps/web/page/page.js @@ -92,7 +92,7 @@ function shots(names) { return el("div", { class: "shots" }, names.map(function (n) { - return el("img", { src: "../static/screenshots/" + n, alt: "", loading: "lazy" }); + return el("img", { src: "/screenshots/" + n, alt: "", loading: "lazy" }); })); } diff --git a/website/server/src/main.rs b/website/server/src/main.rs index 2cc78c2..01e6cd3 100644 --- a/website/server/src/main.rs +++ b/website/server/src/main.rs @@ -304,7 +304,14 @@ async fn main() { .route("/stats", get(stats)) .route("/stats.csv", get(stats_csv)) .route("/healthz", get(|| async { "ok" })) - .fallback_service(ServeDir::new(static_dir).fallback(get(not_found))) + .fallback_service( + // Precompressed copies (`.br`, `.gz`) next to a file go to the browsers that + // take them: the web version's program (/app/) is 23 MB, 6 MB in Brotli. + ServeDir::new(static_dir) + .precompressed_br() + .precompressed_gzip() + .fallback(get(not_found)), + ) .with_state(state); let listener = tokio::net::TcpListener::bind(("0.0.0.0", port)) .await