vole
Clone
Read only, no credentials:
https://rodent.software/git/vole.git
Write over SSH with a registered key:
git clone ssh://git@0.0.0.0:2222/vole.git
A free and open-source forge that lives in your Git repo.
Reorganise the web package around one implementation per rule
c717d4eb92b4257b05fa065918b0071f6302f53e · Keenan Nemetz · 13d ago · parent 4506a4d3
Reorganise the web package around one implementation per rule
server/web had grown by feature, so several rules and widgets existed twice: the
comment stack for issues and change requests, the pager, the file tree, the write
preamble, and the ACL predicates. Each pair agreed today and would drift
tomorrow. No route, stored format, or permission rule changes; the few behaviour
differences found along the way are listed at the end.
Files now say what they answer:
web.go the Web type, render, open, the error pages
page.go Page, pageSection, who, nav
templatefuncs.go the template function map, with the escaping rules noted
ui.go relative time, avatars, breadcrumbs, the pager
markdown.go the goldmark and bluemonday boundary
codebrowser.go the code browser, out of web.go
tokens.go the label/assignee token input
rolepicker.go the role control, out of admin.go
comments.go the comment view, thread builder, action menus, snippet
comment_writes.go add, edit and delete a comment, for both surfaces
write_context.go beginWrite/beginPost/beginAdminPost, fail, refuse
capabilities.go the ACL rules a page and a handler share
audit.go the audit log
request_view.go the change conversation page, out of requests.go
admin_access.go the instance-admin access rules, out of settings.go
A comment is one thing, so it has one view and one thread builder: metadata.Comment
is the same type on both surfaces and only a change request can anchor one to a
diff line. Adding, editing and deleting are one implementation each, with a
commentTopic naming what differs per surface. The pager is one control for issues,
changes and the instance feed; the file tree is one widget for the code browser
and a change's Files tab.
Every write starts at beginWrite (session, body bound, CSRF, repository, rules,
form) and asks capabilities.go for the one rule it needs, so the control a page
draws and the check a handler makes cannot disagree. A rejected write answers
through refuse; a write that fails for another reason answers through fail, which
re-renders the section for HTMX and returns text otherwise.
Templates follow the same split: chrome.html, components.html, diff.html and
role-picker.html hold what more than one surface renders, and each page owns its
fragments. The route table moved to routes.go, one function per surface.
Behaviour changes found while unifying:
- A reply cycle (two comments answering each other, possible through a pushed
metadata branch) used to drop both comments from the page; anything the walk
does not reach is now emitted as a root.
- A rejected anchored comment keeps its "Commenting on path:line" note and
hidden anchor fields, so the reviewer does not have to pick the line again.
- A repository whose access rules cannot be read answers 500 rather than 403;
the account was being blamed for a broken instance.
- Pager wording is now "Showing a-b of n / page x of y" with Previous/Next
everywhere, and the instance feed's page links keep their kind filter.
- The activity feed, issue list and change list share one page control.
Docs: docs/ui-plan.md gains a "Where the code lives" map, the write gate, the
shared comment model, the route table, and rules for rejected writes, shared
template fragments, and the stylesheet's section order. The passkey script is now
an ordinary asset (static/auth.js) under the same CSP as the rest.
server/issues_changes_test.go +13
| @@ -508,6 +508,19 @@ func TestLineAnchoredReviewCommentFromTheWeb(t *testing.T) { | |||
| 508 | 508 | t.Fatalf("anchored composer is not pre-filled:\n%s", page) | |
| 509 | 509 | } | |
| 510 | 510 | ||
| 511 | // A rejected anchored comment re-renders the discussion with the anchor still | ||
| 512 | // chosen, so the reader keeps the line they picked instead of being sent back to | ||
| 513 | // the Files tab to choose it again. | ||
| 514 | resp, body = f.htmxPost(t, "/r/"+f.repo+"/requests/"+id+"/comments", cookie, url.Values{ | ||
| 515 | "csrf": {sess.CSRF}, "body": {""}, | ||
| 516 | "path": {"readme.md"}, "line": {"2"}, "side": {"new"}, | ||
| 517 | }) | ||
| 518 | if resp.StatusCode != http.StatusOK || !strings.Contains(body, "Commenting on") || | ||
| 519 | !strings.Contains(body, `name="line" value="2"`) || | ||
| 520 | !strings.Contains(body, "a comment needs a body") { | ||
| 521 | t.Fatalf("rejected anchored comment = %d:\n%s", resp.StatusCode, body) | ||
| 522 | } | ||
| 523 | |||
| 511 | 524 | // Posting it through HTMX stores the anchor and returns the discussion. | |
| 512 | 525 | resp, body = f.htmxPost(t, "/r/"+f.repo+"/requests/"+id+"/comments", cookie, url.Values{ | |
| 513 | 526 | "csrf": {sess.CSRF}, "body": {"This line needs a second look."}, | |