xonecas.io
8356
Wx

www-xonecas-io / commit 9e98dfe

/projects: periodic-table rows with tag filters, sort and search in the URL (1006)

Co-Authored-By: Claude Opus 5.5

Sean Caetano Martin2026-11-08 9e98dfe88eb87ffd06cd691609f172a0fdd7845d parent 5ff0fd5

13 files changed

internal/site/build.go+3−2
@@ -45,8 +45,9 @@ func Build(projects []project.Project, out, tailwind string) error {
4545 name string
4646 data any
4747 }{
48- "index.html": {"index.html", shown},
49- "style/index.html": {"style.html", styleData()},
48+ "index.html": {"index.html", shown},
49+ "projects/index.html": {"projects.html", projectsData(shown)},
50+ "style/index.html": {"style.html", styleData()},
5051 } {
5152 if err := render(filepath.Join(out, path), page.name, page.data); err != nil {
5253 return err
internal/site/build_test.go+22−2
@@ -11,7 +11,7 @@ import (
1111
1212 func TestBuild(t *testing.T) {
1313 projects := []project.Project{
14- {Name: "hello", Info: project.Info{Commits: 3, Last: "2026-11-01", Description: "says hi"}},
14+ {Name: "hello", Info: project.Info{Commits: 3, First: "2026-10-01", Last: "2026-11-01", Description: "says hi", Tags: []string{"pre-AI", "small", "frontend"}}},
1515 {Name: "a-fork", Info: project.Info{Hidden: "fork"}},
1616 }
1717 out := t.TempDir()
@@ -30,9 +30,29 @@ func TestBuild(t *testing.T) {
3030 if strings.Contains(string(page), "a-fork") {
3131 t.Error("index.html lists a hidden project")
3232 }
33- for _, f := range []string{"style/index.html", "logo.svg"} {
33+ page, err = os.ReadFile(filepath.Join(out, "projects/index.html"))
34+ if err != nil {
35+ t.Fatal(err)
36+ }
37+ for _, want := range []string{`data-name="hello"`, `data-tags="pre-AI small frontend "`, `value="frontend" class="sr-only peer">`} {
38+ if !strings.Contains(string(page), want) {
39+ t.Errorf("projects/index.html is missing %q", want)
40+ }
41+ }
42+ if strings.Contains(string(page), "a-fork") {
43+ t.Error("projects/index.html lists a hidden project")
44+ }
45+ for _, f := range []string{"style/index.html", "logo.svg", "projects.js"} {
3446 if _, err := os.Stat(filepath.Join(out, f)); err != nil {
3547 t.Error(err)
3648 }
3749 }
3850 }
51+
52+func TestSymbol(t *testing.T) {
53+ taken := map[string]bool{}
54+ got := []string{symbol("mini-coder", taken), symbol("mini-coding-agent", taken), symbol("xonecas.com", taken), symbol("a", taken)}
55+ if strings.Join(got, " ") != "Mc Ma Xc A" {
56+ t.Errorf("symbols are %v", got)
57+ }
58+}
internal/site/rows.go+116−0
@@ -0,0 +1,116 @@
1+package site
2+
3+import (
4+ "slices"
5+ "strings"
6+ "time"
7+ "unicode"
8+
9+ "xonecas.io/site/internal/project"
10+)
11+
12+// heat is the fewest commits for each heat level after h0.
13+var heat = []int{1, 15, 40, 100, 200, 500}
14+
15+// Rows turns the shown projects, oldest first, into list rows. Num is the order of discovery,
16+// symbols are unique and go to the oldest project first, and the bar spans the whole timeline.
17+func Rows(projects []project.Project) []ProjectRow {
18+ first, last := projects[0].First, projects[0].Last
19+ for _, p := range projects {
20+ first, last = min(first, p.First), max(last, p.Last)
21+ }
22+ start, end := day(first), day(last)
23+ span := max(end.Sub(start).Hours(), 24)
24+ taken := map[string]bool{}
25+ rows := make([]ProjectRow, len(projects))
26+ for i, p := range projects {
27+ r := ProjectRow{
28+ El: Element{Num: i + 1, Weight: p.Commits, Sym: symbol(p.Name, taken), Name: p.Name, Group: group(p.Tags), Post: slices.Contains(p.Tags, "post-AI")},
29+ Desc: p.Description,
30+ From: 100 * day(p.First).Sub(start).Hours() / span,
31+ Width: 100 * day(p.Last).Sub(day(p.First)).Hours() / span,
32+ Tags: p.Tags,
33+ First: p.First,
34+ Last: p.Last,
35+ }
36+ for _, n := range heat {
37+ if p.Commits >= n {
38+ r.Heat++
39+ }
40+ }
41+ if len(p.Languages) > 0 {
42+ r.Lang = p.Languages[0].Name
43+ }
44+ rows[i] = r
45+ }
46+ return rows
47+}
48+
49+func day(s string) time.Time {
50+ t, _ := time.Parse(time.DateOnly, s)
51+ return t
52+}
53+
54+func group(tags []string) string {
55+ fe, be := slices.Contains(tags, "frontend"), slices.Contains(tags, "backend")
56+ switch {
57+ case fe && be:
58+ return "both"
59+ case fe:
60+ return "fe"
61+ case be:
62+ return "be"
63+ }
64+ return "none"
65+}
66+
67+// symbol is the name's first letter and the first later letter that makes an unused pair,
68+// trying the first letters of words before the rest.
69+func symbol(name string, taken map[string]bool) string {
70+ var initials, rest []rune
71+ first, word := rune(0), false
72+ for _, c := range strings.ToLower(name) {
73+ switch {
74+ case !unicode.IsLetter(c) && !unicode.IsDigit(c):
75+ word = true
76+ case first == 0:
77+ first = c
78+ case word:
79+ initials, word = append(initials, c), false
80+ default:
81+ rest = append(rest, c)
82+ }
83+ }
84+ for _, c := range append(initials, rest...) {
85+ if s := string(unicode.ToUpper(first)) + string(c); !taken[s] {
86+ taken[s] = true
87+ return s
88+ }
89+ }
90+ s := string(unicode.ToUpper(first))
91+ taken[s] = true
92+ return s
93+}
94+
95+// TagCount is a tag and how many shown projects have it.
96+type TagCount struct {
97+ Name string
98+ Count int
99+}
100+
101+// projectsData is the /projects page: the rows by last commit, and the tag pairs with their counts.
102+func projectsData(shown []project.Project) map[string]any {
103+ rows := Rows(shown)
104+ slices.SortStableFunc(rows, func(a, b ProjectRow) int { return strings.Compare(b.Last, a.Last) })
105+ pairs := [][]TagCount{{{"frontend", 0}, {"backend", 0}}, {{"small", 0}, {"big", 0}}, {{"pre-AI", 0}, {"post-AI", 0}}}
106+ for _, r := range rows {
107+ for _, pair := range pairs {
108+ for i := range pair {
109+ if slices.Contains(r.Tags, pair[i].Name) {
110+ pair[i].Count++
111+ }
112+ }
113+ }
114+ }
115+ return map[string]any{"Rows": rows, "Pairs": pairs}
116+}
internal/site/static/projects.js+39−0
@@ -0,0 +1,39 @@
1+// Filters, sorts and searches the /projects list, and keeps the view in the URL.
2+// Tags from different pairs must all match; tags of the same pair match either.
3+const form = document.getElementById("filters"), list = document.getElementById("rows");
4+const search = document.querySelector("input[name=q]"), rows = [...list.children];
5+const sorts = {
6+ recent: (a, b) => b.dataset.last.localeCompare(a.dataset.last),
7+ oldest: (a, b) => a.dataset.first.localeCompare(b.dataset.first),
8+ commits: (a, b) => b.dataset.commits - a.dataset.commits,
9+};
10+
11+function apply() {
12+ const pairs = [...form.querySelectorAll("fieldset")].slice(0, -1)
13+ .map(f => [...f.querySelectorAll(":checked")].map(i => i.value)).filter(p => p.length);
14+ const q = search.value.trim().toLowerCase(), sort = form.sort.value;
15+ let shown = 0;
16+ for (const r of rows.sort(sorts[sort])) {
17+ const tags = r.dataset.tags.split(" ");
18+ r.hidden = !r.dataset.name.includes(q) || !pairs.every(p => p.some(t => tags.includes(t)));
19+ shown += !r.hidden;
20+ list.append(r);
21+ }
22+ document.getElementById("shown").textContent = shown;
23+ document.getElementById("none").hidden = shown > 0;
24+ const url = new URLSearchParams();
25+ for (const p of pairs) for (const t of p) url.append("tag", t);
26+ if (sort !== "recent") url.set("sort", sort);
27+ if (q) url.set("q", q);
28+ history.replaceState(null, "", url.size ? "?" + url : location.pathname);
29+}
30+
31+const url = new URLSearchParams(location.search), want = url.getAll("tag");
32+for (const i of form.tag) i.checked = want.includes(i.value);
33+form.sort.value = sorts[url.get("sort")] ? url.get("sort") : "recent";
34+search.value = url.get("q") || "";
35+search.form.addEventListener("submit", e => e.preventDefault());
36+search.addEventListener("input", apply);
37+form.addEventListener("change", apply);
38+form.hidden = false;
39+apply();
internal/site/style.go+5−5
@@ -14,11 +14,11 @@ func styleData() map[string]any {
1414 "Heat": []int{0, 2, 8, 27, 62, 205, 625},
1515 "Tags": []string{"frontend", "backend", "small", "big", "pre-AI", "post-AI"},
1616 "Rows": []ProjectRow{
17- {mc, "A good idea 👾 A fast, transparent agent for the terminal", "TypeScript", 94.3, 4.7, 6, []string{"post-AI", "big"}},
18- {zn, "Zoea-Nova is a high-performance command center designed to orchestrate massive swarms of agents", "Go", 95.8, 3.1, 5, []string{"post-AI", "big", "backend"}},
19- {cl, "Terminal comics from the AI coding build log", "Python", 97.4, 1.6, 2, []string{"post-AI", "small", "frontend", "backend"}},
20- {xc, "My space online.", "JavaScript", 3.6, 5.7, 3, []string{"pre-AI", "big", "frontend"}},
21- {fn, "Node.js Module for ffmpeg library.", "JavaScript", 0, 34, 1, []string{"pre-AI", "small"}},
17+ {mc, "A good idea 👾 A fast, transparent agent for the terminal", "TypeScript", 94.3, 4.7, 6, []string{"post-AI", "big"}, "", ""},
18+ {zn, "Zoea-Nova is a high-performance command center designed to orchestrate massive swarms of agents", "Go", 95.8, 3.1, 5, []string{"post-AI", "big", "backend"}, "", ""},
19+ {cl, "Terminal comics from the AI coding build log", "Python", 97.4, 1.6, 2, []string{"post-AI", "small", "frontend", "backend"}, "", ""},
20+ {xc, "My space online.", "JavaScript", 3.6, 5.7, 3, []string{"pre-AI", "big", "frontend"}, "", ""},
21+ {fn, "Node.js Module for ffmpeg library.", "JavaScript", 0, 34, 1, []string{"pre-AI", "small"}, "", ""},
2222 },
2323 "Tree": map[string]any{
2424 "Head": Commit{mc, "a2174ac", "chore: pkg bump", "xonecas", "2026-10-02"},
internal/site/templates/components.html+1−1
@@ -6,7 +6,7 @@
66 <nav class="flex gap-5 font-semibold">
77 {{range $l := list "Overview" "Projects" "Activity"}}<a href="{{if eq $l "Overview"}}/{{else}}/{{lower $l}}/{{end}}" class="{{if eq $l $}}underline underline-offset-[6px] decoration-[3px]{{else}}no-underline{{end}}">{{$l}}</a>{{end}}
88 </nav>
9- <form action="/projects/" class="w-full sm:w-auto sm:ml-auto"><input name="q" placeholder="Search 82 projects" class="w-full sm:w-80 px-3 py-1.5 border-[1.5px] border-ink rounded-[2px] bg-card text-sm placeholder:text-soft"></form>
9+ <form action="/projects/" class="w-full sm:w-auto sm:ml-auto"><input name="q" placeholder="Search projects" class="w-full sm:w-80 px-3 py-1.5 border-[1.5px] border-ink rounded-[2px] bg-card text-sm placeholder:text-soft"></form>
1010 </header>
1111 {{end}}
1212
internal/site/templates/projects.html+20−0
@@ -0,0 +1,20 @@
1+{{define "projects.html"}}{{template "head" "Projects"}}{{template "nav" "Projects"}}
2+<main class="px-4 sm:px-8 py-6 max-w-[1440px] mx-auto">
3+ <h1 class="text-3xl font-bold mb-4"><span id="shown">{{len .Rows}}</span> projects</h1>
4+ <form id="filters" hidden class="flex flex-wrap items-center gap-x-6 gap-y-2 mb-4 text-sm">
5+ <p class="w-full -mt-3 font-serif italic text-soft text-[15.5px]">Pick tags to narrow the list. Both tags of a pair keep both.</p>
6+ {{range .Pairs}}<fieldset class="flex gap-1">{{range .}}
7+ <label class="cursor-pointer rounded-[2px] has-checked:bg-accent has-checked:text-paper"><input type="checkbox" name="tag" value="{{.Name}}" class="sr-only peer">
8+ <span class="flex items-center peer-focus-visible:outline-2 outline-accent rounded-[2px]">{{template "tag" .Name}}<span class="px-1.5 font-mono text-xs">{{.Count}}</span></span></label>{{end}}
9+ </fieldset>{{end}}
10+ <fieldset class="flex items-center gap-3 sm:ml-auto"><span class="text-soft">Sort</span>
11+ {{range list "recent" "oldest" "commits"}}<label class="cursor-pointer font-semibold has-checked:underline underline-offset-4 decoration-2"><input type="radio" name="sort" value="{{.}}" class="sr-only" {{if eq . "recent"}}checked{{end}}>{{.}}</label>{{end}}
12+ </fieldset>
13+ </form>
14+ <ol id="rows">
15+ {{range .Rows}}<li data-name="{{lower .El.Name}}" data-tags="{{range .Tags}}{{.}} {{end}}" data-first="{{.First}}" data-last="{{.Last}}" data-commits="{{.El.Weight}}">{{template "project-row" .}}</li>{{end}}
16+ </ol>
17+ <p id="none" hidden class="py-6 text-soft">No project matches.</p>
18+</main>
19+<script src="/projects.js"></script>
20+{{template "foot"}}{{end}}
internal/site/view.go+1−0
@@ -17,6 +17,7 @@ type ProjectRow struct {
1717 From, Width float64 // the active span, as percent of the whole timeline
1818 Heat int // 0-6, from commit count
1919 Tags []string
20+ First, Last string // dates of the first and last commit, for sorting
2021 }
2122
2223 // TreeEntry is one file or folder in a file tree, with its last commit.
tickets/1006-build-the-projects-index-with-tag-filters-and.md+19−3
@@ -2,13 +2,13 @@
22 id: 1006
33 title: Build the /projects index with tag filters and search
44 type: feature
5-status: doing
5+status: review
66 priority: p1
77 area: site
88 created: 2026-11-07T19:30:00Z
9-updated: 2026-11-08T01:09:33Z
9+updated: 2026-11-08T01:33:51Z
1010 source: agent
11-moves: 2026-11-07T19:30:00Z inbox todo agent; 2026-11-08T01:09:33Z todo doing drag
11+moves: 2026-11-07T19:30:00Z inbox todo agent; 2026-11-08T01:09:33Z todo doing drag; 2026-11-08T01:33:51Z doing review agent
1212 ---
1313
1414 xonecas.io/projects lists every project, using the chosen style.
@@ -16,3 +16,19 @@ xonecas.io/projects lists every project, using the chosen style.
1616 Filter by any combination of frontend, backend, small, big, pre-AI, post-AI. Also sort (recent, oldest, commits) and search by name. Filters live in the URL so a filtered view can be shared. With JS off, the full list still renders.
1717
1818 Done when: all listed projects appear, filter counts match the data file, and it works at phone width.
19+
20+## Notes
21+
22+- 2026-11-08 01:33Z (agent): Done: /projects lists all 81 shown projects as periodic-table rows, newest last commit first. It has tag filters, sort (recent, oldest, commits) and search by name, and it works at phone width and in dark mode. Screenshots are attached.
23+
24+ - Filters live in the URL, e.g. /projects/?tag=backend&tag=big&sort=commits&q=agent. Defaults are left out, so a plain /projects/ stays plain.
25+ - Tags from different pairs must all match. Both tags of the same pair match either: frontend+backend gives 'frontend or backend', since pre-AI AND post-AI would always be empty. I picked this rule; it is one line in static/projects.js if you want plain AND.
26+ - The counts next to each tag are from data/projects.json: frontend 37, backend 20, small 70, big 11, pre-AI 51, post-AI 30. I checked them against the data file. They stay fixed as you filter. The heading shows how many match.
27+ - Search is the nav's search box, which filters as you type here. From other pages it submits to /projects/?q=.
28+ - With JS off, the full list renders and the filter bar stays hidden, because it can do nothing without JS. It is a static site, so filtering is a small script (projects.js, about 40 lines) rather than htmx, which needs a server to talk to.
29+ - Each tile: the number is the order of the first commit (1 = oldest), the top-right is your commits, the symbol is unique (first letter plus a word initial, oldest project first), and the colour is frontend, backend, both or neither. The bar is the active span on a 2011 to now timeline, and its heat comes from the commit count.
30+
31+ CHANGED OUTSIDE THE TICKET: the nav's search placeholder said 'Search 82 projects', which was hard-coded and wrong after irvc was hidden. It now says 'Search projects'.
32+
33+ CHECKED: go test (the page renders, hidden projects are left out, symbols are unique), 81 rows and 81 unique symbols in the built page, and Firefox screenshots: desktop, 390px phone, dark, and JS off.
34+ NOT CHECKED: Chrome and Safari, and keyboard-only use beyond a focus ring on the chips. Project links go to /projects/<name>/, which 1007 builds, so they 404 for now.
tickets/attachments/1006/JS off, full list.png+0−0
Binary file, not shown.
tickets/attachments/1006/backend + big, by commits.png+0−0
Binary file, not shown.
tickets/attachments/1006/dark, frontend + backend + big.png+0−0
Binary file, not shown.
tickets/attachments/1006/phone, post-AI + big, search mini.png+0−0
Binary file, not shown.