git clone https://garage44.eu/jeroen/midas.gitcartopolis-agent · 2026-11-28T19:26:24Z
feat(codeview): the public pages in dark when the hub's page was set to dark They followed only the device's own setting: a person who chose dark on the hub's page, on a phone set to light, got them light. One inline script reads the same m-theme the hub page's index.html does.
src/codeview.rs | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/codeview.rs b/src/codeview.rs
index 619dbcb..8cb5dc0 100644
--- a/src/codeview.rs
+++ b/src/codeview.rs
@@ -1,7 +1,7 @@
//! The pages a public hosted repository is read by, at `/<owner>/<name>/…`
//! (hub.rs `public_git`), the paths Forgejo had, so a link to the old forge
//! still lands: files, the README, the log and one commit. Plain HTML from the
-//! server, with no script and no login, so a reader and a search engine see the
+//! server, with no login and no script but the theme's, so a reader and a search engine see the
//! same thing. Private repositories never reach here. `/git/<owner>/<name>/…`,
//! where they were first, is sent here.
//!
@@ -178,11 +178,14 @@ const STYLE: &str = "body{font-size:16px;line-height:1.55}\
.md th{background:var(--m-surface-sunken);text-align:left}";
/// The page around a body: the hub's stylesheet and logo, and a header that
-/// starts with the site's name.
+/// starts with the site's name. Light or dark follows the device, or the
+/// choice made on the hub's page (its `m-theme`, as web/src/index.html reads
+/// it): the one script, and the page reads the same without it.
fn page_html(title: &str, host: &str, crumbs: &str, rest: &str, body: &str) -> String {
format!(
"<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\
- <title>{title}</title><link rel=\"icon\" href=\"/icon.svg\" type=\"image/svg+xml\"><link rel=\"stylesheet\" href=\"/app.css\">\
+ <title>{title}</title><script>try{{const t=localStorage.getItem('m-theme');if(t==='light'||t==='dark')document.documentElement.dataset.theme=t}}catch{{}}</script>\
+ <link rel=\"icon\" href=\"/icon.svg\" type=\"image/svg+xml\"><link rel=\"stylesheet\" href=\"/app.css\">\
<style>{STYLE}</style></head><body><div class=\"pub\"><header class=\"pub-head\">\
<h1><img src=\"/icon.svg\" alt=\"\"><a href=\"/\">{h}</a>{crumbs}</h1>{rest}</header>{body}</div></body></html>",
h = esc(host),