Skip to content

profile: new component for the public persona (closes #52) - #53

Merged
matthewjhunter merged 4 commits into
mainfrom
feature/52
Jun 9, 2026
Merged

matthewjhunter merged 4 commits into
mainfrom
feature/52

Conversation

@matthewjhunter

Copy link
Copy Markdown
Contributor

Summary

Implements #52: a new mountable profile component owning the public persona -- claimable handle, display name, markdown bio, avatar, and bio links -- keyed by an opaque host-supplied user key so the host's users table stays the host's FK hub.

Shape

Follows the timeline/faq component pattern throughout: New(Config) / Routes() / Migrate(ctx), host-supplied profileuser.Resolver, ui/document chrome with a per-request Chrome hook, dedicated profile_goose_db_version table, sqlc + pgx/v5, handlers over a small store interface.

  • Handles: lowercase-normalized text with a plain UNIQUE constraint (case-insensitive uniqueness without citext, so the component never needs CREATE EXTENSION). 3-32 chars, alphanumerics + interior hyphens; claim-once, admin-only rename; built-in reserved set (route words, authority names) extendable via Config.ReservedHandles. One deliberate deviation from the issue text, which said citext -- a mountable component should not assume extension-creation privileges.
  • Bio: stored as markdown source, sanitized at render time through ui/markdown's untrusted-comment preset (safe-scheme links only).
  • Links: absolute http/https only, max 8, rendered with rel="me nofollow ugc".
  • Avatar: uploads go through media.Ingest (re-encode, metadata strip, content-address); the profile stores the canonical URL media returns. Enabled only when both media stores are configured. Fallback is a deterministic SVG identicon derived from the handle, served with nosniff + default-src 'none' (no seed content is echoed into the SVG).
  • Card: Module.Card(ctx, userKey) renders the embeddable avatar+name unit for forum posts, rosters, and bylines.
  • CSRF: bundled same-origin guard (faq's pattern), failing closed without Origin/Referer.

Open questions from #52, as resolved here

  • display_name: seeded from the resolver claim on first visit, user-owned after first save.
  • handle policy: immutable once claimed, admin override via the same form.
  • profile visibility: left to hosts (no built-in flag), per the issue's lean.

Testing

  • Handler tests over an in-memory store fake: auth gates, CSRF (cross-origin + headerless), claim/immutability/reservation/uniqueness, link validation, bio sanitization, card escaping, identicon headers.
  • module_test.go end-to-end against Postgres (gated on TEST_DATABASE_URL): full save/view cycle, cross-user uniqueness, card, identicon, migration idempotence.
  • Integration module: shared-database coexistence with contact, plus Postgres store tests (upsert round-trips, claim-once semantics, DB-constraint uniqueness).
  • All run locally against pgvector/pg17 (the CI image): module, handler, and integration tests pass; golangci-lint 0 issues; govulncheck clean; task build across all modules.

Closes #52

🤖 Generated with Claude Code

matthewjhunter and others added 4 commits June 9, 2026 14:59
New mountable component owning handle, display name, bio, avatar URL, and
bio links, keyed by an opaque host-supplied user key (the host's users
table stays the host's FK hub). This commit adds the module scaffold, the
goose migration (profile_goose_db_version), the sqlc-generated queries,
the store with claim-once handle semantics, and the host-facing resolver
types in profileuser.

Handles are lowercase-normalized text with a plain UNIQUE constraint
rather than citext, so the component never needs CREATE EXTENSION.

#52

Co-Authored-By: Claude Fable 5 <[email protected]>
Handlers follow the timeline/faq pattern: host-supplied resolver
middleware, same-origin CSRF guard failing closed, pages rendered through
infodancer/ui's ui/document with a host Chrome hook. Bio markdown is
sanitized at render time via ui/markdown's untrusted-comment preset;
links render with rel="me nofollow ugc". The identicon endpoint serves a
deterministic SVG built only from hash-derived integers, with nosniff and
default-src 'none' headers. Avatar upload goes through an injected ingest
hook so the media pipeline is substitutable in tests.

Tested against an in-memory store fake: auth gates, CSRF, handle
claim/immutability/reservations, link validation, sanitization, card
escaping.

#52

Co-Authored-By: Claude Fable 5 <[email protected]>
Config mirrors the suite conventions (DB + Resolver required, BasePath,
Chrome, CSRF, AutoMigrate) and wires avatar uploads to media.Ingest when
both media stores are configured, storing the canonical URL media
returns. Module.Card exposes the embeddable avatar+name unit;
Module.Store exposes the data layer for host-side seeding during
migrations from bespoke schemas.

The end-to-end module test (gated on TEST_DATABASE_URL) drives a full
save/view cycle, cross-user handle uniqueness, the card, the identicon,
and migration idempotence against real Postgres.

#52

Co-Authored-By: Claude Fable 5 <[email protected]>
Adds profile to go.work, the root Taskfile module list, and the CI
matrix. The integration module gains shared-database coexistence checks
(prefixed table + dedicated goose version table alongside contact's) and
Postgres store tests covering upsert round-trips, claim-once handle
semantics, cross-user uniqueness via the DB constraint, and avatar
updates.

#52

Co-Authored-By: Claude Fable 5 <[email protected]>
@matthewjhunter
matthewjhunter merged commit ac56daf into main Jun 9, 2026
31 checks passed
@matthewjhunter
matthewjhunter deleted the feature/52 branch June 9, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

profile: new component for the public persona (handle, display name, bio, avatar, links)

1 participant