diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-02 23:43:08 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-03 09:54:39 -0300 |
| commit | 5ec72f8723d795d0b02d7e9ebb9f555f0c7e6a2e (patch) | |
| tree | f12f4b700fff4ff6f7e818d2a542672ba0b8d76e /vrsite/tree.go | |
| parent | a9263daee9413c5eff3c1f1bebcd224442fd8685 (diff) | |
| download | notevi-5ec72f8723d795d0b02d7e9ebb9f555f0c7e6a2e.tar.gz notevi-5ec72f8723d795d0b02d7e9ebb9f555f0c7e6a2e.zip | |
rebrand to notevi: one CLI over the jj sidecar
vr and vrsite become a single binary. vrsite/ folds into a web package in
one module (0x4200.cafe/notevi); "notevi web" serves and exports exactly
what vrsite did, and "notevi read/grep/note/query" is unchanged.
The sidecar is renamed with it: notevi_log, notevi-log.jsonl, and the
description "private: notevi log". The pre-rebrand names are still
recognized, so an old repository opens and reads; it is renamed in place
on the first write, or up front with "notevi migrate DIR...".
That rename cannot be a single mv inside jj run. jj only auto-tracks a
*new* file in the run working copy below a size limit it does not take
from the command line, so writing a whole log under a name the change has
never held is silently dropped while jj reports success. ensureLogFile
creates the file empty first and lets every later byte be a modification
of a tracked file, which snapshots at any size; that also fixes the same
latent bug when importing a large legacy vr-log.jsonl.
Adds a bem-te-vi mark (favicon and nav brand) and a README.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Diffstat (limited to 'vrsite/tree.go')
| -rw-r--r-- | vrsite/tree.go | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/vrsite/tree.go b/vrsite/tree.go deleted file mode 100644 index e7891c6..0000000 --- a/vrsite/tree.go +++ /dev/null @@ -1,115 +0,0 @@ -// tree.go — the repository tree, one fragment shared by every page. -package main - -import ( - "fmt" - "html" - "path/filepath" - "strings" -) - -type treeNode struct { - Name string - Dirs []*treeNode - Files []*File - Mask uint8 // union of traced masks underneath - HasNotes bool - HasTraced bool -} - -func aggregate(n *treeNode) { - for _, f := range n.Files { - if f.Traced { - n.HasTraced = true - n.Mask |= f.Mask - if len(f.Notes) > 0 { - n.HasNotes = true - } - } - } - for _, d := range n.Dirs { - aggregate(d) - n.Mask |= d.Mask - n.HasNotes = n.HasNotes || d.HasNotes - n.HasTraced = n.HasTraced || d.HasTraced - } -} - -func buildTree(files []*File) *treeNode { - root := &treeNode{} - for _, f := range files { - parts := strings.Split(f.Path, "/") - node := root - for _, d := range parts[:len(parts)-1] { - var next *treeNode - for _, c := range node.Dirs { - if c.Name == d { - next = c - } - } - if next == nil { - next = &treeNode{Name: d} - node.Dirs = append(node.Dirs, next) - } - node = next - } - node.Files = append(node.Files, f) - } - return root -} - -// treeHTML renders one unified tree: traced files carry coverage bars, dirs -// with traced content underneath get a mixed-color dot (and ◆ for notes) and -// default open. prefix is the dir path so far, used for state persistence; -// link maps a repo path to the href for that file's page. -func treeHTML(b *strings.Builder, n *treeNode, link func(path string) string, prefix string) { - for _, d := range n.Dirs { - dp := d.Name - if prefix != "" { - dp = prefix + "/" + d.Name - } - openAttr, cls := "", "" - if d.HasTraced { - openAttr, cls = " open", ` class="t"` - } - fmt.Fprintf(b, `<details%s%s data-path="%s"><summary>%s`, cls, openAttr, html.EscapeString(dp), html.EscapeString(d.Name)) - if d.HasTraced { - fmt.Fprintf(b, `<span class="dot trace-only am%d"></span>`, d.Mask) - } - if d.HasNotes { - b.WriteString(`<span class="nmark notes-only">◆</span>`) - } - b.WriteString(`</summary>`) - treeHTML(b, d, link, dp) - b.WriteString(`</details>`) - } - if len(n.Files) == 0 { - return - } - b.WriteString("<ul>") - for _, f := range n.Files { - name := html.EscapeString(filepath.Base(f.Path)) - path := html.EscapeString(f.Path) - if !f.Traced { - fmt.Fprintf(b, `<li><a class="file plain" data-path="%s" href="%s">%s</a></li>`, path, html.EscapeString(link(f.Path)), name) - continue - } - noted := "" - if len(f.Notes) > 0 { - noted = " has-notes" - } - fmt.Fprintf(b, - `<li><a class="file am%d%s" data-path="%s" href="%s" style="--pct:%d%%" title="%d%% read, %d notes">%s</a></li>`, - f.Mask, noted, path, html.EscapeString(link(f.Path)), f.Pct, f.Pct, len(f.Notes), name) - } - b.WriteString("</ul>") -} - -// renderTree is the whole fragment for a file set. -func renderTree(files []*File, link func(string) string) string { - root := buildTree(files) - aggregate(root) - var b strings.Builder - treeHTML(&b, root, link, "") - return b.String() -} |
