From 151ea12251ed876aa87bb486da1bc337e25369e9 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 1 Aug 2026 16:18:19 -0300 Subject: --- vrsite/templates/frag-note.tmpl | 57 ++++++++++++++++++++++++++++++++++++----- vrsite/templates/layout.tmpl | 30 +++++++++++++++++----- vrsite/templates/page-note.tmpl | 54 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 12 deletions(-) create mode 100644 vrsite/templates/page-note.tmpl (limited to 'vrsite/templates') diff --git a/vrsite/templates/frag-note.tmpl b/vrsite/templates/frag-note.tmpl index 0c3182c..3b04e11 100644 --- a/vrsite/templates/frag-note.tmpl +++ b/vrsite/templates/frag-note.tmpl @@ -1,19 +1,26 @@ {{define "note"}}{{$n := .N}}{{$p := .P}}{{$away := and $n.Change $p.ChangeID (ne $n.Change $p.ChangeID)}}
+ data-agent="{{$n.Agent.Name}}" data-model="{{$n.Model}}" data-session="{{$n.Session}}" + data-kind="{{$n.Kind}}" data-file="{{$n.File}}" data-date="{{if not $n.At.IsZero}}{{$n.At.Format "2006-01-02"}}{{end}}" + data-start="{{$n.Start}}" data-end="{{$n.End}}" data-reply-to="{{$n.ReplyTo}}">
{{if $n.File}}{{base $n.File}}{{lines $n}}{{end}} {{if $n.Kind}}{{$n.Kind}}{{end}} {{$n.Agent.Short}}
-

{{$n.Text}}

+
{{md $n.Text $p}}
+ {{with $p.PermaHref $n}}#{{$n.ID}} + {{else}}#{{$n.ID}}{{end}} {{if not $n.At.IsZero}}{{end}} {{if $n.Model}}{{$n.Model}}{{if $n.Reason}}/{{$n.Reason}}{{end}}{{end}} - {{if $n.Session}}{{short $n.Session}}{{end}} - {{with $p.ConvHref $n}}conversation{{end}} + {{if $n.Session}}{{short $n.Session}}{{end}} + {{if $n.ReplyTo}}{{with $p.ReplyHref $n}}reply to #{{$n.ReplyTo}}{{else}}reply to #{{$n.ReplyTo}}{{end}}{{end}} + {{with $p.ThreadHref $n}} + {{if $n.Replies}}↳ {{len $n.Replies}} repl{{if eq (len $n.Replies) 1}}y{{else}}ies{{end}}{{end}}{{if and $n.Replies $n.Mentions}} · {{end}}{{if $n.Mentions}}↶ {{len $n.Mentions}} mention{{if ne (len $n.Mentions) 1}}s{{end}}{{end}}{{end}} + {{with $p.ConvHref $n}}conversation{{end}} {{if $n.Change}} {{if $p.Live}}{{short $n.Change}} @@ -30,6 +37,44 @@ {{define "note-added"}}{{if .File}}{{len .File.Notes}}{{end}}{{range .Notes}}{{template "note" (dict "N" . "P" $)}}{{end}}{{end}} +{{/* A child-note form appears below every full card in a focused thread. It + deliberately uses a normal POST: one append and one redirect rebuild the + entire DAG from the log, including shared mention paths. */}} +{{define "replyform"}}{{$n := .N}}{{$p := .P}} +
+ reply to #{{$n.ID}} +
+ + + + + + +
+ as {{$p.User}} at {{short $p.ChangeID}} → the log + +
+
+
+{{end}} + +{{/* Recursive at arbitrary depth. A DAG join/cycle is a reference rather than + a second card, which keeps ids unique and recursion finite. */}} +{{define "threadnode"}}{{$x := .Node}}{{$p := .P}} +
+
{{if eq $x.Via "reply"}}↳{{else}}↶{{end}}
+
+ {{if $x.Reference}} +

{{$x.Via}} also reaches note #{{$x.Note.ID}}

+ {{else}} + {{template "note" (dict "N" $x.Note "P" $p)}} + {{if $p.Live}}{{template "replyform" (dict "N" $x.Note "P" $p)}}{{end}} + {{if $x.Children}}
{{range $x.Children}}{{template "threadnode" (dict "Node" . "P" $p)}}{{end}}
{{end}} + {{end}} +
+
+{{end}} + {{/* the add-a-comment form; live pages only, since it writes to the log */}} {{define "noteform"}}
{{.Title}} + - {{if .Live}}{{end}} @@ -35,11 +43,20 @@ files{{if .Live}} · jj{{end}} - +
+ + +
@@ -47,6 +64,7 @@ {{if .Err}}

{{.Err}}

{{end}} {{if eq .Kind "file"}}{{template "page-file" .}} {{else if eq .Kind "notes"}}{{template "page-notes" .}} +{{else if eq .Kind "note"}}{{template "page-note" .}} {{else if eq .Kind "files"}}{{template "page-files" .}} {{else if eq .Kind "jj"}}{{template "page-jj" .}} {{else if eq .Kind "change"}}{{template "page-change" .}} diff --git a/vrsite/templates/page-note.tmpl b/vrsite/templates/page-note.tmpl new file mode 100644 index 0000000..8cd0e64 --- /dev/null +++ b/vrsite/templates/page-note.tmpl @@ -0,0 +1,54 @@ +{{/* One note, on its own — the page a shared permalink opens. + + It has to stand up for a reader who has never seen this site: what was + said, about which lines of which file, at which change, and the code + itself, right there. Everything else on the page is a way further in. */}} +{{define "page-note"}} +{{$n := .Note}} +
+

{{if $n.File}}{{base $n.File}}{{lines $n}}{{else}}Note{{end}}

+

+ note #{{$n.ID}} by {{$n.Agent.Short}}{{if $n.Kind}} · {{$n.Kind}}{{end}} + {{if not $n.At.IsZero}} · + ({{$n.Ago}}){{end}} + {{if $n.Change}} · read at + {{if .Live}}{{short $n.Change}} + {{else}}{{short $n.Change}}{{end}} + {{end}} +

+ {{if ne $n.File (base $n.File)}}

{{$n.File}}

{{end}} +
+ +
+
{{template "note" (dict "N" $n "P" $)}}
+ + {{$open := .HasCode $n.File}} + {{if .Excerpt}} +

lines {{.ExFrom}}–{{.ExTo}} of {{$n.File}}{{if $open}} · + open the whole file →{{end}}

+
{{.Excerpt}}
+ {{else if .ExErr}} +

{{.ExErr}}

+ {{else if $n.File}} +

this note is about the whole file{{if $open}} — + open {{base $n.File}} →{{end}}

+ {{else}} +

this note is not pinned to a file

+ {{end}} + + {{if .Live}}{{template "replyform" (dict "N" $n "P" $)}}{{end}} + +
+

Replies & mentions + {{len $n.Replies}} repl{{if eq (len $n.Replies) 1}}y{{else}}ies{{end}} · {{len $n.Mentions}} mention{{if ne (len $n.Mentions) 1}}s{{end}} +

+ {{if .Thread.Children}} +
{{range .Thread.Children}}{{template "threadnode" (dict "Node" . "P" $)}}{{end}}
+ {{else}} +

no notes reply to or mention this one yet

+ {{end}} +
+ +

← every note in the log

+
+{{end}} -- cgit v1.3