oficina / mapa Public

Phase 1 step 3: the page is the window — kicker, large title, borderless Markdown writing, links at the foot

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Human

Prompt

Phase 1 step 3 of the Mapa level-up (spec section 12): full window, the kicker line and the title, the restyled textarea screen, the draft bar.

From this commit's own message. The prompt ledger has no entries for it — which is what a squashed, rebased or amended commit looks like, and what every commit looks like in a repo without a ledger.

Summary

Team pages, daily notes, scratch and the editor screen share one doc head: a kicker (Team page / Your note / Scratch, Edited by who and when, Also called, Edit) over a 2.5rem title; daily notes show the year quieter and carry the day pill on phones. The body is no longer a card; the textarea is borderless at the page's measure with its label for screen readers only; backlinks and mentions sit at the foot after a rule; the unsaved-changes offer is a bar. LastEditOf reads the revision store's plaintext row only.
Agent notes
Rename still goes through the existing /links confirm page rather than an in-page notice (departure to report). The renderer changes of section 5 come with the spike branch. estilo's stacked title fit measures ~15px short in Chromium (scrollWidth of a zero-width input), clipping the last letter; not Mapa's to fix, reported.
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 9414f16fda981624a2186cdcb39386465a6d14ef parent 2187c2b
10 files changed, +253 −50
  • internal/mapa/funcs.go +45 −0
  • internal/mapa/handlers_pages.go +4 −0
  • internal/mapa/lastedit.go +62 −0
  • internal/mapa/static/frame.css +109 −4
  • internal/mapa/static/mapa.css +1 −7
  • internal/mapa/templates/day.html +4 −18
  • internal/mapa/templates/page.html +7 −17
  • internal/mapa/templates/page_edit.html +1 −2
  • internal/mapa/templates/partials.html +19 −1
  • internal/mapatest/pages_test.go +1 −1

CI passed — run details

CI log
=== vet ===
go vet ./...
go vet -tags browser ./internal/mapatest/
=== fmt ===
=== code ===
go tool rastrillo budget code
The base has no .rastrillo/code.txt: skipping the check that records only go down.
budget code: within the limits.
=== test ===
CGO_ENABLED=0 go test ./...
?   	amadan.net/oficina/mapa/cmd/mapa	[no test files]
ok  	amadan.net/oficina/mapa/internal/mapa	0.311s
?   	amadan.net/oficina/mapa/internal/mapa/icons	[no test files]
ok  	amadan.net/oficina/mapa/internal/mapa/markup	(cached)
ok  	amadan.net/oficina/mapa/internal/mapa/seal	(cached)
ok  	amadan.net/oficina/mapa/internal/mapatest	7.946s
?   	amadan.net/oficina/mapa/scripts/mutate	[no test files]
?   	amadan.net/oficina/mapa/scripts/preview	[no test files]
=== migration-check ===
go tool rastrillo migration check
rastrillo migration check: models and migrations agree
diff --git a/internal/mapa/funcs.go b/internal/mapa/funcs.go
index 22dfbbb..627ab9b 100644
--- a/internal/mapa/funcs.go
+++ b/internal/mapa/funcs.go
@@ -15,6 +15,10 @@ var templateFuncs = template.FuncMap{
"longDate": longDate,
"shortDate": shortDate,
"saveStatus": saveStatus,
+ "editedWhen": editedWhen,
+ "dayTitle": dayTitle,
+ "dayYear": dayYear,
+ "dayPillOf": dayPillOf,
}
// ago is a past moment in words, for a <time> whose title carries the
@@ -70,3 +74,44 @@ func saveStatus() savestatus.Data {
Saving: "Saving…", Retrying: "Retrying…", Failed: "Not saved",
Label: "Save status"}
}
+
+// editedWhen is the kicker's time: "at 11:40" today, "yesterday", or
+// "on 12 November".
+func editedWhen(when time.Time) string {
+ now := time.Now().In(when.Location())
+ switch {
+ case sameDay(when, now):
+ return "at " + when.Format("15:04")
+ case sameDay(when, now.AddDate(0, 0, -1)):
+ return "yesterday"
+ case when.Year() == now.Year():
+ return "on " + when.Format("2 January")
+ }
+ return "on " + when.Format("2 January 2006")
+}
+
+func sameDay(one, other time.Time) bool {
+ return one.Year() == other.Year() && one.YearDay() == other.YearDay()
+}
+
+// dayTitle and dayYear are a daily note's title, the year set apart
+// and quieter: "Saturday 14 November" and "2026".
+func dayTitle(iso string) string {
+ day, err := time.Parse(time.DateOnly, iso)
+ if err != nil {
+ return iso
+ }
+ return day.Format("Monday 2 January")
+}
+
+func dayYear(iso string) string {
+ day, err := time.Parse(time.DateOnly, iso)
+ if err != nil {
+ return ""
+ }
+ return day.Format("2006")
+}
+
+func dayPillOf(date, today, prev, next string) *dayPill {
+ return &dayPill{Date: date, Today: today, Prev: prev, Next: next}
+}
diff --git a/internal/mapa/handlers_pages.go b/internal/mapa/handlers_pages.go
index 4414955..0300f7c 100644
--- a/internal/mapa/handlers_pages.go
+++ b/internal/mapa/handlers_pages.go
@@ -94,6 +94,10 @@ func (app *app) showPage(writer http.ResponseWriter,
return
}
data["Editing"] = editing
+ if last, ok, err := app.store.LastEditOf(request.Context(), viewer,
+ page.ID); err == nil && ok {
+ data["Last"] = &last
+ }
app.show(writer, request, http.StatusOK, "page", view{Title: page.Label,
Nav: nav(navFor(page.Kind)), Viewer: viewer, Data: data,
Chrome: &pageChrome{Page: &page, Editing: editing}})
diff --git a/internal/mapa/lastedit.go b/internal/mapa/lastedit.go
new file mode 100644
index 0000000..3e8a9e7
--- /dev/null
+++ b/internal/mapa/lastedit.go
@@ -0,0 +1,62 @@
+package mapa
+
+import (
+ "context"
+ "errors"
+ "strings"
+ "time"
+
+ "gorm.io/gorm"
+)
+
+// LastEdit is who saved a page's current revision and when: the
+// kicker's "Edited by Ana at 11:40" (level-up spec §4.1). It reads the
+// revision store's plaintext row only (base §4), never a body.
+type LastEdit struct {
+ Who string
+ At time.Time
+}
+
+// LastEditOf is the page's newest revision in the window, for a viewer
+// who may open the page; ok is false when the window holds none.
+func (store *Store) LastEditOf(ctx context.Context, viewer Viewer,
+ pageID int64) (LastEdit, bool, error) {
+ page, err := store.readable(ctx, viewer, pageID)
+ if err != nil {
+ return LastEdit{}, false, err
+ }
+ var row Revision
+ err = store.database.WithContext(ctx).Where("page_id = ? AND "+
+ "revision = ? AND at > ?", pageID, page.Revision,
+ store.now().UTC().Add(-HistoryWindow)).First(&row).Error
+ if errors.Is(err, gorm.ErrRecordNotFound) {
+ return LastEdit{}, false, nil
+ }
+ if err != nil {
+ return LastEdit{}, false, err
+ }
+ who := "you"
+ if row.ActorID != viewer.MemberID {
+ address, err := store.MemberAddress(ctx, row.ActorID)
+ if err != nil {
+ return LastEdit{}, false, err
+ }
+ who = personName(address)
+ }
+ at := row.At
+ if viewer.TimeZone != nil {
+ at = at.In(viewer.TimeZone)
+ }
+ return LastEdit{Who: who, At: at}, true, nil
+}
+
+// personName is how Mapa names a teammate in passing: the address's
+// local part ("ana" for ana@example.com). The full address stays in the
+// account menu and history.
+func personName(address string) string {
+ local, _, _ := strings.Cut(address, "@")
+ if local == "" {
+ return address
+ }
+ return local
+}
diff --git a/internal/mapa/static/frame.css b/internal/mapa/static/frame.css
index b9d29a7..447bdec 100644
--- a/internal/mapa/static/frame.css
+++ b/internal/mapa/static/frame.css
@@ -36,10 +36,6 @@ body {
@media (max-width: 79.99rem) {
[mapa-app]:not([data-side]) { --mapa-side-w: var(--mapa-rail-w); }
}
-@media (max-width: 799.98px) {
- [mapa-app] { grid-template-columns: minmax(0, 1fr); }
- [mapa-side] { display: none; }
-}
[mapa-main] { min-inline-size: 0; }
[mapa-doc] {
@@ -264,3 +260,112 @@ dialog[mapa-dialog]::backdrop { background: rgb(15 18 25 / 0.35); }
[mapa-dialog-head] h2 { margin: 0; font-size: 1rem; }
dl[mapa-keys] { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0; }
dl[mapa-keys] dd { margin: 0; color: var(--rst-text-muted); }
+
+/* ── The page (§4.1): the window is the page. A quiet kicker, a large
+ title, then the writing; no card, no label. ── */
+[mapa-page-head] { display: block; margin: 0 0 24px; }
+[mapa-doc-kicker] {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 6px 14px;
+ margin: 0 0 14px;
+ color: var(--rst-text-muted);
+ font-size: 13px;
+}
+[mapa-doc-kicker] > span { display: inline-flex; align-items: center; gap: 6px; }
+[mapa-doc-kicker] svg { inline-size: 14px; block-size: 14px; }
+[mapa-doc-edit] {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ color: var(--rst-text-muted);
+ font-weight: 600;
+ text-decoration: none;
+}
+[mapa-doc-edit]:hover { color: var(--rst-text); }
+[mapa-phone-only] { display: none !important; }
+@media (max-width: 799.98px) {
+ [mapa-phone-only] { display: inline-flex !important; }
+}
+h1[mapa-title] {
+ margin: 0;
+ font-size: 2.5rem;
+ line-height: 1.08;
+ font-weight: 720;
+ letter-spacing: -0.025em;
+ text-wrap: balance;
+ overflow-wrap: anywhere;
+}
+[mapa-title-faint] { color: var(--rst-text-faint, var(--rst-text-muted)); font-weight: 500; }
+@media (max-width: 799.98px) {
+ h1[mapa-title] { font-size: 1.875rem; }
+}
+[mapa-sr] {
+ position: absolute;
+ clip-path: inset(50%);
+ inline-size: 1px;
+ block-size: 1px;
+ overflow: hidden;
+ white-space: nowrap;
+}
+[mapa-empty] { color: var(--rst-text-muted); }
+
+/* The Markdown editor (Phase 1's writing surface): the page's own
+ face and measure, borderless, no label. */
+textarea[mapa-editor] {
+ box-sizing: border-box;
+ inline-size: 100%;
+ min-block-size: 50vh;
+ padding: 0;
+ border: 0;
+ border-radius: 0;
+ background: transparent;
+ color: var(--rst-text);
+ font: 400 16px/1.7 var(--rst-font);
+ resize: none;
+ field-sizing: content;
+ caret-color: var(--rst-accent);
+ box-shadow: none;
+}
+textarea[mapa-editor]:focus { outline: none; box-shadow: none; }
+[mapa-edit-form] [rst-field-hint] { display: none; }
+
+/* What links here, at the page's foot whenever the panel is not there
+ (§3.3): after a quiet break, like a reference list. */
+[mapa-foot-refs] {
+ display: grid;
+ gap: 30px;
+ margin-block-start: 72px;
+ padding-block-start: 28px;
+ border-block-start: 1px solid var(--rst-line);
+}
+[mapa-foot-refs] h2 {
+ margin: 0 0 6px;
+ color: var(--rst-text-muted);
+ font-size: 12px;
+ font-weight: 650;
+}
+
+/* The unsaved-changes offer, as a bar above the page. */
+[mapa-unsaved] {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 8px 12px;
+ margin: 0 0 20px;
+ padding: 10px 14px;
+ border: 1px solid var(--rst-line);
+ border-radius: 12px;
+ background: var(--rst-surface-2);
+ font-size: 14px;
+}
+[mapa-unsaved] p { margin: 0; flex: 1 1 16rem; }
+
+
+/* Below 800px there is no sidebar: its places are rows in estilo's
+ Menu sheet. Last, so it wins over [mapa-side]'s own display. */
+@media (max-width: 799.98px) {
+ [mapa-app] { grid-template-columns: minmax(0, 1fr); }
+ [mapa-side] { display: none; }
+}
diff --git a/internal/mapa/static/mapa.css b/internal/mapa/static/mapa.css
index 129e2c9..518cf6f 100644
--- a/internal/mapa/static/mapa.css
+++ b/internal/mapa/static/mapa.css
@@ -41,13 +41,7 @@
gap: var(--rst-sp-2);
}
[mapa-body] {
- background: var(--rst-surface);
- border: 1px solid var(--rst-line);
- border-radius: var(--rst-radius);
- box-shadow: var(--rst-shadow-lift);
- padding: var(--rst-sp-4) var(--rst-sp-5);
- margin-block: var(--rst-sp-4);
- line-height: 1.65;
+ line-height: 1.7;
overflow-wrap: anywhere;
}
[mapa-body] > :first-child { margin-block-start: 0; }
diff --git a/internal/mapa/templates/day.html b/internal/mapa/templates/day.html
index 573ac1e..a655453 100644
--- a/internal/mapa/templates/day.html
+++ b/internal/mapa/templates/day.html
@@ -1,15 +1,5 @@
{{define "content"}}{{$d := .Data}}{{$page := $d.Page}}
-<header mapa-page-head>
-<div>
-<h1>{{longDate $page.Date}}</h1>
-<p mapa-meta>{{if eq $page.Date $d.Today}}Today's note.{{else}}Your daily note.{{end}} Only you can open it.</p>
-</div>
-<nav mapa-actions aria-label="Days">
-<a rst-btn href="/d/{{$d.Prev}}" aria-label="Previous day">← {{$d.Prev}}</a>
-{{if ne $page.Date $d.Today}}<a rst-btn href="/">Today</a>{{end}}
-<a rst-btn href="/d/{{$d.Next}}" aria-label="Next day">{{$d.Next}} →</a>
-</nav>
-</header>
+{{template "mapa-doc-head" dict "Page" $page "Edit" (or (and $d.Written (not $d.Editing) (printf "/d/%s/edit" $page.Date)) "") "Day" (dayPillOf $page.Date $d.Today $d.Prev $d.Next)}}
{{template "notice" $d.Notice}}
{{with $d.Draft}}{{template "mapa-unsaved" dict "Draft" . "Save" (printf "/d/%s/draft/save" $page.Date) "Discard" (printf "/d/%s/draft/discard" $page.Date)}}{{end}}
{{range $d.Orphans}}<div mapa-unsaved role="status"><p><strong>You have unsaved changes to a page that was deleted.</strong></p><form method="post" action="/p/{{.Public}}/draft/scratch"><button rst-btn="primary" type="submit">Save as a scratch page</button></form><form method="post" action="/p/{{.Public}}/draft/discard"><input type="hidden" name="version" value="{{.Version}}"><button rst-btn type="submit">Discard</button></form></div>{{end}}
@@ -23,13 +13,9 @@
{{if not $d.Written}}<p mapa-meta>Nothing is saved until you write something and save it.</p>{{end}}
</form>
{{else}}
-<nav mapa-actions aria-label="Note actions">
-<a rst-btn="primary" href="/d/{{$page.Date}}/edit">{{icon "pencil"}} Edit</a>
-<a rst-btn href="/p/{{$page.Public}}/share">Make team page</a>
-<a rst-btn href="/p/{{$page.Public}}/history">{{icon "history"}} History</a>
-<a rst-btn href="/p/{{$page.Public}}/delete">{{icon "trash-2"}} Delete</a>
-</nav>
<article mapa-body>{{$page.HTML}}</article>
{{end}}
-{{template "mapa-linked" dict "ID" "backlinks" "Heading" "Linked from" "Items" $page.Backlinks "Empty" "No page links to this day." "Target" 0}}
+<footer mapa-foot-refs>
+{{template "mapa-linked" dict "ID" "backlinks" "Heading" "Linked from" "Items" $page.Backlinks "Empty" "No page links to this day yet. A date link in any of your pages lands here." "Target" 0}}
+</footer>
{{end}}
diff --git a/internal/mapa/templates/page.html b/internal/mapa/templates/page.html
index 164e7bd..1fb8a78 100644
--- a/internal/mapa/templates/page.html
+++ b/internal/mapa/templates/page.html
@@ -1,24 +1,14 @@
-{{define "content"}}{{$page := .Data.Page}}
-<header mapa-page-head>
-<h1>{{$page.Label}}</h1>
-<nav mapa-actions aria-label="Page actions">
-<a rst-btn="primary" href="{{$page.Href}}/edit">{{icon "pencil"}} Edit</a>
-{{if eq $page.Kind "page"}}<a rst-btn href="/p/{{$page.Public}}/rename">Rename</a>{{end}}
-{{if eq $page.Rung "private"}}<a rst-btn href="/p/{{$page.Public}}/share">Make team page</a>{{end}}
-<a rst-btn href="/p/{{$page.Public}}/history">{{icon "history"}} History</a>
-{{if eq $page.Kind "page"}}<a rst-btn href="/p/{{$page.Public}}/blocks">Link to a block</a>{{end}}
-<a rst-btn href="/p/{{$page.Public}}/delete">{{icon "trash-2"}} Delete</a>
-</nav>
-</header>
-{{template "notice" .Data.Notice}}
-{{with .Data.Draft}}{{template "mapa-unsaved" dict "Draft" . "Save" (printf "/p/%s/draft/save" $page.Public) "Discard" (printf "/p/%s/draft/discard" $page.Public)}}{{end}}
-{{template "mapa-editing" .Data.Editing}}
-{{with $page.Aliases}}<p mapa-meta>Also called {{range $i, $a := .}}{{if $i}}, {{end}}{{$a.Title}}{{end}}</p>{{end}}
+{{define "content"}}{{$d := .Data}}{{$page := $d.Page}}
+{{template "mapa-doc-head" dict "Page" $page "Last" $d.Last "Edit" (printf "%s/edit" $page.Href)}}
+{{template "notice" $d.Notice}}
+{{with $d.Draft}}{{template "mapa-unsaved" dict "Draft" . "Save" (printf "/p/%s/draft/save" $page.Public) "Discard" (printf "/p/%s/draft/discard" $page.Public)}}{{end}}
<article mapa-body>
-{{if $page.Body}}{{$page.HTML}}{{else}}<p mapa-meta>This page is empty. <a href="{{$page.Href}}/edit">Write something</a>.</p>{{end}}
+{{if $page.Body}}{{$page.HTML}}{{else}}<p mapa-empty>This page is empty. <a href="{{$page.Href}}/edit">Write something</a>.</p>{{end}}
</article>
+<footer mapa-foot-refs>
{{template "mapa-linked" dict "ID" "backlinks" "Heading" "Linked from" "Items" $page.Backlinks "Empty" "Nothing links here yet." "Target" 0}}
{{if eq $page.Kind "page"}}
{{template "mapa-linked" dict "ID" "mentions" "Heading" "Mentioned without a link" "Items" $page.Mentions "Empty" "No unlinked mentions." "Target" $page.Public}}
{{end}}
+</footer>
{{end}}
diff --git a/internal/mapa/templates/page_edit.html b/internal/mapa/templates/page_edit.html
index a099213..4281828 100644
--- a/internal/mapa/templates/page_edit.html
+++ b/internal/mapa/templates/page_edit.html
@@ -1,6 +1,5 @@
{{define "content"}}{{$page := .Data.Page}}
-{{template "back-nav" dict "Href" $page.Href "Label" $page.Label}}
-<h1>{{$page.Label}}</h1>
+{{template "mapa-doc-head" dict "Page" $page "Edit" ""}}
{{template "notice" .Data.Notice}}
<form rst-form method="post" action="{{.Data.Action}}" mapa-edit-form data-drafts="{{.Data.Drafts}}" data-version="{{.Data.Version}}">
<input type="hidden" name="revision" value="{{.Data.Revision}}">
diff --git a/internal/mapa/templates/partials.html b/internal/mapa/templates/partials.html
index cfef14b..f06b118 100644
--- a/internal/mapa/templates/partials.html
+++ b/internal/mapa/templates/partials.html
@@ -20,7 +20,7 @@
{{/* mapa-editor: the scriptless editor. Keys: Body, Error. */}}
{{define "mapa-editor"}}
<div rst-field>
-<label rst-field-label for="body">Text</label>
+<label rst-field-label mapa-sr for="body">Page text</label>
<textarea rst-textarea mapa-editor id="body" name="body" rows="18" spellcheck="true"{{if .Error}} aria-invalid="true" aria-describedby="body-error"{{end}}>{{.Body}}</textarea>
<small rst-field-hint>Markdown. Link a page with [[Its title]]; a date like [[2026-11-12]] opens your own daily note.</small>
{{if .Error}}<small rst-field-error id="body-error" role="alert">{{.Error}}</small>{{end}}
@@ -39,3 +39,21 @@
{{/* mapa-editing: "Ana is editing", team pages only (§5). */}}
{{define "mapa-editing"}}{{with .}}<p mapa-meta mapa-editing>{{range $i, $who := .}}{{if $i}}, {{end}}{{$who}}{{end}} {{if eq (len .) 1}}is{{else}}are{{end}} editing this page.</p>{{end}}{{end}}
+
+{{/* mapa-doc-head: the page's kicker and its large title (level-up
+ §4.1). The kicker says what kind of page this is and who can open
+ it; Edit opens the Markdown editor (Phase 1's writing surface).
+ Keys: Page (PageView), Last (*LastEdit or nil), Edit (href, or ""
+ on the editor itself), Day (*dayPill, daily notes). */}}
+{{define "mapa-doc-head"}}{{$page := .Page}}<header mapa-page-head>
+<p mapa-doc-kicker>
+{{- if eq $page.Kind "page"}}<span>{{icon "users"}}Team page</span>
+{{- else if eq $page.Kind "daily"}}<span>{{icon "lock"}}Your note. Only you can open it.</span>
+{{- else}}<span>{{icon "lock"}}Scratch. Only you can open it.</span>{{end}}
+{{- with .Last}}<span>Edited by {{.Who}} {{editedWhen .At}}</span>{{end}}
+{{- with $page.Aliases}}<span>Also called {{range $i, $a := .}}{{if $i}}, {{end}}{{$a.Title}}{{end}}</span>{{end}}
+{{- with .Edit}}<span mapa-actions><a mapa-doc-edit href="{{.}}">{{icon "pencil"}}Edit</a></span>{{end}}
+{{- with .Day}}<span mapa-phone-only>{{template "mapa-day-pill" .}}</span>{{end}}
+</p>
+<h1 mapa-title>{{if eq $page.Kind "daily"}}{{dayTitle $page.Date}}<span mapa-title-faint> {{dayYear $page.Date}}</span>{{else}}{{$page.Label}}{{end}}</h1>
+</header>{{end}}
diff --git a/internal/mapatest/pages_test.go b/internal/mapatest/pages_test.go
index 1550089..1f0b0f9 100644
--- a/internal/mapatest/pages_test.go
+++ b/internal/mapatest/pages_test.go
@@ -33,7 +33,7 @@ func TestATeamPageIsCreatedReadAndEditedByEveryone(t *testing.T) {
rig := newRig(t)
acme := rig.createPage(t, Ana, "Acme", "Customer since 2024.")
body := rig.page(t, Bo, acme)
- if !strings.Contains(body, "<h1>Acme</h1>") ||
+ if !strings.Contains(body, "<h1 mapa-title>Acme</h1>") ||
!strings.Contains(body, "Customer since 2024.") {
t.Fatalf("Bo cannot read Ana's team page:\n%s", body)
}