From c9c63160e6f889c03fdf55befb50c09bb471dfc7 Mon Sep 17 00:00:00 2001 From: Amolith Date: Sat, 18 Oct 2025 10:41:01 -0600 Subject: [PATCH] feat: use consistent tooltip pattern for time Modify the author/time info on the home page to follow the same tooltip pattern as the commits page, displaying "Updated {time}". - Change HomeRepository.UpdatedAt from string to time.Time - Convert timestamps to UTC for consistency - Clean up tooltip format to show timezone only once - Remove unused humanize import Implements: bug-af63a29 Co-Authored-By: Crush --- pkg/web/templates/home.html | 2 +- pkg/web/webui.go | 11 ++++++++--- pkg/web/webui_home.go | 7 +++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/web/templates/home.html b/pkg/web/templates/home.html index 6d4457644199961c521639f4d49ad1d78baeeb84..2fc0133d83cf3fe4c81aad29a0b019372ac5df06 100644 --- a/pkg/web/templates/home.html +++ b/pkg/web/templates/home.html @@ -24,7 +24,7 @@
{{end}} {{if .UpdatedAt}} - Updated {{.UpdatedAt}} + Updated {{end}} diff --git a/pkg/web/webui.go b/pkg/web/webui.go index 56c6595a12d3db9aaaa09e53ea85199348be50b2..61837bc973fb6489912cd8ca3e1b535139f44c4a 100644 --- a/pkg/web/webui.go +++ b/pkg/web/webui.go @@ -111,10 +111,15 @@ var templateFuncs = template.FuncMap{ return hashStr }, "formatDate": func(t interface{}) string { - if time, ok := t.(fmt.Stringer); ok { - return time.String() + switch v := t.(type) { + case time.Time: + return v.Format("2006-01-02 15:04:05 UTC") + default: + if time, ok := t.(fmt.Stringer); ok { + return time.String() + } + return fmt.Sprintf("%v", t) } - return fmt.Sprintf("%v", t) }, "humanizeSize": func(size int64) string { const unit = 1024 diff --git a/pkg/web/webui_home.go b/pkg/web/webui_home.go index c8130acb0b02e5c11fdbd6be2b82b863b6b04951..e54fbaccd4f86a219746fdc5948897b723d7ddc8 100644 --- a/pkg/web/webui_home.go +++ b/pkg/web/webui_home.go @@ -15,7 +15,6 @@ import ( "github.com/charmbracelet/soft-serve/pkg/config" "github.com/charmbracelet/soft-serve/pkg/proto" "github.com/charmbracelet/soft-serve/pkg/ui/common" - "github.com/dustin/go-humanize" ) type HomeRepository struct { @@ -24,7 +23,7 @@ type HomeRepository struct { Description string IsPrivate bool CloneURL string - UpdatedAt string + UpdatedAt time.Time } type HomeData struct { @@ -135,9 +134,9 @@ func home(w http.ResponseWriter, r *http.Request) { description := strings.TrimSpace(repo.Description()) cloneURL := common.RepoURL(cfg.SSH.PublicURL, name) - var updatedAt string + var updatedAt time.Time if item.lastUpdate != nil { - updatedAt = humanize.Time(*item.lastUpdate) + updatedAt = item.lastUpdate.UTC() } homeRepos = append(homeRepos, HomeRepository{