From b92787be7a95a4f340ba0f538775fc8e3b3f6bf8 Mon Sep 17 00:00:00 2001 From: Jean-Michel Tremblay Date: Fri, 19 Jun 2026 09:01:09 -0400 Subject: [PATCH] Recent list: initial the first name, keep timestamp from wrapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Abbreviate "First Last" → "F. Last" in the recent list and nowrap the upload timestamp, so rows fit on narrow phone screens instead of wrapping. Co-Authored-By: Claude Opus 4.8 --- internal/web/static/style.css | 2 +- internal/web/views.go | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/web/static/style.css b/internal/web/static/style.css index 87b4027..356e32a 100644 --- a/internal/web/static/style.css +++ b/internal/web/static/style.css @@ -91,7 +91,7 @@ ul.recent .amt { font-weight: 600; } ul.recent .meta { color: #333; } ul.recent .atts { margin-left: .15rem; } ul.recent .atts a { text-decoration: none; } -ul.recent .when { color: #999; font-size: .8rem; margin-left: .35rem; } +ul.recent .when { color: #999; font-size: .8rem; margin-left: .35rem; white-space: nowrap; } p.pager { margin-top: 1rem; } .err { diff --git a/internal/web/views.go b/internal/web/views.go index c88ee8e..6c3d888 100644 --- a/internal/web/views.go +++ b/internal/web/views.go @@ -6,6 +6,7 @@ import ( "fmt" "net/http" "strconv" + "strings" "time" "maisym.com/hsa/internal/receipt" @@ -129,7 +130,7 @@ func (s *Server) renderRecent(w http.ResponseWriter, r *http.Request, orderBy, t Date: row.ReceiptDate.Format(dateLayout), Amount: dollars(row.AmountCents), Category: row.Category, - Who: row.Who, + Who: shortWho(row.Who), When: row.UploadedAt.Local().Format("2006-01-02 15:04"), Filename: row.OriginalFilename, Attachments: links, @@ -224,6 +225,17 @@ func (s *Server) handleAttachmentFile(w http.ResponseWriter, r *http.Request) { http.ServeContent(w, r, a.OriginalFilename, a.UploadedAt, bytes.NewReader(a.ImageData)) } +// shortWho abbreviates a "First Last" person label to "F. Last" to keep the recent +// list compact on narrow screens. Single-word or empty labels are left as-is. +func shortWho(label string) string { + fields := strings.Fields(label) + if len(fields) < 2 { + return label + } + first := []rune(fields[0]) + return string(first[0]) + ". " + fields[len(fields)-1] +} + // dollars formats integer cents as a plain dollar string, e.g. 1234 -> "12.34". func dollars(cents int64) string { if cents < 0 {