git clone https://garage44.eu/jeroen/midas.gitcartopolis-agent · 2026-11-28T16:40:06Z
style(codeview): the public pages in the hub's own look, readable on a phone The front page and a public repository's pages had a stylesheet of their own (system font, blue links, a three-column table), so garage44.eu looked like another site than the hub behind its log-in, and on a phone the table squeezed each description into a strip a few words wide. They now link the hub page's /app.css (its palette, font, light and dark) and its logo, and lay out on top of it: the front page lists the projects as cards that wrap to one column on a phone, log in is the accent button, and the log stacks its rows under 40rem.
src/codeview.rs | 79 +++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 54 insertions(+), 25 deletions(-)
diff --git a/src/codeview.rs b/src/codeview.rs
index b3bd0b8..3ca8e44 100644
--- a/src/codeview.rs
+++ b/src/codeview.rs
@@ -38,22 +38,53 @@ fn link(s: &str) -> String {
crate::hub::pct_encode(s).replace("%2F", "/")
}
-const STYLE: &str = "body{font:15px/1.5 system-ui,sans-serif;margin:0 auto;max-width:60rem;padding:1rem;color:#222}\
- a{color:#1a5fb4;text-decoration:none}a:hover{text-decoration:underline}\
- header{display:flex;gap:1rem;align-items:baseline;flex-wrap:wrap;border-bottom:1px solid #ddd;margin-bottom:1rem}\
- header h1{font-size:1.2rem;margin:.4rem 0}pre{background:#f6f6f6;padding:.8rem;overflow:auto;font-size:13px}\
- table{border-collapse:collapse;width:100%}td{padding:.2rem .5rem;border-bottom:1px solid #eee}\
- code{background:#f6f6f6;padding:0 .3rem;white-space:nowrap}header code{white-space:normal;overflow-wrap:anywhere}.muted{color:#777}td.muted{white-space:nowrap}\
- header .end{margin-left:auto}figure.map{margin:1rem 0}figure.map svg{width:100%;height:auto;max-height:70vh}h2{font-size:1rem;margin:1.2rem 0 .4rem}";
+/// The hub page's own stylesheet (`/app.css`: its palette, font and light and
+/// dark), and on top only what these pages lay out. A phone reads the front
+/// page as cards and the log as stacked rows: a three-column table squeezed a
+/// description into a strip a few words wide.
+const STYLE: &str = "body{font-size:16px;line-height:1.55}\
+ .pub{max-width:60rem;margin:0 auto;padding:16px}\
+ a{color:var(--m-accent-text);text-decoration:none}a:hover{text-decoration:underline}\
+ .pub-head{display:flex;gap:8px 16px;align-items:center;flex-wrap:wrap;padding-bottom:12px;margin-bottom:16px;border-bottom:1px solid var(--m-border)}\
+ .pub-head h1{display:flex;align-items:center;flex-wrap:wrap;gap:.4em;margin:0;font-size:1.3rem;color:var(--m-text-strong)}\
+ .pub-head h1 a{color:inherit}.pub-head h1 img{width:1.35em;height:1.35em}.pub-head h1 span{color:var(--m-text-dim);font-weight:400}\
+ .pub-head .end{margin-left:auto}.pub-head .clone{flex-basis:100%;font-size:14px}\
+ .pub-in{padding:6px 16px;border-radius:var(--m-radius);background:var(--m-accent);color:var(--m-on-accent);font-weight:600}\
+ .pub-in:hover{background:var(--m-accent-hover);text-decoration:none}\
+ .pub-list{display:grid;gap:12px;grid-template-columns:repeat(auto-fill,minmax(min(100%,17rem),1fr))}\
+ .pub-card{display:flex;flex-direction:column;gap:6px;padding:14px 16px;background:var(--m-surface);color:var(--m-text);\
+ border:1px solid var(--m-border);border-radius:var(--m-radius-lg);box-shadow:var(--lift-1)}\
+ .pub-card:hover{border-color:var(--m-accent);text-decoration:none}\
+ .pub-card strong{color:var(--m-accent-text);font-size:1.05rem}.pub-card time{margin-top:auto;color:var(--m-text-faint);font-size:13px}\
+ pre{background:var(--m-surface-sunken);border:1px solid var(--m-border);border-radius:var(--m-radius);padding:12px;overflow:auto;font-size:13px}\
+ code{background:var(--m-surface-sunken);border-radius:var(--m-radius-sm);padding:0 .3rem;white-space:nowrap}.clone code{white-space:normal;overflow-wrap:anywhere}\
+ table{border-collapse:separate;border-spacing:0;width:100%;background:var(--m-surface);border:1px solid var(--m-border);border-radius:var(--m-radius-lg);overflow:hidden}\
+ td{padding:8px 12px;border-bottom:1px solid var(--m-border);vertical-align:top}tr:last-child td{border-bottom:0}\
+ .muted{color:var(--m-text-dim)}td.muted{white-space:nowrap}h2{font-size:1.1rem;margin:24px 0 8px}\
+ @media (max-width:40rem){.pub{padding:12px}table.log tr{display:block;padding:8px 12px;border-bottom:1px solid var(--m-border)}\
+ table.log tr:last-child{border-bottom:0}table.log td{display:block;padding:1px 0;border:0}table.log td.muted{font-size:13px}}\
+ figure.map{margin:0 0 16px}figure.map svg{width:100%;height:auto;max-height:70vh;background:var(--m-surface);border:1px solid var(--m-border);border-radius:var(--m-radius-lg)}figcaption{font-size:13px;margin-top:4px}";
-fn frame(repo: &str, host: &str, title: &str, body: &str) -> String {
- let key = repo.trim_end_matches(".git");
+/// The page around a body: the hub's stylesheet and logo, and a header that
+/// starts with the site's name.
+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>{t} · {k}</title><style>{STYLE}</style></head><body><header><h1><a href=\"/\">{h}</a> / <a href=\"/{k}\">{k}</a></h1>\
- <a href=\"/{k}/log\">log</a><span class=\"muted\">clone: <code>git clone https://{h}/{k}.git</code></span></header>\
- {body}</body></html>",
- t = esc(title), k = esc(key), h = esc(host), body = body,
+ <title>{title}</title><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),
+ )
+}
+
+fn frame(repo: &str, host: &str, title: &str, body: &str) -> String {
+ let key = repo.trim_end_matches(".git");
+ let (k, h) = (esc(key), esc(host));
+ page_html(
+ &format!("{} · {k}", esc(title)), host,
+ &format!("<span>/</span><a href=\"/{k}\">{k}</a>"),
+ &format!("<a class=\"end\" href=\"/{k}/log\">log</a><span class=\"clone muted\">clone: <code>git clone https://{h}/{k}.git</code></span>"),
+ body,
)
}
@@ -69,23 +100,21 @@ pub fn front(host: &str) -> String {
})
.collect();
rows.sort_by(|a, b| b.2.cmp(&a.2).then(a.0.cmp(&b.0)));
- let mut body = "<table>".to_string();
+ let mut body = "<div class=\"pub-list\">".to_string();
for (k, d, at) in &rows {
- body += &format!("<tr><td><a href=\"/{k}\">{k}</a></td><td>{d}</td><td class=\"muted\">{at}</td></tr>",
- k = esc(k), d = esc(d), at = esc(at.get(..10).unwrap_or("")));
+ let (owner, name) = k.split_once('/').map(|(o, n)| (format!("{o}/"), n)).unwrap_or_default();
+ let day = at.get(..10).unwrap_or("");
+ body += &format!("<a class=\"pub-card\" href=\"/{k}\"><strong><span class=\"muted\">{o}</span>{n}</strong>{d}<time datetime=\"{day}\">{day}</time></a>",
+ k = esc(k), o = esc(&owner), n = esc(if name.is_empty() { k } else { name }), day = esc(day),
+ d = if d.is_empty() { String::new() } else { format!("<span>{}</span>", esc(d)) });
}
- body += "</table>";
+ body += "</div>";
if rows.is_empty() {
body = "<p class=\"muted\">No public projects yet.</p>".into();
} else {
body = map() + &body;
}
- format!(
- "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\
- <title>{h}</title><style>{STYLE}</style></head><body><header><h1><a href=\"/\">{h}</a></h1>\
- <span class=\"muted\">projects</span><a class=\"end\" href=\"/login\">log in</a></header>{body}</body></html>",
- h = esc(host),
- )
+ page_html(&esc(host), host, "", "<a class=\"end pub-in\" href=\"/login\">Log in</a>", &body)
}
/// The public projects as a map, and the techs built in them lately.
@@ -96,7 +125,7 @@ fn map() -> String {
crate::graph::svg(&g, Some("/")));
let landed = g["landed"].as_array().cloned().unwrap_or_default();
if !landed.is_empty() {
- s += "<h2>Built lately</h2><table>";
+ s += "<h2>Built lately</h2><table class=\"log\">";
for l in &landed {
let day = l["at"].as_i64().and_then(|t| chrono::DateTime::from_timestamp(t, 0)).map(|d| d.format("%Y-%m-%d").to_string()).unwrap_or_default();
let repo = l["repo"].as_str().unwrap_or("");
@@ -203,7 +232,7 @@ pub fn page(repo: &str, host: &str, tail: &str, q: &str) -> Result<Option<Page>>
return Ok(Some(Page::Html(frame(repo, host, &title, &body))));
}
if tail == "log" {
- let mut body = "<table>".to_string();
+ let mut body = "<table class=\"log\">".to_string();
for c in hosted::log(repo, rev.as_deref(), 50)? {
let sha = c["sha"].as_str().unwrap_or("");
body += &format!("<tr><td><a href=\"/{}/commit/{}\"><code>{}</code></a></td><td>{}</td><td class=\"muted\">{}</td></tr>",