xonecas.io
8356
Wx

www-xonecas-io / commit e3ea431

/activity: years, months and my commit feed by day, linked from the header (1027)

Co-Authored-By: Claude Opus 5.5

Sean Caetano Martin2026-11-08 e3ea43114a73e39c9ad67ae94faf4bf3a0925dbf parent 2f09b2a

12 files changed

internal/site/activity.go+79−0
@@ -0,0 +1,79 @@
1+package site
2+
3+import (
4+ "path/filepath"
5+ "slices"
6+ "strconv"
7+ "strings"
8+ "time"
9+
10+ "xonecas.io/site/internal/project"
11+)
12+
13+// YearCount is one row of the activity page's year list.
14+type YearCount struct {
15+ Year string
16+ Count, Heat int
17+}
18+
19+// Day is one day of the activity feed, newest commit first.
20+type Day struct {
21+ Label string
22+ Commits []Commit
23+}
24+
25+// ActivityPage is one year of my commits: the year list, its months, and its commits by day.
26+type ActivityPage struct {
27+ Year string
28+ Total int
29+ Years []YearCount
30+ Months []Cell
31+ Days []Day
32+}
33+
34+// writeActivity writes /activity/<year>/ for every year from the first to the last commit,
35+// and /activity/ as the latest year. feed is my commits across the shown projects.
36+func writeActivity(out string, shown []project.Project, feed []Commit) error {
37+ all, years := map[string]int{}, map[string]int{}
38+ first, last := "9999", "0000"
39+ for _, p := range shown {
40+ for m, n := range p.Months {
41+ all[m] += n
42+ years[m[:4]] += n
43+ }
44+ first, last = min(first, p.First[:4]), max(last, p.Last[:4])
45+ }
46+ var list []YearCount
47+ lo, _ := strconv.Atoi(first)
48+ hi, _ := strconv.Atoi(last)
49+ for n := hi; n >= lo; n-- {
50+ y := strconv.Itoa(n)
51+ list = append(list, YearCount{y, years[y], level(years[y])})
52+ }
53+ slices.SortStableFunc(feed, func(a, b Commit) int { return strings.Compare(b.Date, a.Date) })
54+ for _, y := range list {
55+ page := ActivityPage{Year: y.Year, Total: y.Count, Years: list, Months: months(y.Year, all)}
56+ day := ""
57+ for _, c := range feed {
58+ if !strings.HasPrefix(c.Date, y.Year) {
59+ continue
60+ }
61+ if c.Date != day {
62+ t, _ := time.Parse(time.DateOnly, c.Date)
63+ page.Days, day = append(page.Days, Day{Label: t.Format("Mon 2 Jan")}), c.Date
64+ }
65+ c.Date = "" // the day's heading says it
66+ page.Days[len(page.Days)-1].Commits = append(page.Days[len(page.Days)-1].Commits, c)
67+ }
68+ paths := []string{filepath.Join(out, "activity", y.Year, "index.html")}
69+ if y.Year == last {
70+ paths = append(paths, filepath.Join(out, "activity", "index.html"))
71+ }
72+ for _, path := range paths {
73+ if err := render(path, "activity.html", page); err != nil {
74+ return err
75+ }
76+ }
77+ }
78+ return nil
79+}
internal/site/build.go+11−1
@@ -60,17 +60,27 @@ func Build(projects []project.Project, out, tailwind string) error {
6060 if err != nil {
6161 return err
6262 }
63+ var feed []Commit
6364 for i, p := range shown {
6465 if err := writeProject(out, p, rows[i], fresh); err != nil {
6566 return fmt.Errorf("%s: %w", p.Name, err)
6667 }
67- if err := writeCommits(out, p, rows[i], fresh); err != nil {
68+ log, err := writeCommits(out, p, rows[i], fresh)
69+ if err != nil {
6870 return fmt.Errorf("%s: %w", p.Name, err)
6971 }
72+ for _, c := range log {
73+ if project.Me[strings.ToLower(c.Author)] {
74+ feed = append(feed, Commit{rows[i].El, c.Short, c.Subject, c.Author, c.Date, "/projects/" + p.Name + "/commit/" + c.Hash + "/"})
75+ }
76+ }
7077 if err := writeClone(out, p.Name, p.Sources[0].Dir); err != nil {
7178 return fmt.Errorf("%s: %w", p.Name, err)
7279 }
7380 }
81+ if err := writeActivity(out, shown, feed); err != nil {
82+ return err
83+ }
7484 if err := os.WriteFile(filepath.Join(out, ".stamp"), []byte(stamp), 0o644); err != nil {
7585 return err
7686 }
internal/site/build_test.go+5−1
@@ -31,7 +31,7 @@ func gitRepo(t *testing.T) string {
3131 }
3232
3333 func TestBuild(t *testing.T) {
34- src := []project.Source{{URL: "https://github.com/xonecas/hello.git", Dir: gitRepo(t), Branch: "main"}}
34+ src := []project.Source{{URL: "https://github.com/xonecas/hello.git", Dir: gitRepo(t), Branch: "main", Commits: 1}}
3535 projects := []project.Project{
3636 {Name: "hello", Sources: src, Info: project.Info{Readme: "README.md", Commits: 3, First: "2026-10-01", Last: "2026-11-01", Description: "says hi", Tags: []string{"pre-AI", "small", "frontend"}}},
3737 {Name: "a-fork", Info: project.Info{Hidden: "fork"}},
@@ -74,6 +74,10 @@ func TestBuild(t *testing.T) {
7474 t.Errorf("projects/hello/index.html is missing %q", want)
7575 }
7676 }
77+ page, err = os.ReadFile(filepath.Join(out, "activity/index.html"))
78+ if err != nil || !strings.Contains(string(page), `href="/projects/hello/commit/`) {
79+ t.Errorf("activity page does not list hello's commit: %v", err)
80+ }
7781 page, err = os.ReadFile(filepath.Join(out, "projects/hello/blob/img/logo.png/index.html"))
7882 if err != nil || !strings.Contains(string(page), "Binary file, not shown.") {
7983 t.Errorf("logo.png page: %v", err)
internal/site/commits.go+5−5
@@ -72,11 +72,11 @@ func readLog(p project.Project) ([]LogEntry, error) {
7272 }
7373
7474 // writeCommits writes the log pages, and a page for each commit not already built by this
75-// same build of the site (stamp), so a rebuild only renders new commits.
76-func writeCommits(out string, p project.Project, row ProjectRow, fresh bool) error {
75+// same build of the site (stamp), so a rebuild only renders new commits. It returns the log.
76+func writeCommits(out string, p project.Project, row ProjectRow, fresh bool) ([]LogEntry, error) {
7777 log, err := readLog(p)
7878 if err != nil {
79- return err
79+ return nil, err
8080 }
8181 base := filepath.Join(out, "projects", p.Name, "commits")
8282 pages := max(1, (len(log)+PerPage-1)/PerPage)
@@ -87,7 +87,7 @@ func writeCommits(out string, p project.Project, row ProjectRow, fresh bool) err
8787 }
8888 page := LogPage{Row: row, Name: p.Name, Commits: log[i*PerPage : min(len(log), (i+1)*PerPage)], Page: i + 1, Pages: pages, Total: len(log)}
8989 if err := render(filepath.Join(dir, "index.html"), "commits.html", page); err != nil {
90- return err
90+ return nil, err
9191 }
9292 }
9393 var wg sync.WaitGroup
@@ -113,5 +113,5 @@ func writeCommits(out string, p project.Project, row ProjectRow, fresh bool) err
113113 })
114114 }
115115 wg.Wait()
116- return errors.Join(errs...)
116+ return log, errors.Join(errs...)
117117 }
internal/site/templates/activity.html+24−0
@@ -0,0 +1,24 @@
1+{{define "activity.html"}}{{template "head" (printf "Activity %s" .Year)}}{{template "nav" "Activity"}}
2+<main class="px-4 sm:px-8 py-6 max-w-[1440px] mx-auto grid grid-cols-1 lg:grid-cols-[17rem_minmax(0,1fr)] gap-x-10 gap-y-8">
3+ <aside class="order-2 lg:order-none">
4+ <h2 class="font-bold text-lg mb-2">Years</h2>
5+ {{range .Years}}<a href="/activity/{{.Year}}/" class="grid grid-cols-[2.75rem_minmax(0,1fr)_3.5rem] items-center gap-3 py-1 no-underline hover:underline {{if eq .Year $.Year}}text-accent font-bold{{end}}">
6+ <span>{{.Year}}</span><span class="h-4 rounded-[2px] bg-h{{.Heat}}"></span><span class="text-right font-mono text-sm">{{comma .Count}}</span></a>{{end}}
7+ </aside>
8+ <div class="min-w-0">
9+ <div class="flex flex-wrap items-end gap-x-4 gap-y-2">
10+ <div class="bg-det text-det-fg text-[64px] font-bold leading-[.9] tracking-tight px-3 pt-2 pb-1 rounded-[2px]">{{comma .Total}}</div>
11+ <h1 class="text-2xl font-bold">commits in {{.Year}}</h1>
12+ <span class="ml-auto text-xs text-soft">newest first</span>
13+ </div>
14+ <div class="grid grid-cols-12 gap-[3px] mt-4 text-[11px]">
15+ {{range list "J" "F" "M" "A" "M" "J" "J" "A" "S" "O" "N" "D"}}<span class="text-center text-soft">{{.}}</span>{{end}}
16+ {{range .Months}}<span class="h-7 rounded-[2px] bg-h{{.Heat}} text-t{{.Heat}} grid place-items-center font-semibold" title="{{.Month}}: {{.Count}} commits">{{if .Count}}{{.Count}}{{end}}</span>{{end}}
17+ </div>
18+ {{range .Days}}<section class="mt-5">
19+ <div class="flex items-baseline justify-between border-b-[1.5px] border-ink pb-1"><h2 class="font-bold">{{.Label}}</h2><span class="text-xs text-soft">{{len .Commits}} commit{{if gt (len .Commits) 1}}s{{end}}</span></div>
20+ {{range .Commits}}{{template "commit-row" .}}{{end}}
21+ </section>{{else}}<p class="mt-6 font-serif italic text-soft">No commits in {{.Year}}.</p>{{end}}
22+ </div>
23+</main>
24+{{template "foot"}}{{end}}
internal/site/templates/components.html+2−2
@@ -4,7 +4,7 @@
44 <header class="border-b-[1.5px] border-ink"><div class="flex flex-wrap items-center gap-x-6 gap-y-2 px-4 sm:px-8 py-3 max-w-[1440px] mx-auto">
55 <a href="/" id="face" class="flex items-center gap-2 font-bold text-xl"><img src="/logo.svg" alt="" width="32" height="32" class="rounded-[2px]">xonecas.io</a>
66 <nav class="flex gap-5 font-semibold">
7- {{range $l := list "Overview" "Projects"}}<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}}
7+ {{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>
99 <button id="theme" type="button" title="Light or dark" aria-label="Switch between light and dark" class="ml-auto p-1 cursor-pointer hover:text-accent"><svg viewBox="0 0 16 16" width="20" height="20" aria-hidden="true"><circle cx="8" cy="8" r="6.5" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M8 1.5a6.5 6.5 0 0 1 0 13z" fill="currentColor"/></svg></button>
1010 <form action="/projects/" class="w-full sm:w-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>
@@ -70,7 +70,7 @@
7070 <div class="@container"><div class="grid grid-cols-[30px_minmax(0,1fr)_auto] @xl:grid-cols-[30px_12rem_5rem_minmax(0,1fr)_6rem] gap-x-3 gap-y-0.5 items-center py-1.5 border-b border-line text-[14.5px]">
7171 {{template "element" (dict "El" .El "Size" "xs")}}
7272 <b class="truncate">{{.El.Name}}</b>
73- <code class="font-mono text-[12.5px] text-accent @xl:order-none">{{.Hash}}</code>
73+ {{if .Href}}<a href="{{.Href}}" class="font-mono text-[12.5px] text-accent no-underline hover:underline">{{.Hash}}</a>{{else}}<code class="font-mono text-[12.5px] text-accent">{{.Hash}}</code>{{end}}
7474 <span class="col-start-2 col-span-2 @xl:col-auto truncate">{{.Msg}}</span>
7575 <span class="hidden @xl:block text-right text-sm text-soft">{{.Date}}</span>
7676 </div></div>
tickets/1020-let-s-add-a-filtering-control-for-filtering-by.md+3−3
@@ -2,13 +2,13 @@
22 id: 1020
33 title: let's add a filtering control for filtering by start and end years/months. use a slider
44 type: feature
5-status: review
5+status: done
66 priority: p2
77 created: 2026-11-08T03:56:52Z
8-updated: 2026-11-08T04:16:55Z
8+updated: 2026-11-08T04:28:57Z
99 source: devnote
1010 area: site
11-moves: 2026-11-08T04:02:14Z inbox doing drag; 2026-11-08T04:16:55Z doing review agent
11+moves: 2026-11-08T04:02:14Z inbox doing drag; 2026-11-08T04:16:55Z doing review agent; 2026-11-08T04:28:57Z review done drag
1212 ---
1313
1414 ## Context
tickets/1022-should-be-a-link-to-the-commit-view.md+3−3
@@ -2,13 +2,13 @@
22 id: 1022
33 title: Should be a link to the commit view
44 type: bug
5-status: review
5+status: done
66 priority: p2
77 created: 2026-11-08T03:59:59Z
8-updated: 2026-11-08T04:04:07Z
8+updated: 2026-11-08T04:28:53Z
99 source: devnote
1010 area: site
11-moves: 2026-11-08T04:02:13Z inbox doing drag; 2026-11-08T04:04:07Z doing review agent
11+moves: 2026-11-08T04:02:13Z inbox doing drag; 2026-11-08T04:04:07Z doing review agent; 2026-11-08T04:28:53Z review done drag
1212 ---
1313
1414 ## Context
tickets/1025-need-a-light-dark-toggel.md+3−3
@@ -2,12 +2,12 @@
22 id: 1025
33 title: Need a light/dark toggle
44 type: feature
5-status: review
5+status: done
66 priority: p2
77 created: 2026-11-08T04:14:52Z
8-updated: 2026-11-08T04:23:05Z
8+updated: 2026-11-08T04:28:46Z
99 source: human
10-moves: 2026-11-08T04:14:56Z inbox doing drag; 2026-11-08T04:23:05Z doing review agent
10+moves: 2026-11-08T04:14:56Z inbox doing drag; 2026-11-08T04:23:05Z doing review agent; 2026-11-08T04:28:46Z review done drag
1111 area: site
1212 ---
1313
tickets/1027-the-mocks-have-a-activity-page-lets-make-it-real.md+30−0
@@ -0,0 +1,30 @@
1+---
2+id: 1027
3+title: the mocks have a /activity page lets make it real
4+type: feature
5+status: review
6+priority: p2
7+created: 2026-11-08T04:27:16Z
8+updated: 2026-11-08T04:34:24Z
9+source: human
10+area: site
11+moves: 2026-11-08T04:28:43Z inbox doing drag; 2026-11-08T04:34:24Z doing review agent
12+---
13+
14+
15+## Notes
16+
17+- 2026-11-08 04:27Z (agent): Triage: type feature (it was bug), priority p2, area site. No typos to fix.
18+
19+ The mock is the 'Activity' page in the 1001 attachments ('02 layout in 20 style, light and dark'). Its caption: 'Years as heat, 2026 by month, then the commit feed by day.' The mocks also have 'Activity' in the header nav, after Overview and Projects. 1010 removed that nav link because no page existed; this ticket brings it back. The data is already there: per-month counts (homepage wall) and each project's commit log (commit pages, 1009).
20+
21+- 2026-11-08 04:34Z (agent): Done. /activity is real, following the 1001 mock ('Years as heat, 2026 by month, then the commit feed by day'), built from the site's own components. 'Activity' is back in the header nav.
22+
23+ - /activity/ is the latest year; /activity/<year>/ exists for every year 2011-2026, 2019 included ('No commits in 2019.').
24+ - Left: Years, each a heat bar and count, linking to its page, the current one in accent. Main: the year's total in the big block, 'commits in <year>', the 12-month strip with counts, then the feed grouped by day ('Sat 7 Nov', N commits). Each row uses the style guide's commit-row: project tile, name, hash linking to the commit page, subject. The date per row is dropped there, since the day heading says it.
25+ - 'My commits' uses the same rule as every other count (project.Me authors, each hash once), so the totals match the homepage wall.
26+ - internal/site/activity.go (new), templates/activity.html (new). writeCommits now returns its log, so Build collects the feed without reading git twice. commit-row's hash is a link when it has one. build_test checks the page lists a commit; its test source needed Commits: 1, or readLog skipped it.
27+
28+ CHECKED: go vet, go test pass. Every year page's headline count equals its feed rows (2026: 2057 = 2057; all 16 years match, 0 mismatches). agent-browser: clicked 2011 in Years, which opened /activity/2011/ (55 days, 2011 marked); clicked a hash, which opened its commit page. Screenshots at 1440 light and 390 dark, no sideways scroll.
29+
30+ NOT CHECKED / WATCH OUT: the 2026 page is 1.9 MB of HTML (132 KB gzipped) for 2057 rows; no paging. On phones the header now wraps to three rows (logo / nav and theme button / search), because three nav links no longer fit beside the logo at 390px.
tickets/1028-let-s-make-the-slider-more-prominent-and-cool.md+21−0
@@ -0,0 +1,21 @@
1+---
2+id: 1028
3+title: let's make the slider more prominent and cool. As wide as the table below it.
4+type: feature
5+status: inbox
6+priority: p2
7+created: 2026-11-08T04:27:51Z
8+updated: 2026-11-08T04:28:00Z
9+source: devnote
10+area: site
11+---
12+
13+## Context
14+
15+Filed from `http://192.168.122.10:8080/projects/`, on `div.range.flex-1.max-w-md`.
16+
17+## Notes
18+
19+- 2026-11-08 04:28Z (agent): Triage: type feature (it was bug), priority p2, area site. Fixed the typo 'bellow' -> 'below'.
20+
21+ The slider is the 'Active' row on /projects from 1020: today it is capped at max-w-md (448px) and sits after an 'Active' label, with the range printed to its right. The table below spans the full content width (up to 1440px minus padding). Related: 1020.
tickets/1029-let-s-add-click-to-copy-to-clipboard-to-the.md+16−0
@@ -0,0 +1,16 @@
1+---
2+id: 1029
3+title: Let's add click to copy to clipboard to the clone link
4+type: bug
5+status: inbox
6+priority: p2
7+created: 2026-11-08T04:29:39Z
8+updated: 2026-11-08T04:29:39Z
9+source: devnote
10+---
11+
12+## Context
13+
14+Filed from `http://192.168.122.10:8080/projects/macotron-plugin-caffeinate/`, on `pre.bg-pre.text-pre-fg.rounded-[2px]`.
15+
16+> git clone https://xonecas.io/macotron-plugin-caffeinate.git