oficina / mapa Public

Phase 1 steps 4 and 5: the Links panel with its map, and day navigation with the month

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

Prompt

Phase 1 steps 4 and 5 of the Mapa level-up (spec section 12): the scoped accessor and L6's mutation; the lists and the map; the foot fallback, the phone sheet, and the week on daily notes; the day pill and the calendar.

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

A floating Links panel (Docs' inspector glass, 312px, cookie mapa-links, open by default) holds Around this page (a server-drawn SVG map: linked, not written and mentioned edges drawn solid, dashed and dotted; at most 12 neighbours; a role=img label in words), Linked from with each block, Mentioned without a link with Link it, and Links out as chips. On daily notes it is This week first. Between 800px and 64rem and with the panel off the lists sit at the page's foot; on phones it is a sheet with a peek line. The day pill's middle opens a server-rendered month (details, ?month= paging). Everything new reads through one scoped accessor (around.go); make mutate has a mutation that strips its scope, and gate 1 catches it (10 of 10).
Agent notes
The phone sheet is a script enhancement over the foot lists rather than a modal dialog; the toggle and sheet live in links.js.
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 15d9fbecb6094e79428b611d238f928970f6e7ee parent 9414f16
18 files changed, +973 −27
  • internal/mapa/around.go +188 −0
  • internal/mapa/calendar.go +118 −0
  • internal/mapa/calendar_test.go +51 −0
  • internal/mapa/frame.go +2 −1
  • internal/mapa/funcs.go +0 −5
  • internal/mapa/handlers_pages.go +1 −1
  • internal/mapa/mapview.go +126 −0
  • internal/mapa/static/links.css +275 −0
  • internal/mapa/static/links.js +61 −0
  • internal/mapa/templates/day.html +3 −1
  • internal/mapa/templates/frame.html +78 −4
  • internal/mapa/templates/page.html +2 −0
  • internal/mapa/templates/partials.html +2 −2
  • internal/mapa/templates/shell.html +2 −0
  • internal/mapa/today.go +29 −2
  • internal/mapa/views.go +15 −9
  • internal/mapatest/gate1_test.go +8 −2
  • scripts/mutate/mutations.go +12 −0

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.351s
?   	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	9.177s
?   	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/around.go b/internal/mapa/around.go
new file mode 100644
index 0000000..c35d781
--- /dev/null
+++ b/internal/mapa/around.go
@@ -0,0 +1,188 @@
+package mapa
+
+import (
+ "sort"
+
+ "amadan.net/oficina/mapa/internal/mapa/markup"
+)
+
+// What is around a page (level-up spec §4.3): the Links panel's links
+// out and its map. Every read goes through scoped, the one accessor the
+// level-up's read paths share, so a page the viewer may not open is
+// never a node, an edge, a chip or a count (base §3.3, gate 1, L6).
+
+// scoped is the index as one scope sees it. The caller holds the read
+// lock for as long as it uses one.
+type scoped struct {
+ index *Index
+ scope Scope
+}
+
+func (index *Index) in(scope Scope) scoped {
+ return scoped{index: index, scope: scope}
+}
+
+// page is a page the scope may open, or nil.
+func (view scoped) page(pageID int64) *entry {
+ page := view.index.pages[pageID]
+ if page == nil || !view.scope.sees(page) {
+ return nil
+ }
+ return page
+}
+
+// target is where a [[link]]'s text leads for this scope: a team page,
+// or the scope's own note for a date; nil for a pending link.
+func (view scoped) target(text string) *entry {
+ if markup.IsDateShaped(text) {
+ if view.scope.Member == 0 {
+ return nil
+ }
+ return view.page(view.index.days[view.scope.Member][text])
+ }
+ return view.page(view.index.titles[Fold(text)])
+}
+
+// wroteOn reports whether the scope has its own note for a date.
+func (view scoped) wroteOn(date string) bool {
+ if view.scope.Member == 0 {
+ return false
+ }
+ return view.page(view.index.days[view.scope.Member][date]) != nil
+}
+
+// Chip is one link out, as the panel lists it.
+type Chip struct {
+ Label, Href string
+ // Kind is "team", "pending" or "date".
+ Kind string
+}
+
+// Around is the panel's own data: links out and the map. Backlinks and
+// mentions are the PageView's, already scoped.
+type Around struct {
+ Out []Chip
+ Map MapView
+}
+
+// linksOut is each distinct link a page types, in body order: team
+// pages, pending titles and dates. A date that is no date is left out.
+func (view scoped) linksOut(page *entry) []Chip {
+ seen := map[string]bool{}
+ var out []Chip
+ for _, link := range page.links {
+ fold := Fold(link.Target)
+ if seen[fold] {
+ continue
+ }
+ seen[fold] = true
+ if chip, ok := view.chip(link.Target); ok {
+ out = append(out, chip)
+ }
+ }
+ return out
+}
+
+func (view scoped) chip(text string) (Chip, bool) {
+ if markup.IsDateShaped(text) {
+ if !markup.IsDate(text) {
+ return Chip{}, false
+ }
+ return Chip{Label: dayTitle(text), Href: "/d/" + text,
+ Kind: "date"}, true
+ }
+ if target := view.target(text); target != nil {
+ return Chip{Label: target.label(), Href: target.href(),
+ Kind: "team"}, true
+ }
+ return Chip{Label: text, Href: pendingHref(text), Kind: "pending"},
+ true
+}
+
+// neighbour is one page on the map before it is placed.
+type neighbour struct {
+ page *entry // nil for a pending title
+ label string
+ href string
+ // kind is "linked", "pending" or "mentioned".
+ kind string
+ sort string
+}
+
+// mapNeighbours is the map's ring (§4.3): linked pages first (both
+// ways, by public id), then titles not written yet, then pages that
+// mention this one, at most mapCap of them.
+func (view scoped) mapNeighbours(page *entry, backlinks,
+ mentions []Linked) []neighbour {
+ have := map[int64]bool{page.id: true}
+ var linked, pending, mentioned []neighbour
+ addPage := func(found *entry, kind string, into *[]neighbour) {
+ if found == nil || have[found.id] {
+ return
+ }
+ have[found.id] = true
+ *into = append(*into, neighbour{page: found, label: found.label(),
+ href: found.href(), kind: kind, sort: publicID(found.nonce)})
+ }
+ for _, link := range backlinks {
+ addPage(view.page(link.ID), "linked", &linked)
+ }
+ pendingSeen := map[string]bool{}
+ for _, link := range page.links {
+ if markup.IsDateShaped(link.Target) {
+ continue
+ }
+ if found := view.target(link.Target); found != nil {
+ addPage(found, "linked", &linked)
+ } else if fold := Fold(link.Target); !pendingSeen[fold] {
+ pendingSeen[fold] = true
+ pending = append(pending, neighbour{label: link.Target,
+ href: pendingHref(link.Target), kind: "pending",
+ sort: fold})
+ }
+ }
+ for _, link := range mentions {
+ addPage(view.page(link.ID), "mentioned", &mentioned)
+ }
+ return capRing(linked, pending, mentioned)
+}
+
+// mapCap is how many neighbours the map draws. Past it there is no node
+// and no count: the lists below the map are complete (§4.3).
+const mapCap = 12
+
+func capRing(groups ...[]neighbour) []neighbour {
+ var ring []neighbour
+ for _, group := range groups {
+ sort.SliceStable(group, func(left, right int) bool {
+ return group[left].sort < group[right].sort
+ })
+ ring = append(ring, group...)
+ }
+ if len(ring) > mapCap {
+ ring = ring[:mapCap]
+ }
+ return ring
+}
+
+// links reports whether one page on the ring links to another, by the
+// text it typed. Both are in scope, or they would not be on the ring.
+func (view scoped) links(from, to *entry) bool {
+ if from == nil || to == nil {
+ return false
+ }
+ targets := to.targetFolds()
+ for _, link := range from.links {
+ if targets[Fold(link.Target)] && view.target(link.Target) == to {
+ return true
+ }
+ }
+ return false
+}
+
+// around is the panel's data for a page the scope sees.
+func (view scoped) around(page *entry, backlinks,
+ mentions []Linked) *Around {
+ ring := view.mapNeighbours(page, backlinks, mentions)
+ return &Around{Out: view.linksOut(page), Map: view.mapOf(page, ring)}
+}
diff --git a/internal/mapa/calendar.go b/internal/mapa/calendar.go
new file mode 100644
index 0000000..2193b25
--- /dev/null
+++ b/internal/mapa/calendar.go
@@ -0,0 +1,118 @@
+package mapa
+
+import (
+ "context"
+ "time"
+)
+
+// Day navigation (level-up spec §4.4): the week strip on a daily note's
+// Links panel and the month calendar. Weeks start on Monday. A dot is a
+// day the viewer wrote a note, read from their own partition only, so
+// nobody else's writing ever shows as a dot.
+
+// CalendarDay is one day in the week strip or the month.
+type CalendarDay struct {
+ Date, Letter, Number string
+ // Wrote: the viewer has a note for the day. Today and Current are
+ // today and the day on screen. Outside is a day of the month before
+ // or after.
+ Wrote, Today, Current, Outside bool
+}
+
+// WeekView is the strip: seven days and the weeks either side.
+type WeekView struct {
+ Days []CalendarDay
+ Prev, Next string
+ // Month names the month the day on screen is in ("November").
+ Month string
+}
+
+// MonthView is the calendar: six rows of seven days, and the months
+// either side as ?month= values.
+type MonthView struct {
+ Title string
+ Weeks [][]CalendarDay
+ Prev, Next string
+ Date, Today string
+}
+
+// Week is the strip for the week holding date.
+func (index *Index) Week(ctx context.Context, scope Scope, date,
+ today string) (WeekView, error) {
+ day, err := time.Parse(time.DateOnly, date)
+ if err != nil {
+ return WeekView{}, err
+ }
+ if err := index.Sync(ctx); err != nil {
+ return WeekView{}, err
+ }
+ index.mutex.RLock()
+ defer index.mutex.RUnlock()
+ view := index.in(scope)
+ monday := mondayOf(day)
+ week := WeekView{Prev: iso(day.AddDate(0, 0, -7)),
+ Next: iso(day.AddDate(0, 0, 7)), Month: day.Format("January")}
+ for offset := range 7 {
+ week.Days = append(week.Days, view.calendarDay(
+ monday.AddDate(0, 0, offset), date, today, day.Month()))
+ }
+ return week, nil
+}
+
+// Month is the calendar for month ("2006-01"), or for date's month when
+// month is empty or not a month.
+func (index *Index) Month(ctx context.Context, scope Scope, month, date,
+ today string) (MonthView, error) {
+ first, err := monthStart(month, date)
+ if err != nil {
+ return MonthView{}, err
+ }
+ if err := index.Sync(ctx); err != nil {
+ return MonthView{}, err
+ }
+ index.mutex.RLock()
+ defer index.mutex.RUnlock()
+ view := index.in(scope)
+ cal := MonthView{Title: first.Format("January 2006"), Date: date,
+ Today: today, Prev: first.AddDate(0, -1, 0).Format("2006-01"),
+ Next: first.AddDate(0, 1, 0).Format("2006-01")}
+ start := mondayOf(first)
+ for row := range 6 {
+ var week []CalendarDay
+ for column := range 7 {
+ week = append(week, view.calendarDay(
+ start.AddDate(0, 0, row*7+column), date, today,
+ first.Month()))
+ }
+ cal.Weeks = append(cal.Weeks, week)
+ }
+ return cal, nil
+}
+
+func (view scoped) calendarDay(day time.Time, date, today string,
+ month time.Month) CalendarDay {
+ at := iso(day)
+ return CalendarDay{Date: at, Letter: day.Format("Mon")[:1],
+ Number: day.Format("2"), Wrote: view.wroteOn(at),
+ Today: at == today, Current: at == date,
+ Outside: day.Month() != month}
+}
+
+func monthStart(month, date string) (time.Time, error) {
+ if first, err := time.Parse("2006-01", month); err == nil {
+ return first, nil
+ }
+ day, err := time.Parse(time.DateOnly, date)
+ if err != nil {
+ return time.Time{}, err
+ }
+ return time.Date(day.Year(), day.Month(), 1, 0, 0, 0, 0, time.UTC),
+ nil
+}
+
+// mondayOf is the Monday on or before day (Europe/Dublin's week).
+func mondayOf(day time.Time) time.Time {
+ return day.AddDate(0, 0, -((int(day.Weekday()) + 6) % 7))
+}
+
+func iso(day time.Time) string { return day.Format(time.DateOnly) }
diff --git a/internal/mapa/calendar_test.go b/internal/mapa/calendar_test.go
new file mode 100644
index 0000000..874d965
--- /dev/null
+++ b/internal/mapa/calendar_test.go
@@ -0,0 +1,51 @@
+package mapa
+
+import (
+ "strings"
+ "testing"
+ "time"
+)
+
+// Weeks start on Monday (level-up §4.4), whatever day they are asked
+// from.
+func TestWeeksStartOnMonday(t *testing.T) {
+ for date, want := range map[string]string{
+ "2026-11-14": "2026-11-09", "2026-11-09": "2026-11-09",
+ "2026-11-15": "2026-11-09", "2026-11-16": "2026-11-16",
+ } {
+ day, _ := time.Parse(time.DateOnly, date)
+ if got := iso(mondayOf(day)); got != want {
+ t.Errorf("mondayOf(%s) = %s, want %s", date, got, want)
+ }
+ }
+}
+
+// The map is the same drawing every time for the same ring, and says
+// itself in words for anyone who cannot see it (§4.3).
+func TestTheMapIsStableAndLabelled(t *testing.T) {
+ ring := []neighbour{{label: "Halden", href: "/p/a", kind: "linked"},
+ {label: "Pricing", href: "/new?title=Pricing", kind: "pending"},
+ {label: "Q4", href: "/p/b", kind: "mentioned"}}
+ here := &entry{kind: KindPage, rung: RungTeam,
+ record: Record{Title: "Acme"}}
+ view := (&Index{}).in(Scope{})
+ one, other := view.mapOf(here, ring), view.mapOf(here, ring)
+ if len(one.Nodes) != 3 || len(one.Edges) != 3 {
+ t.Fatalf("map: %d nodes, %d edges", len(one.Nodes), len(one.Edges))
+ }
+ for at := range one.Nodes {
+ if one.Nodes[at] != other.Nodes[at] {
+ t.Fatal("the same ring drew two maps")
+ }
+ node := one.Nodes[at]
+ if node.X < 0 || node.X > mapW || node.Y < 0 || node.Y > mapH {
+ t.Errorf("%s is off the map: %v,%v", node.Label, node.X, node.Y)
+ }
+ }
+ for _, words := range []string{"Acme", "Halden (linked)",
+ "Pricing (not written yet)", "Q4 (mentioned without a link)"} {
+ if !strings.Contains(one.Label, words) {
+ t.Errorf("the map's label lacks %q: %s", words, one.Label)
+ }
+ }
+}
diff --git a/internal/mapa/frame.go b/internal/mapa/frame.go
index b865606..355fabf 100644
--- a/internal/mapa/frame.go
+++ b/internal/mapa/frame.go
@@ -37,9 +37,10 @@ type pageChrome struct {
Links bool
}
-// dayPill is ‹ Today › on a daily note (§4.4).
+// dayPill is ‹ Today › on a daily note (§4.4), with its month.
type dayPill struct {
Date, Today, Prev, Next string
+ Month *MonthView
}
// leadView is the lead slot's data: presence, save status, the pill.
diff --git a/internal/mapa/funcs.go b/internal/mapa/funcs.go
index 627ab9b..5717efa 100644
--- a/internal/mapa/funcs.go
+++ b/internal/mapa/funcs.go
@@ -18,7 +18,6 @@ var templateFuncs = template.FuncMap{
"editedWhen": editedWhen,
"dayTitle": dayTitle,
"dayYear": dayYear,
- "dayPillOf": dayPillOf,
}
// ago is a past moment in words, for a <time> whose title carries the
@@ -111,7 +110,3 @@ func dayYear(iso string) string {
}
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 0300f7c..224c8d4 100644
--- a/internal/mapa/handlers_pages.go
+++ b/internal/mapa/handlers_pages.go
@@ -100,7 +100,7 @@ func (app *app) showPage(writer http.ResponseWriter,
}
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}})
+ Chrome: &pageChrome{Page: &page, Editing: editing, Links: true}})
}
// navFor is the rail entry a page belongs under.
diff --git a/internal/mapa/mapview.go b/internal/mapa/mapview.go
new file mode 100644
index 0000000..53b4ec3
--- /dev/null
+++ b/internal/mapa/mapview.go
@@ -0,0 +1,126 @@
+package mapa
+
+import (
+ "fmt"
+ "math"
+ "net/url"
+ "strings"
+)
+
+// The map (level-up spec §4.3): an SVG the server draws, with no
+// simulation. This page sits at the centre and its neighbours on a ring
+// around it, in a stable order, so the same page draws the same map.
+
+// MapView is the map's drawing.
+type MapView struct {
+ Here MapNode
+ Nodes []MapNode
+ Edges []MapEdge
+ // Label is the map's accessible name: what it shows, in words.
+ Label string
+}
+
+// MapNode is one circle and its label.
+type MapNode struct {
+ Label, Href string
+ // Kind is "here", "linked", "pending" or "mentioned".
+ Kind string
+ X, Y, LabelX, LabelY float64
+ // Anchor is the label's text-anchor.
+ Anchor string
+}
+
+// MapEdge is one line. Kind is "linked", "pending" or "mentioned".
+type MapEdge struct {
+ X1, Y1, X2, Y2 float64
+ Kind string
+}
+
+// The drawing's box and ring, in SVG units (viewBox 0 0 mapW mapH).
+const (
+ mapW, mapH = 284.0, 200.0
+ mapCX, mapCY = 142.0, 98.0
+ ringRX, ringRY = 104.0, 66.0
+ labelGap = 13.0
+ labelMargin = 34.0
+ firstAngleDegree = -150.0
+)
+
+// mapOf places the ring and draws its edges.
+func (view scoped) mapOf(page *entry, ring []neighbour) MapView {
+ drawing := MapView{Here: MapNode{Label: page.label(), Kind: "here",
+ X: mapCX, Y: mapCY, LabelX: mapCX, LabelY: mapCY - labelGap,
+ Anchor: "middle"}}
+ for at, near := range ring {
+ node := placed(near, at, len(ring))
+ drawing.Nodes = append(drawing.Nodes, node)
+ drawing.Edges = append(drawing.Edges, MapEdge{X1: mapCX, Y1: mapCY,
+ X2: node.X, Y2: node.Y, Kind: near.kind})
+ }
+ for one := range ring {
+ for other := range ring {
+ if one != other && view.links(ring[one].page, ring[other].page) &&
+ (one < other || !view.links(ring[other].page,
+ ring[one].page)) {
+ drawing.Edges = append(drawing.Edges, MapEdge{
+ X1: drawing.Nodes[one].X, Y1: drawing.Nodes[one].Y,
+ X2: drawing.Nodes[other].X, Y2: drawing.Nodes[other].Y,
+ Kind: "linked"})
+ }
+ }
+ }
+ drawing.Label = mapLabel(page.label(), ring)
+ return drawing
+}
+
+// placed puts the at-th of count neighbours on the ring, its label
+// outside the ring and inside the box.
+func placed(near neighbour, at, count int) MapNode {
+ angle := (firstAngleDegree + 360*float64(at)/float64(count)) *
+ math.Pi / 180
+ across := round1(mapCX + ringRX*math.Cos(angle))
+ down := round1(mapCY + ringRY*math.Sin(angle))
+ node := MapNode{Label: near.label, Href: near.href, Kind: near.kind,
+ X: across, Y: down, LabelX: across, Anchor: "middle"}
+ if down < mapCY {
+ node.LabelY = down - labelGap + 4
+ } else {
+ node.LabelY = down + labelGap + 4
+ }
+ switch {
+ case across < labelMargin:
+ node.Anchor = "start"
+ node.LabelX = across - 6
+ case across > mapW-labelMargin:
+ node.Anchor = "end"
+ node.LabelX = across + 6
+ }
+ return node
+}
+
+func round1(value float64) float64 { return math.Round(value*10) / 10 }
+
+// mapLabel says the map in words, for anyone who cannot see it.
+func mapLabel(here string, ring []neighbour) string {
+ if len(ring) == 0 {
+ return "A map of the pages around " + here +
+ ": nothing links here, and it links nowhere yet."
+ }
+ var names []string
+ for _, near := range ring {
+ names = append(names, near.label+" ("+mapKindWords[near.kind]+")")
+ }
+ return fmt.Sprintf("A map of the pages around %s: %s.", here,
+ strings.Join(names, ", "))
+}
+
+var mapKindWords = map[string]string{
+ "linked": "linked", "pending": "not written yet",
+ "mentioned": "mentioned without a link",
+}
+
+// pendingHref is where a link to a page not written yet goes: the new
+// page form, its title filled in (base §6).
+func pendingHref(text string) string {
+ return "/new?title=" + url.QueryEscape(text)
+}
diff --git a/internal/mapa/static/links.css b/internal/mapa/static/links.css
new file mode 100644
index 0000000..5097e70
--- /dev/null
+++ b/internal/mapa/static/links.css
@@ -0,0 +1,275 @@
+/* links.css: the Links panel, the map, the week strip and the month
+ * (level-up spec §4.3, §4.4). Docs' inspector recipe: glass, a rim, a
+ * soft shadow, much fainter in dark. Calma: only icons carry colour,
+ * and on the map only "here" does.
+ */
+
+/* ── The panel: from 64rem it floats at the inline end, under the bar.
+ Between 800px and 64rem it is not drawn and the page's foot holds the
+ same lists; below 800px it is a sheet with a peek line. ── */
+aside[mapa-links] {
+ --mapa-panel-w: 312px;
+ box-sizing: border-box;
+ position: fixed;
+ z-index: 20;
+ inset-block-start: calc(var(--mapa-bar-h) + 12px);
+ inset-inline-end: 12px;
+ inline-size: var(--mapa-panel-w);
+ max-block-size: calc(100dvh - var(--mapa-bar-h) - 24px);
+ overflow: auto;
+ overscroll-behavior: contain;
+ border: 1px solid transparent;
+ border-radius: 14px;
+ background:
+ linear-gradient(light-dark(rgb(255 255 255 / 0.92), rgb(32 35 43 / 0.92)) 0 0) padding-box,
+ linear-gradient(var(--rst-line) 0 0) border-box;
+ -webkit-backdrop-filter: blur(14px) saturate(1.3);
+ backdrop-filter: blur(14px) saturate(1.3);
+ box-shadow:
+ inset 0 1px 0 light-dark(rgb(255 255 255 / 0.9), rgb(255 255 255 / 0.06)),
+ 0 2px 4px rgb(23 32 60 / 0.06),
+ 0 10px 20px -8px light-dark(rgb(23 32 60 / 0.18), rgb(0 0 0 / 0.5)),
+ 0 28px 56px -20px light-dark(rgb(23 32 60 / 0.28), rgb(0 0 0 / 0.7));
+ font-size: 13px;
+}
+aside[mapa-links][hidden] { display: none; }
+[mapa-links-body] { display: grid; gap: 18px; padding: 14px 14px 16px; }
+[mapa-links-body] > section + section { padding-block-start: 16px; border-block-start: 1px solid var(--rst-line); }
+aside[mapa-links] h2 {
+ display: flex;
+ align-items: baseline;
+ gap: 6px;
+ margin: 0 0 8px;
+ color: var(--rst-text-muted);
+ font: 650 11px/14px var(--rst-font);
+}
+aside[mapa-links] h2 small,
+[mapa-foot-refs] h2 small { font-size: 11px; font-variant-numeric: tabular-nums; }
+[mapa-peek] { display: none; }
+
+/* The page column moves left only when the panel needs the room
+ (Docs' sheet-centring rule), measured on the main column. */
+@media (min-width: 64rem) {
+ [mapa-main] { container-type: inline-size; }
+ [mapa-app][data-links="open"] [mapa-doc] {
+ padding-inline-end: max(48px, calc(48px + 2 * 340px + 42rem + 96px - 100cqi));
+ }
+ [mapa-app][data-links="open"] [mapa-foot-refs] { display: none; }
+}
+@media (max-width: 63.99rem) {
+ aside[mapa-links] { display: none; }
+}
+
+/* ── References: Linked from, Mentioned. ── */
+ul[mapa-refs] { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
+ul[mapa-refs] > li { padding: 7px 8px; margin-inline: -8px; border-radius: 10px; }
+ul[mapa-refs] > li:hover { background: var(--rst-surface-2); }
+[mapa-ref-src] {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ color: var(--rst-text);
+ font-size: 13px;
+ font-weight: 650;
+ text-decoration: none;
+}
+[mapa-ref-src] > svg { inline-size: 14px; block-size: 14px; color: var(--rst-accent); flex: none; }
+[mapa-ref-src]:hover > span:first-of-type { text-decoration: underline; }
+[mapa-only-you] {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ margin-inline-start: auto;
+ color: var(--rst-text-muted);
+ font-size: 11.5px;
+ font-weight: 600;
+}
+[mapa-only-you] > svg { inline-size: 12px; block-size: 12px; }
+[mapa-ref-ctx] {
+ margin-block-start: 3px;
+ padding-inline-start: 22px;
+ color: var(--rst-text-muted);
+ font-size: 12.5px;
+ line-height: 1.5;
+}
+[mapa-ref-ctx] > :is(p, ul, ol, blockquote, h2, h3, h4, h5, h6, pre) { margin: 0; font-size: inherit; }
+[mapa-ref-ctx] form { margin-block-start: 6px; }
+
+/* ── Chips in Links out. ── */
+p[mapa-chips] { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
+a[mapa-chip] {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ padding: 1px 7px;
+ border-radius: 6px;
+ background: var(--rst-surface-2);
+ color: var(--rst-text);
+ font-weight: 550;
+ text-decoration: none;
+}
+a[mapa-chip] > svg { inline-size: 13px; block-size: 13px; color: var(--rst-accent); }
+a[mapa-chip]:hover { background: var(--rst-accent-soft); }
+a[mapa-chip="pending"] { background: none; outline: 1px dashed var(--rst-line-strong); outline-offset: -1px; color: var(--rst-text-muted); }
+a[mapa-chip="pending"] > svg { color: var(--rst-text-muted); }
+
+/* ── The map. Edges drawn three ways so colour never carries the
+ difference: solid linked, dashed not written, dotted mentioned. ── */
+svg[mapa-map] { display: block; inline-size: 100%; block-size: auto; overflow: visible; }
+[mapa-map-edge] { stroke: var(--rst-line-strong); stroke-width: 1.25; }
+[mapa-map-edge="pending"] { stroke-dasharray: 4 3; }
+[mapa-map-edge="mentioned"] { stroke-dasharray: 1 3; stroke-linecap: round; stroke-width: 1.5; }
+[mapa-map-node] { fill: var(--rst-surface); stroke: var(--rst-text-muted); stroke-width: 1.5; }
+[mapa-map-node="pending"] { stroke-dasharray: 2 2; }
+[mapa-map-node="here"] {
+ fill: var(--rst-accent);
+ stroke: color-mix(in oklab, var(--rst-accent) 28%, transparent);
+ stroke-width: 6;
+ paint-order: stroke;
+}
+svg[mapa-map] text {
+ fill: var(--rst-text-muted);
+ font: 500 10.5px var(--rst-font);
+ paint-order: stroke;
+ stroke: light-dark(#ffffff, #20232b);
+ stroke-width: 4px;
+ stroke-linejoin: round;
+}
+svg[mapa-map] text[mapa-map-here] { fill: var(--rst-text); font-weight: 700; font-size: 12px; }
+svg[mapa-map] a { text-decoration: none; }
+svg[mapa-map] a:hover text { fill: var(--rst-text); }
+p[mapa-map-key] { display: flex; gap: 14px; margin: 4px 0 0; color: var(--rst-text-muted); font-size: 11px; }
+p[mapa-map-key] span { display: inline-flex; align-items: center; gap: 6px; }
+p[mapa-map-key] span::before { content: ""; inline-size: 14px; border-block-start: 1.5px solid var(--rst-line-strong); }
+[mapa-k="pending"]::before { border-block-start-style: dashed !important; }
+[mapa-k="mentioned"]::before { border-block-start-style: dotted !important; border-block-start-width: 2px !important; }
+
+/* ── The week strip. ── */
+[mapa-week] { display: flex; align-items: center; gap: 4px; }
+ol[mapa-week-days] { display: grid; grid-template-columns: repeat(7, 1fr); flex: 1; gap: 2px; margin: 0; padding: 0; list-style: none; }
+ol[mapa-week-days] a {
+ position: relative;
+ display: grid;
+ justify-items: center;
+ gap: 2px;
+ padding: 5px 0 8px;
+ border-radius: 9px;
+ color: var(--rst-text);
+ font-weight: 650;
+ font-variant-numeric: tabular-nums;
+ text-decoration: none;
+}
+ol[mapa-week-days] abbr { color: var(--rst-text-muted); font-size: 10.5px; font-weight: 600; text-decoration: none; }
+ol[mapa-week-days] a:hover { background: var(--rst-surface-2); }
+:is(ol[mapa-week-days], table[mapa-month-grid]) a[mapa-wrote]::after {
+ content: "";
+ position: absolute;
+ inset-block-end: 3px;
+ inset-inline-start: calc(50% - 2px);
+ inline-size: 4px;
+ block-size: 4px;
+ border-radius: 50%;
+ background: var(--rst-text-muted);
+}
+:is(ol[mapa-week-days], table[mapa-month-grid]) a[mapa-today] { box-shadow: inset 0 0 0 1.5px var(--rst-accent); }
+:is(ol[mapa-week-days], table[mapa-month-grid]) a[aria-current] { background: var(--rst-accent); color: var(--rst-on-accent, #fff); box-shadow: none; }
+:is(ol[mapa-week-days], table[mapa-month-grid]) a[aria-current] abbr { color: inherit; opacity: 0.8; }
+:is(ol[mapa-week-days], table[mapa-month-grid]) a[aria-current]::after { background: var(--rst-on-accent, #fff); }
+[mapa-icon-link] {
+ display: inline-grid;
+ place-items: center;
+ inline-size: 26px;
+ block-size: 26px;
+ border-radius: 7px;
+ color: var(--rst-text-muted);
+}
+[mapa-icon-link]:hover { background: var(--rst-surface-2); color: var(--rst-text); }
+[mapa-icon-link] > svg { inline-size: 15px; block-size: 15px; }
+
+/* ── The month: the day pill's middle opens it. ── */
+details[mapa-calendar] { position: relative; }
+details[mapa-calendar] > summary { list-style: none; cursor: pointer; }
+details[mapa-calendar] > summary::-webkit-details-marker { display: none; }
+[mapa-day-now] {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ block-size: 26px;
+ padding-inline: 8px;
+ border-radius: 999px;
+ color: var(--rst-text);
+ font-size: 13px;
+ font-weight: 600;
+}
+[mapa-day-now]:hover, details[mapa-calendar][open] > [mapa-day-now] { background: var(--rst-surface-2); }
+[mapa-day-now] > svg { inline-size: 15px; block-size: 15px; }
+[mapa-month] {
+ position: absolute;
+ z-index: 40;
+ inset-block-start: calc(100% + 8px);
+ inset-inline-end: -40px;
+ inline-size: 256px;
+ padding: 10px;
+ border: 1px solid var(--rst-line);
+ border-radius: 12px;
+ background: var(--rst-surface);
+ box-shadow: 0 18px 40px -16px rgb(23 32 60 / 0.35);
+ font-size: 12.5px;
+}
+[mapa-month-head] { display: flex; align-items: center; gap: 2px; padding: 2px 2px 8px 6px; }
+[mapa-month-head] strong { flex: 1; font-size: 13.5px; font-weight: 650; }
+table[mapa-month-grid] { inline-size: 100%; border-collapse: collapse; text-align: center; }
+table[mapa-month-grid] th { padding-block: 4px; color: var(--rst-text-muted); font-size: 11px; font-weight: 600; }
+table[mapa-month-grid] td { padding: 1px; }
+table[mapa-month-grid] a {
+ position: relative;
+ display: grid;
+ place-items: center;
+ block-size: 30px;
+ border-radius: 8px;
+ color: var(--rst-text);
+ font-variant-numeric: tabular-nums;
+ text-decoration: none;
+}
+table[mapa-month-grid] a:hover { background: var(--rst-surface-2); }
+table[mapa-month-grid] a[mapa-outside] { color: var(--rst-text-muted); opacity: 0.7; }
+[mapa-month-foot] { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 2px 0 6px; color: var(--rst-text-muted); font-size: 12px; }
+[mapa-dot] { display: inline-block; inline-size: 4px; block-size: 4px; margin-inline-end: 4px; border-radius: 50%; background: var(--rst-text-muted); vertical-align: middle; }
+[mapa-month-foot] [rst-btn] { min-block-size: 26px; padding-block: 0; font-size: 12px; }
+
+/* ── The phone: the panel is a sheet at the foot with a peek line;
+ the page's own foot keeps the lists, so nothing needs the sheet. ── */
+@media (max-width: 799.98px) {
+ aside[mapa-links] {
+ display: block;
+ inset: auto 0 0 0;
+ inline-size: auto;
+ max-block-size: 62px;
+ overflow: hidden;
+ border-radius: 18px 18px 0 0;
+ padding-block-end: env(safe-area-inset-bottom);
+ transition: max-block-size 0.25s ease;
+ }
+ aside[mapa-links][data-open] { max-block-size: 74dvh; overflow: auto; }
+ aside[mapa-links]:not([data-open]) [mapa-links-body] { visibility: hidden; }
+ [mapa-peek] {
+ display: grid;
+ justify-items: center;
+ gap: 6px;
+ inline-size: 100%;
+ padding: 8px 16px 12px;
+ border: 0;
+ background: none;
+ color: var(--rst-text);
+ font: 600 14px var(--rst-font);
+ cursor: pointer;
+ }
+ [mapa-peek] > span:last-child { display: inline-flex; align-items: center; gap: 8px; }
+ [mapa-peek] svg { inline-size: 16px; block-size: 16px; color: var(--rst-accent); }
+ [mapa-grabber] { inline-size: 36px; block-size: 4px; border-radius: 4px; background: var(--rst-line-strong); opacity: 0.6; }
+ [mapa-doc] { padding-block-end: 140px; }
+ [mapa-month] { position: fixed; inset-inline: 12px; inset-block-start: calc(var(--mapa-bar-h) + 8px); inline-size: auto; }
+}
+@media (prefers-reduced-motion: reduce) {
+ aside[mapa-links] { transition: none; }
+}
diff --git a/internal/mapa/static/links.js b/internal/mapa/static/links.js
new file mode 100644
index 0000000..420f2bc
--- /dev/null
+++ b/internal/mapa/static/links.js
@@ -0,0 +1,61 @@
+// links.js: the Links panel's toggle and its phone sheet (level-up spec
+// §4.3). Without it the panel follows its cookie, the View menu's Links
+// row posts to set it, and the page's foot holds the same lists.
+(function () {
+ "use strict";
+
+ function setCookie(value) {
+ document.cookie = "mapa-links=" + value + "; path=/; max-age=31536000; samesite=lax" +
+ (location.protocol === "https:" ? "; secure" : "");
+ }
+
+ function start() {
+ var panel = document.getElementById("mapa-links");
+ var app = document.querySelector("[mapa-app]");
+ if (!panel || !app) return;
+ var toggles = document.querySelectorAll(
+ '[data-estilo-toggle][aria-controls="mapa-links"], [data-mapa-command="toggle-links"]');
+
+ function show(open) {
+ panel.hidden = !open;
+ app.setAttribute("data-links", open ? "open" : "closed");
+ toggles.forEach(function (toggle) {
+ if (toggle.hasAttribute("aria-controls")) toggle.setAttribute("aria-expanded", open ? "true" : "false");
+ });
+ setCookie(open ? "open" : "closed");
+ }
+
+ toggles.forEach(function (toggle) {
+ toggle.disabled = false;
+ toggle.addEventListener("click", function (event) {
+ event.preventDefault();
+ var menu = toggle.closest("details");
+ if (menu) menu.open = false;
+ show(panel.hidden);
+ });
+ });
+
+ // The phone's sheet: the peek line opens it; Esc or the peek closes.
+ var peek = panel.querySelector("[mapa-peek]");
+ if (peek) {
+ peek.addEventListener("click", function () {
+ var open = !panel.hasAttribute("data-open");
+ panel.toggleAttribute("data-open", open);
+ peek.setAttribute("aria-expanded", open ? "true" : "false");
+ });
+ document.addEventListener("keydown", function (event) {
+ if (event.key === "Escape" && panel.hasAttribute("data-open")) {
+ panel.removeAttribute("data-open");
+ peek.setAttribute("aria-expanded", "false");
+ peek.focus();
+ }
+ });
+ }
+ }
+
+ if (document.readyState === "loading") {
+ document.addEventListener("DOMContentLoaded", start);
+ } else {
+ start();
+ }
+})();
diff --git a/internal/mapa/templates/day.html b/internal/mapa/templates/day.html
index a655453..982c479 100644
--- a/internal/mapa/templates/day.html
+++ b/internal/mapa/templates/day.html
@@ -1,5 +1,5 @@
{{define "content"}}{{$d := .Data}}{{$page := $d.Page}}
-{{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 "mapa-doc-head" dict "Page" $page "Edit" (or (and $d.Written (not $d.Editing) (printf "/d/%s/edit" $page.Date)) "") "Day" $d.Pill}}
{{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}}
@@ -17,5 +17,7 @@
{{end}}
<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}}
+{{if $d.Written}}{{template "mapa-links-out" $page}}{{end}}
</footer>
+{{template "mapa-links-panel" dict "Page" $page "Week" $d.Week "State" $.Frame.Panel}}
{{end}}
diff --git a/internal/mapa/templates/frame.html b/internal/mapa/templates/frame.html
index abfb56b..4cbb8aa 100644
--- a/internal/mapa/templates/frame.html
+++ b/internal/mapa/templates/frame.html
@@ -32,15 +32,89 @@
{{- with .Day}}{{template "mapa-day-pill" .}}{{end}}
{{- end}}
-{{/* mapa-day-pill: ‹ Today ›. The middle names the day on screen, and
- is Today's link when that is another day. Data: dayPill. */}}
+{{/* mapa-day-pill: ‹ Today ›. The middle names the day on screen and
+ opens the month (a <details>, so it works with no script). Data:
+ dayPill. */}}
{{define "mapa-day-pill"}}<nav mapa-day aria-label="Days">
<a mapa-day-step href="/d/{{.Prev}}" aria-label="Previous day, {{longDate .Prev}}">{{icon "chevron-left"}}</a>
- {{- if eq .Date .Today}}<a mapa-day-now href="/" aria-current="page">{{icon "calendar"}}<span>Today</span></a>
- {{- else}}<a mapa-day-now href="/" title="Go to today">{{icon "calendar"}}<span>{{shortDate .Date}}</span></a>{{end}}
+ <details mapa-calendar name="estilo-menus">
+ <summary mapa-day-now aria-label="{{longDate .Date}}: choose a day">{{icon "calendar"}}<span>{{if eq .Date .Today}}Today{{else}}{{shortDate .Date}}{{end}}</span></summary>
+ {{with .Month}}{{template "mapa-month" .}}{{end}}
+ </details>
<a mapa-day-step href="/d/{{.Next}}" aria-label="Next day, {{longDate .Next}}">{{icon "chevron-right"}}</a>
</nav>{{end}}
+{{/* mapa-month: a month of links, weeks from Monday (§4.4). A dot is a
+ day you wrote a note; today is ringed; the day on screen is filled.
+ ‹ › page the month with ?month=. Data: MonthView. */}}
+{{define "mapa-month"}}<div mapa-month>
+ <div mapa-month-head>
+ <strong>{{.Title}}</strong>
+ <a mapa-icon-link href="?month={{.Prev}}" aria-label="Previous month">{{icon "chevron-left"}}</a>
+ <a mapa-icon-link href="?month={{.Next}}" aria-label="Next month">{{icon "chevron-right"}}</a>
+ </div>
+ <table mapa-month-grid>
+ <thead><tr><th abbr="Monday">M</th><th abbr="Tuesday">T</th><th abbr="Wednesday">W</th><th abbr="Thursday">T</th><th abbr="Friday">F</th><th abbr="Saturday">S</th><th abbr="Sunday">S</th></tr></thead>
+ <tbody>{{range .Weeks}}<tr>{{range .}}<td><a href="/d/{{.Date}}" aria-label="{{longDate .Date}}{{if .Wrote}}, a note you wrote{{end}}{{if .Today}}, today{{end}}"{{if .Current}} aria-current="date"{{end}}{{if .Today}} mapa-today{{end}}{{if .Wrote}} mapa-wrote{{end}}{{if .Outside}} mapa-outside{{end}}>{{.Number}}</a></td>{{end}}</tr>{{end}}</tbody>
+ </table>
+ <div mapa-month-foot><span><span mapa-dot aria-hidden="true"></span> A note you wrote</span><a rst-btn href="/">Today</a></div>
+</div>{{end}}
+
+{{/* mapa-links-panel: the Links panel (§4.3), Docs' inspector glass at
+ the inline end from 64rem; at narrower widths and with the panel
+ off the same lists are at the page's foot, and on a phone this is a
+ sheet. Its state is the mapa-links cookie, rendered. Data: dict
+ Page (PageView), Week (*WeekView or nil), State. */}}
+{{define "mapa-links-panel"}}{{$page := .Page}}<aside mapa-links id="mapa-links" aria-label="Links"{{if eq .State "closed"}} hidden{{end}}>
+ <button mapa-peek type="button" aria-expanded="false" aria-controls="mapa-links-body"><span mapa-grabber aria-hidden="true"></span><span>{{icon "map"}}{{template "mapa-peek-line" .}}</span></button>
+ <div mapa-links-body id="mapa-links-body">
+ {{with .Week}}{{template "mapa-week" .}}{{end}}
+ {{with $page.Around}}{{if not $.Week}}<section aria-labelledby="mapa-around-h"><h2 id="mapa-around-h">Around this page</h2>{{template "mapa-map" .Map}}</section>{{end}}{{end}}
+ {{if .Week}}{{template "mapa-links-out" $page}}{{end}}
+ {{template "mapa-panel-linked" dict "ID" "mapa-p-backlinks" "Heading" "Linked from" "Items" $page.Backlinks "Empty" (or (and .Week "No page links to this day yet. A date link in any of your pages lands here.") "Nothing links here yet.") "Target" 0}}
+ {{if eq $page.Kind "page"}}{{template "mapa-panel-linked" dict "ID" "mapa-p-mentions" "Heading" "Mentioned without a link" "Items" $page.Mentions "Empty" "No unlinked mentions." "Target" $page.Public}}{{end}}
+ {{if not .Week}}{{template "mapa-links-out" $page}}{{end}}
+ </div>
+</aside>{{end}}
+{{define "mapa-peek-line"}}{{if .Week}}This week, and links out{{else}}Linked from {{len .Page.Backlinks}}{{if eq .Page.Kind "page"}}, mentioned in {{len .Page.Mentions}}{{end}}{{end}}{{end}}
+
+{{define "mapa-links-out"}}<section aria-labelledby="mapa-out-h"><h2 id="mapa-out-h">Links out {{with .Around}}<small>{{len .Out}}</small>{{end}}</h2>
+ {{with .Around}}{{with .Out}}<p mapa-chips>{{range .}}<a mapa-chip="{{.Kind}}" href="{{.Href}}">{{if eq .Kind "date"}}{{icon "calendar"}}{{else if eq .Kind "pending"}}{{icon "file-plus"}}{{else}}{{icon "file"}}{{end}}<span>{{.Label}}</span>{{if eq .Kind "pending"}}<span mapa-sr>, page not written yet</span>{{end}}</a>{{end}}</p>
+ {{else}}<p mapa-meta>This page links nowhere yet.</p>{{end}}{{end}}
+</section>{{end}}
+
+{{/* mapa-panel-linked: Linked from or Mentioned, as the panel lists
+ them: the page, then each block that does it. Keys as mapa-linked. */}}
+{{define "mapa-panel-linked"}}<section aria-labelledby="{{.ID}}">
+<h2 id="{{.ID}}">{{.Heading}} <small>{{len .Items}}</small></h2>
+{{if .Items}}{{$target := .Target}}<ul mapa-refs>
+{{range .Items}}<li><a mapa-ref-src href="{{.Href}}">{{if eq .Kind "daily"}}{{icon "calendar"}}{{else if eq .Kind "scratch"}}{{icon "file"}}{{else}}{{icon "file-text"}}{{end}}<span>{{.Label}}</span>{{if ne .Kind "page"}}<span mapa-only-you>{{icon "lock"}}Only you</span>{{end}}</a>
+{{$source := .Public}}{{range .Contexts}}<div mapa-ref-ctx>{{.HTML}}
+{{if $target}}<form method="post" action="/p/{{$target}}/mentions"><input type="hidden" name="source" value="{{$source}}"><input type="hidden" name="block" value="{{.Block}}"><button rst-btn="sm" type="submit">{{icon "link"}}Link it</button></form>{{end}}
+</div>{{end}}</li>
+{{end}}</ul>
+{{else}}<p mapa-meta>{{.Empty}}</p>{{end}}
+</section>{{end}}
+
+{{/* mapa-map: around this page (§4.3). A picture of the lists that
+ follow it: its nodes are pointer shortcuts to links that are also in
+ the lists, so they take no tab stop. Data: MapView. */}}
+{{define "mapa-map"}}<svg mapa-map viewBox="0 0 284 200" role="img" aria-label="{{.Label}}">
+ <g mapa-map-edges>{{range .Edges}}<line x1="{{.X1}}" y1="{{.Y1}}" x2="{{.X2}}" y2="{{.Y2}}" mapa-map-edge="{{.Kind}}"/>{{end}}</g>
+ <g mapa-map-nodes>{{range .Nodes}}<a href="{{.Href}}" tabindex="-1" aria-hidden="true"><circle cx="{{.X}}" cy="{{.Y}}" r="5.5" mapa-map-node="{{.Kind}}"/><text x="{{.LabelX}}" y="{{.LabelY}}" text-anchor="{{.Anchor}}">{{.Label}}</text></a>{{end}}
+ {{with .Here}}<circle cx="{{.X}}" cy="{{.Y}}" r="8" mapa-map-node="here"/><text x="{{.LabelX}}" y="{{.LabelY}}" text-anchor="middle" mapa-map-here>{{.Label}}</text>{{end}}</g>
+</svg>
+<p mapa-map-key aria-hidden="true"><span mapa-k="linked">Linked</span><span mapa-k="pending">Not written</span><span mapa-k="mentioned">Mentioned</span></p>{{end}}
+
+{{/* mapa-week: the panel on a daily note (§4.3, §4.4). Data: WeekView. */}}
+{{define "mapa-week"}}<section aria-labelledby="mapa-week-h"><h2 id="mapa-week-h">This week</h2>
+<div mapa-week>
+ <a mapa-icon-link href="/d/{{.Prev}}" aria-label="Previous week">{{icon "chevron-left"}}</a>
+ <ol mapa-week-days>{{range .Days}}<li><a href="/d/{{.Date}}" aria-label="{{longDate .Date}}{{if .Wrote}}, a note you wrote{{end}}{{if .Today}}, today{{end}}"{{if .Current}} aria-current="date"{{end}}{{if .Today}} mapa-today{{end}}{{if .Wrote}} mapa-wrote{{end}}><abbr aria-hidden="true">{{.Letter}}</abbr><span aria-hidden="true">{{.Number}}</span></a></li>{{end}}</ol>
+ <a mapa-icon-link href="/d/{{.Next}}" aria-label="Next week">{{icon "chevron-right"}}</a>
+</div>
+</section>{{end}}
+
{{/* mapa-side: the sidebar, one grid per row (§3.2). In the rail the
labels stay in the accessibility tree and show as tooltips. The fold
is two submit buttons, one per state; CSS shows the one that fits
diff --git a/internal/mapa/templates/page.html b/internal/mapa/templates/page.html
index 1fb8a78..6a5b5a1 100644
--- a/internal/mapa/templates/page.html
+++ b/internal/mapa/templates/page.html
@@ -10,5 +10,7 @@
{{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}}
+{{template "mapa-links-out" $page}}
</footer>
+{{template "mapa-links-panel" dict "Page" $page "Week" nil "State" $.Frame.Panel}}
{{end}}
diff --git a/internal/mapa/templates/partials.html b/internal/mapa/templates/partials.html
index f06b118..0b83c73 100644
--- a/internal/mapa/templates/partials.html
+++ b/internal/mapa/templates/partials.html
@@ -46,7 +46,7 @@
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>
+<div 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}}
@@ -54,6 +54,6 @@
{{- 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>
+</div>
<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/mapa/templates/shell.html b/internal/mapa/templates/shell.html
index d64ceac..a581ae2 100644
--- a/internal/mapa/templates/shell.html
+++ b/internal/mapa/templates/shell.html
@@ -16,6 +16,7 @@
<link rel="stylesheet" href="{{asset "static/savestatus.css"}}">
<link rel="stylesheet" href="{{asset "static/mapa.css"}}">
<link rel="stylesheet" href="{{asset "static/frame.css"}}">
+<link rel="stylesheet" href="{{asset "static/links.css"}}">
<script defer src="{{asset "static/rastrillo.js"}}"></script>
<script defer src="{{asset "static/busy.js"}}"></script>
<script defer src="{{asset "static/chrome.js"}}"></script>
@@ -23,6 +24,7 @@
panel toggle and the time zone offer. Every screen works without
it. */}}
<script defer src="{{asset "static/mapa.js"}}"></script>
+<script defer src="{{asset "static/links.js"}}"></script>
{{block "head" .}}{{end}}
</head>
<body data-zone="{{with .Viewer.TimeZone}}{{.String}}{{end}}">
diff --git a/internal/mapa/today.go b/internal/mapa/today.go
index 693c0ed..5e9d0c0 100644
--- a/internal/mapa/today.go
+++ b/internal/mapa/today.go
@@ -76,6 +76,30 @@ type dayData struct {
Orphans, Elsewhere []Unsaved
// Drafts is where the editor autosaves; empty for none.
Drafts string
+ // Week and Pill are day navigation (level-up §4.4): the panel's
+ // strip, and ‹ Today › with its month.
+ Week *WeekView
+ Pill *dayPill
+}
+
+// dayCalendar fills in the week strip and the month calendar, both read
+// from the viewer's own notes only. ?month= pages the calendar.
+func (app *app) dayCalendar(request *http.Request, viewer Viewer,
+ data *dayData) error {
+ ctx, scope, date := request.Context(), ScopeOf(viewer), data.Page.Date
+ week, err := app.index.Week(ctx, scope, date, data.Today)
+ if err != nil {
+ return err
+ }
+ month, err := app.index.Month(ctx, scope,
+ request.URL.Query().Get("month"), date, data.Today)
+ if err != nil {
+ return err
+ }
+ data.Week = &week
+ data.Pill = &dayPill{Date: date, Today: data.Today, Prev: data.Prev,
+ Next: data.Next, Month: &month}
+ return nil
}
func (app *app) showDay(writer http.ResponseWriter, request *http.Request,
@@ -106,11 +130,14 @@ func (app *app) showDay(writer http.ResponseWriter, request *http.Request,
if request.Method == http.MethodPost {
data.Body = request.PostFormValue("body")
}
+ if err := app.dayCalendar(request, viewer, &data); err != nil {
+ app.fail(writer, request, err)
+ return
+ }
app.show(writer, request, status, "day", view{Title: longDate(date),
Nav: nav(dayNav(date, data.Today)), Viewer: viewer, Data: data,
Chrome: &pageChrome{Page: &data.Page, Editor: data.Editing,
- Day: &dayPill{Date: date, Today: data.Today, Prev: data.Prev,
- Next: data.Next}}})
+ Day: data.Pill, Links: true}})
}
// dayDrafts fills in the day's own draft, which the editor holds, and on
diff --git a/internal/mapa/views.go b/internal/mapa/views.go
index 1326ddb..604a3ac 100644
--- a/internal/mapa/views.go
+++ b/internal/mapa/views.go
@@ -12,15 +12,17 @@ import (
type PageView struct {
ID, Revision int64
// Public is the page's id in every URL (publicid.go).
- Public string
- Kind, Rung string
- Title, Date string
- Label, Href string
- Body string
- HTML template.HTML
- Aliases []AliasView
- Backlinks []Linked
- Mentions []Linked
+ Public string
+ Kind, Rung string
+ Title, Date string
+ Label, Href string
+ Body string
+ HTML template.HTML
+ Aliases []AliasView
+ Backlinks []Linked
+ Mentions []Linked
+ // Around is the Links panel's links out and map (level-up §4.3).
+ Around *Around
Created, Edited time.Time
}
@@ -63,6 +65,8 @@ func (index *Index) View(ctx context.Context, scope Scope,
if page.team() {
view.Mentions = index.mentions(scope, page, view.Backlinks)
}
+ view.Around = index.in(scope).around(page, view.Backlinks,
+ view.Mentions)
return view, nil
}
@@ -230,12 +234,14 @@ func (index *Index) Day(ctx context.Context, scope Scope,
view := page.summary()
view.HTML = markup.Render(page.blocks, resolver{index, scope})
view.Backlinks = index.backlinks(scope, page)
+ view.Around = index.in(scope).around(page, view.Backlinks, nil)
return view, true, nil
}
unwritten := &entry{kind: KindDaily, rung: RungPrivate,
owner: scope.Member, record: Record{Date: date}}
view := unwritten.summary()
view.Backlinks = index.backlinks(scope, unwritten)
+ view.Around = index.in(scope).around(unwritten, view.Backlinks, nil)
return view, false, nil
}
diff --git a/internal/mapatest/gate1_test.go b/internal/mapatest/gate1_test.go
index 0ffaea6..8707d4e 100644
--- a/internal/mapatest/gate1_test.go
+++ b/internal/mapatest/gate1_test.go
@@ -165,10 +165,16 @@ func firstDifference(want, got string) string {
// Ana's private notes (§3.4).
func TestUpdateLinksNeverTouchesSomeoneElsesNotes(t *testing.T) {
busy, acme := gate1World(t, true)
- daily := busy.page(t, Ana, "/d/2026-11-12/edit")
+ // The note's text, as its editor holds it. The rest of the screen
+ // (its links panel) rightly shows the page's new title.
+ text := func() string {
+ return between(busy.page(t, Ana, "/d/2026-11-12/edit"),
+ "<textarea", "</textarea>")
+ }
+ daily := text()
busy.post(t, Bo, acme+"/rename", url.Values{"title": {"Renamed"}})
busy.post(t, Bo, acme+"/links", nil)
- if busy.page(t, Ana, "/d/2026-11-12/edit") != daily {
+ if text() != daily {
t.Fatal("Bo's Update links edited Ana's daily note")
}
}
diff --git a/scripts/mutate/mutations.go b/scripts/mutate/mutations.go
index ef38ed4..d462fd5 100644
--- a/scripts/mutate/mutations.go
+++ b/scripts/mutate/mutations.go
@@ -8,6 +8,7 @@ const (
verbs = "internal/mapa/verbs.go"
views = "internal/mapa/views.go"
aliases = "internal/mapa/aliases.go"
+ around = "internal/mapa/around.go"
gateOne = "TestGate1ScopeLeaksNothing"
gateFour = "TestNoPlaintextReachesTheDisk"
@@ -24,6 +25,17 @@ var mutations = []mutation{
"\t\tfor pageID, text := range found.private[scope.Member] {",
to: "\tfor _, texts := range found.private {\n" +
"\t\tfor pageID, text := range texts {"}}},
+ {gate: "1", test: gateOne,
+ name: "the level-up's scoped accessor ignores its scope",
+ edits: []edit{{file: around,
+ from: "\tif page == nil || !view.scope.sees(page) {",
+ to: "\tif page == nil {"},
+ {file: around,
+ from: "\treturn view.page(view.index.days[view.scope.Member]" +
+ "[date]) != nil\n}",
+ to: "\tfor _, days := range view.index.days {\n" +
+ "\t\tif view.page(days[date]) != nil {\n" +
+ "\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}"}}},
{gate: "1", test: gateOne, name: "search reads every person's postings",
edits: []edit{{file: rank,
from: "\tif own := index.ownTerms[scope.Member]; " +