diff --git a/AGENTS.md b/AGENTS.md index 80fffd3..ca9bc5d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -193,9 +193,32 @@ Located in `/Users/dima/code/pcom/cmd/web/client/scss/_dark-mode.scss`: **Do NOT define ad-hoc colors directly on elements** - always use Bootstrap's CSS variables to ensure proper inheritance and theming. +## Date/Time Rendering + +Use `renderHumanTime` template helper to display timestamps with relative time and full timestamp on hover: + +```html +{{ renderHumanTime .CreatedAt $.User.DBUser }} +``` + +**Output**: `5 minutes ago` + +- First argument: `time.Time` value to display +- Second argument: `*core.User` for timezone localization (can be nil for UTC) +- Implementation: `pkg/util/date` + +## Development + +### Verification +Use `make check` to verify code compiles and tests pass without producing build artifacts: +```bash +make check +``` + ## File Locations - HTML Templates: `/Users/dima/code/pcom/cmd/web/client/html/` - JavaScript: `/Users/dima/code/pcom/cmd/web/client/js/` - Main JS entry: `/Users/dima/code/pcom/cmd/web/client/js/index.js` - Markdown package: `/Users/dima/code/pcom/pkg/markdown/` - Dark mode styles: `/Users/dima/code/pcom/cmd/web/client/scss/_dark-mode.scss` +- Date utilities: `/Users/dima/code/pcom/pkg/util/date/` diff --git a/Makefile b/Makefile index 264a563..c11acc2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: shell tunnel lint test build +.PHONY: shell tunnel lint test build check shell: flyctl postgres connect -a pcomdb @@ -20,3 +20,7 @@ test: build: go build -v ./... + +check: + go build -o /dev/null ./... + go test ./... diff --git a/cmd/web/client/html/controls.html b/cmd/web/client/html/controls.html index 6b4b66d..baffcbe 100644 --- a/cmd/web/client/html/controls.html +++ b/cmd/web/client/html/controls.html @@ -36,7 +36,7 @@
Drafts
{{ range . }} {{ with .Subject }}{{ . }}{{ else }}No subject{{ end }} - {{ renderTimestamp .LastUpdatedAt $.User.DBUser }} + {{ renderHumanTime .LastUpdatedAt $.User.DBUser }}