Polish the repository index and its empty states
Browse files- Author
- Um9i vulgarmessiah@gmail.com
- Date
- 22 Nov 2026, 14:41
- Commit
- 37a78506c889
- Parent
- 0d0992e
4 files changed +98−40
+31−8
| @@ -112,13 +112,36 @@ a.entry:hover .name{color:var(--accent)} | ||
| color:var(--accent);background:var(--accent-wash)} | ||
| .sha:hover{text-decoration:none;box-shadow:inset 0 0 0 1px var(--accent)} | ||
| .repo-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:2px 20px;align-items:center;padding:14px 18px;color:var(--ink)} | ||
| .repo-row:hover{background:var(--sunk);text-decoration:none} | ||
| .repo-row:hover .rname{color:var(--accent)} | ||
| .rname{font:700 18px/1.3 var(--f-display);letter-spacing:-.01em;overflow-wrap:anywhere} | ||
| /* Repository index */ | ||
| .index-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:12px 0 24px} | ||
| .index-head .title{font-size:clamp(32px,5vw,44px);letter-spacing:-.035em} | ||
| .index-head .count,.index-columns,.rwhen,.ridentity small{font-size:14px;color:var(--ink-2)} | ||
| .index-columns,.repo-row{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,3fr) 8rem;gap:20px;align-items:center;padding:16px 20px} | ||
| .index-columns{padding-block:10px;background:var(--sunk);border-bottom:1px solid var(--rule);font-weight:600} | ||
| .index-columns span:last-child,.rwhen{text-align:right} | ||
| .repo-row{min-height:68px;color:var(--ink)} | ||
| .repo-row:is(:hover,:focus-visible,:active){background:var(--sunk);text-decoration:none} | ||
| .repo-row:focus-visible{outline-offset:-3px} | ||
| .repo-row:is(:hover,:focus-visible) .rname{color:var(--accent);text-decoration:underline} | ||
| .ridentity{display:grid;gap:2px} | ||
| .rname{font:700 19px/1.3 var(--f-display);overflow-wrap:anywhere} | ||
| .rname span{font-weight:400;color:var(--ink-2)} | ||
| .rlast{grid-column:1;font-size:14px;color:var(--ink-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} | ||
| .rwhen{grid-row:1 / span 2;grid-column:2;font-size:13px;color:var(--ink-2);white-space:nowrap} | ||
| .rlast{font-size:15px;line-height:1.4;overflow-wrap:anywhere} | ||
| .rwhen{font-variant-numeric:tabular-nums} | ||
| .index-empty{text-align:center;padding:clamp(40px,8vw,88px) 20px} | ||
| .index-mark{display:inline-grid;place-items:center;background:var(--accent-wash);color:var(--accent);width:60px;height:60px;border-radius:16px} | ||
| .index-mark .ic{width:36px;height:36px} | ||
| .index-empty h2{font:700 clamp(22px,4vw,28px)/1.25 var(--f-display);margin:18px 0} | ||
| .index-empty p{color:var(--ink-2)} | ||
| .index-empty code{overflow-wrap:anywhere} | ||
| .index-empty .button{min-height:44px;white-space:normal} | ||
| @media(max-width:720px){ | ||
| .index-columns{display:none} | ||
| .index-list .repo-row{grid-template-columns:minmax(0,1fr);gap:5px;padding:16px} | ||
| .ridentity{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px} | ||
| .rwhen{text-align:left} | ||
| .rwhen:empty{display:none} | ||
| } | ||
| .commit-row{display:flex;align-items:center;gap:14px;min-height:58px;padding:10px 16px} | ||
| .commit-row .cmain{flex:1;min-width:0} | ||
| @@ -247,8 +270,8 @@ button.button{cursor:pointer} | ||
| .clone{flex-basis:100%} | ||
| .markdown{padding:4px 18px 18px} | ||
| .cmsg{padding:18px}.facts{padding:14px 18px;gap:12px 24px} | ||
| .repo-row,.tag-row{grid-template-columns:minmax(0,1fr)} | ||
| .rwhen,.tag-row .tacts{grid-row:auto;grid-column:1} | ||
| .tag-row{grid-template-columns:minmax(0,1fr)} | ||
| .tag-row .tacts{grid-row:auto;grid-column:1} | ||
| .panel-head .who{display:none} | ||
| } | ||
| @media (prefers-reduced-motion:no-preference){ | ||
+17−32
| @@ -836,6 +836,7 @@ fn refs_fingerprint(repo: &RepoDir) -> Option<String> { | ||
| /// One row of the index: everything it shows, and no open repository handle, so a large | ||
| /// installation holds one handle at a time however many repositories it lists. | ||
| struct Row { | ||
| public: bool, | ||
| owner: String, | ||
| name: String, | ||
| head: Option<Head>, | ||
| @@ -850,7 +851,8 @@ fn view_index(signed_in: bool) -> View { | ||
| for entry in sorted_names(&owner_dir) { | ||
| let Some(name) = entry.strip_suffix(".git") else { continue }; | ||
| let Some(dir) = repo_in(&owner_dir, &owner, name) else { continue }; | ||
| if !signed_in && !dir.is_public() { | ||
| let public = dir.is_public(); | ||
| if !signed_in && !public { | ||
| continue; | ||
| } | ||
| let repo = Repo::from_dir(&owner, name, dir); | ||
| @@ -869,42 +871,25 @@ fn view_index(signed_in: bool) -> View { | ||
| }; | ||
| let head = raw.as_deref().and_then(Head::parse); | ||
| // `repo`, and with it the directory handle, is dropped here. | ||
| rows.push(Row { owner: owner.clone(), name: name.to_string(), head }); | ||
| rows.push(Row { public, owner: owner.clone(), name: name.to_string(), head }); | ||
| } | ||
| } | ||
| rows.sort_by_key(|row| Reverse(row.head.as_ref().and_then(|h| h.stamp.parse::<u64>().ok()).unwrap_or(0))); | ||
| let items: String = rows | ||
| .iter() | ||
| .map(|Row { owner, name, head }| { | ||
| let (last, when) = head.as_ref().map_or(("No commits yet".into(), String::new()), |h| { | ||
| (esc(subject_or_placeholder(&h.subject)).into_owned(), ago(&h.stamp, &h.date)) | ||
| }); | ||
| format!( | ||
| r#"<li><a class="repo-row" href="{}"><span class="rname"><span>{}/</span>{}</span><span class="rlast">{last}</span><span class="rwhen">{when}</span></a></li>"#, | ||
| attr(&format!("/{owner}/{name}/tree")), | ||
| esc(owner), | ||
| esc(name) | ||
| ) | ||
| let count = plural(rows.len(), "repository", "repositories"); | ||
| let rows = rows | ||
| .into_iter() | ||
| .map(|row| { | ||
| let (subject, when) = row.head.map_or_else( | ||
| || ("No commits yet".into(), String::new()), | ||
| |h| (subject_or_placeholder(&h.subject).into(), ago(&h.stamp, &h.date)), | ||
| ); | ||
| templates::RepositoryRow { owner: row.owner, name: row.name, public: row.public, subject, when } | ||
| }) | ||
| .collect(); | ||
| let listing = if items.is_empty() && !signed_in { | ||
| r#"<div class="panel empty"><h2>No public repositories yet</h2></div>"#.to_owned() | ||
| } else if items.is_empty() { | ||
| format!( | ||
| r#"<div class="panel empty"><h2>No repositories yet</h2><p>Push to a new name and GITv creates the repository.</p> | ||
| <code>git push git@{HOST}:um9i/my-project.git main</code></div>"# | ||
| ) | ||
| } else { | ||
| format!(r#"<div class="panel"><ul class="rows">{items}</ul></div>"#) | ||
| }; | ||
| let count = plural(rows.len(), "repository", "repositories"); | ||
| View::Html(layout( | ||
| "Repositories", | ||
| &format!( | ||
| r#"<div class="pagehead"><h1 class="title">Repositories</h1><p class="count">{count}</p></div>{listing}"# | ||
| ), | ||
| signed_in, | ||
| )) | ||
| View::Html( | ||
| templates::Repositories { title: "Repositories", signed_in, count, rows, branch: icon("branch"), host: HOST } | ||
| .to_string(), | ||
| ) | ||
| } | ||
| fn view_tree(repo: &Repo, q: &Q) -> Option<View> { | ||
| @@ -65,3 +65,22 @@ pub(super) struct TreeRow<'a> { | ||
| pub short_id: &'a str, | ||
| pub commit: Option<EntryCommit>, | ||
| } | ||
| pub(super) struct RepositoryRow { | ||
| pub owner: String, | ||
| pub name: String, | ||
| pub public: bool, | ||
| pub subject: String, | ||
| pub when: String, | ||
| } | ||
| #[derive(Template)] | ||
| #[template(path = "repositories.html")] | ||
| pub(super) struct Repositories<'a> { | ||
| pub title: &'a str, | ||
| pub signed_in: bool, | ||
| pub count: String, | ||
| pub rows: Vec<RepositoryRow>, | ||
| pub branch: String, | ||
| pub host: &'a str, | ||
| } | ||
+31−0
| @@ -0,0 +1,31 @@ | ||
| {% extends "base.html" %} | ||
| {% block content %} | ||
| <header class="index-head"><h1 class="title">Repositories</h1>{% if !rows.is_empty() %}<p class="count">{{ count }}</p>{% endif %}</header> | ||
| {% if rows.is_empty() %} | ||
| <section class="panel index-empty"> | ||
| <div class="index-mark">{{ branch|safe }}</div> | ||
| {% if signed_in %} | ||
| <h2>No repositories yet</h2> | ||
| <p>Create your first repository by pushing a branch over SSH.</p> | ||
| <code>git push git@{{ host }}:um9i/my-project.git main</code> | ||
| {% else %} | ||
| <h2>No public repositories yet</h2> | ||
| <a class="button" href="/login">Sign in to view private repositories</a> | ||
| {% endif %} | ||
| </section> | ||
| {% else %} | ||
| <div class="panel index-list"> | ||
| <div class="index-columns" aria-hidden="true"><span>Repository</span><span>Latest commit</span><span>Updated</span></div> | ||
| <ul class="rows"> | ||
| {% for row in rows %} | ||
| <li><a class="repo-row" href="/{{ row.owner }}/{{ row.name }}/tree"> | ||
| <span class="ridentity"><span class="rname"><span>{{ row.owner }}/</span>{{ row.name }}</span> | ||
| {% if signed_in %}<small>{% if row.public %}Public{% else %}Private{% endif %}</small>{% endif %}</span> | ||
| <span class="rlast">{{ row.subject }}</span> | ||
| <span class="rwhen">{{ row.when }}</span> | ||
| </a></li> | ||
| {% endfor %} | ||
| </ul> | ||
| </div> | ||
| {% endif %} | ||
| {% endblock %} | ||