╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
438 detail_outer.getFocus().mode = .mouse; 439 try box.children.put(allocator, detail_outer.getFocus().id, .{ .widget = .{ .box = detail_outer }, .rect = null, .min_size = .{ .width = detail_min_width, .height = null } }); 440 } 441 442 // the page opens on the list, unless the url names a commit 443 box.getFocus().child_id = box.children.keys()[if (data.ref_or_oid == .object) detail_index else list_index]; 444 try outer.children.put(allocator, box.getFocus().id, .{ .widget = .{ .box = box }, .rect = null, .min_size = null }); 445 446 // focus lives in the split, except that search results start in the 447 // search box so the query can be refined right away. 448 outer.getFocus().child_id = outer.children.keys()[if (data.search != null) header_index else outer.children.count() - 1]; 449 450 return .{ 451 .box = outer, 452 .data = data, 453 .session = session, 454 .detailed_index = null, 455 }; 456 } 457 458 fn addRow(allocator: std.mem.Allocator, box: *wgt.Box(ui.Widget), label: []const u8, link: []const u8, bottom_label: []const u8) !void { 459 var row = try wgt.TextBox.init(allocator, label, .{ .border = .hidden, .round_corners = true, .wrap_kind = .word, .bottom_label = .{ .text = bottom_label } }); 460 errdefer row.deinit(allocator); 461 row.getFocus().mode = .all; 462 if (link.len != 0) row.getFocus().kind = .{ .custom = link }; 463 try box.children.put(allocator, row.getFocus().id, .{ .widget = .{ .text_box = row }, .rect = null, .min_size = null, .max_size = .{ .width = null, .height = 5 } }); 464 } 465 466 // a focusable row following the "a:" `link`. 467 fn addLink(allocator: std.mem.Allocator, box: *wgt.Box(ui.Widget), label: []const u8, link: []const u8) !void { 468 var tb = try wgt.TextBox.init(allocator, label, .{ .border = .single, .round_corners = true, .wrap_kind = .none }); 469 errdefer tb.deinit(allocator); 470 tb.getFocus().mode = .all; 471 tb.getFocus().kind = .{ .custom = link }; 472 try box.children.put(allocator, tb.getFocus().id, .{ .widget = .{ .text_box = tb }, .rect = null, .min_size = null }); 473 } 474 475 // how much of the message a pane's box holds: a truncated preview links to 476 // the pane holding the whole thing, which is that link's destination. 477 const MessageBox = enum { preview, whole }; 478 479 // the selected commit's message. 480 fn addMessageBox(self: *View, allocator: std.mem.Allocator, box: *wgt.Box(ui.Widget), commit: Commit, kind: MessageBox) !void { 481 // a truncated message keeps its box even with no whole line to show, 482 // since the box is what links to the whole thing. 483 if (commit.message.len == 0 and !commit.message_truncated) return; 484 const cut_short = commit.message_truncated and kind == .preview; 485 var tb = try messageBox(allocator, commit.message, if (cut_short) " click or press enter to see more " else ""); 486 errdefer tb.deinit(allocator); 487 if (cut_short) tb.getFocus().kind = .{ .custom = try messageLink(self.session.page_arena, self.data, commit.oid) }; 488 try box.children.put(allocator, tb.getFocus().id, .{ .widget = .{ .text_box = tb }, .rect = null, .min_size = null }); 489 } 490 491 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 492 self.box.deinit(allocator); 493 } 494 495 // the split is last, after the sub-header where there is one 496 fn contentIndex(self: *View) usize { 497 return self.box.children.count() - 1; 498 } 499 500 fn contentBox(self: *View) *wgt.Box(ui.Widget) { 501 return &self.box.children.values()[self.contentIndex()].widget.box; 502 } 503 504 fn header(self: *View) ?*ui.widget.SearchHeader { 505 switch (self.box.children.values()[header_index].widget) { 506 .search_header => |*header_view| return header_view, 507 else => return null, 508 } 509 } 510 511 fn headerActive(self: *View) bool { 512 const header_view = self.header() orelse return false; 513 return self.box.getFocus().child_id == header_view.getFocus().id; 514 } 515 516 fn listScroll(self: *View) *wgt.Scroll(ui.Widget) { 517 return &self.contentBox().children.values()[list_index].widget.scroll; 518 } 519 520 fn listBox(self: *View) *wgt.Box(ui.Widget) { 521 return &self.listScroll().child.box; 522 } 523 524 fn detailOuter(self: *View) *wgt.Box(ui.Widget) { 525 return &self.contentBox().children.values()[detail_index].widget.box; 526 } 527 528 fn detailScroll(self: *View) *wgt.Scroll(ui.Widget) { 529 return &self.detailOuter().children.values()[0].widget.scroll; 530 } 531 532 fn detailInner(self: *View) *wgt.Box(ui.Widget) { 533 return &self.detailScroll().child.box; 534 } 535 536 fn detailActive(self: *View) bool { 537 const content = self.contentBox(); 538 const cid = content.getFocus().child_id orelse return false; 539 return content.children.getIndex(cid) == detail_index; 540 } 541 542 // the selected commit's index, or null when the "next" row is selected. 543 fn selectedCommitIndex(self: *View) ?usize { 544 const lb = self.listBox(); 545 const cid = lb.getFocus().child_id orelse return null; 546 const idx = lb.children.getIndex(cid) orelse return null; 547 if (idx >= self.data.commits.len) return null; 548 return idx; 549 } 550 551 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 552 self.clearGrid(); 553 if (self.data.no_commits) return self.box.build(allocator, constraint, root_focus); 554 555 // swap the detail pane to the selected commit when it changes. 556 try self.refreshDetail(allocator); 557 558 // the selected list row shows a border (the focused TextBox upgrades it 559 // to a double border itself); the rest stay borderless. 560 const lb = self.listBox(); 561 for (lb.children.keys(), lb.children.values()) |id, *child| { 562 switch (child.widget) { 563 .text_box => |*tb| ui.widget.markSelected(tb, lb.getFocus().child_id == id), 564 else => {}, 565 } 566 } 567 568 // cap the list at list_max_width only while the detail pane fits beside it. 569 // the box drops the pane when the width can't hold both minimums, so when 570 // it's that narrow we lift the cap and let the list fill the whole width. 571 const both_panes_fit = if (constraint.max_size.width) |w| w >= list_max_width + detail_min_width else true; 572 self.contentBox().children.values()[list_index].max_size = if (both_panes_fit) .{ .width = list_max_width, .height = null } else null; 573 574 // stretch the detail pane across the rest of the width so it fills the area 575 // rather than shrinking to its content; its scroll fills the pane. when 576 // too narrow for both, it fills the whole width. 577 const detail_width: usize = if (constraint.max_size.width) |w| 578 (if (both_panes_fit) w - list_max_width else w) 579 else 580 detail_min_width; 581 self.contentBox().children.values()[detail_index].min_size = .{ .width = detail_width, .height = null }; 582 583 // the web bounds the layout to the browser viewport like the terminal; 584 // each Scroll's web-native mode hands its full content to a real 585 // scrollable element, so we no longer build unbounded here. 586 // 587 // crossing panes only re-selects the content box's child (focusDetail / 588 // focusList); when the window is too narrow to show both, the pane that 589 // held focus is dropped here. the framework recovers focus after the 590 // top-level build by re-deriving it down the selected-child chain, so 591 // there's nothing to fix up afterward. 592 try self.box.build(allocator, constraint, root_focus); 593 } 594 595 fn refreshDetail(self: *View, allocator: std.mem.Allocator) !void { 596 const sel = self.selectedCommitIndex() orelse return; 597 if (self.detailed_index) |d| if (d == sel) return; 598 try self.populateDetail(allocator, sel); 599 self.detailed_index = sel; 600 } 601 602 fn populateDetail(self: *View, allocator: std.mem.Allocator, sel: usize) !void { 603 const commit = self.data.commits[sel]; 604 const inner = self.detailInner(); 605 606 for (inner.children.values()) |*child| child.widget.deinit(allocator); 607 inner.children.clearAndFree(allocator); 608 inner.getFocus().child_id = null; 609 610 if (sel == 0 and self.data.message) { 611 try addLink(allocator, inner, "← back to commit", try commitsLink(self.session.page_arena, self.data, commit.oid)); 612 try self.addMessageBox(allocator, inner, commit, .whole); 613 } else { 614 const pa = self.session.page_arena; 615 { 616 var row = try wgt.Box(ui.Widget).init(allocator, .{ .border = null, .direction = .horiz }); 617 errdefer row.deinit(allocator); 618 const diff_route = self.data.handle.location.commitDiffRoute(commit.oid, commit.parent_oid) orelse return error.RouteTooLong; 619 try addLink(allocator, &row, "view diff", try pa.allocator().print("a:{s}", .{try diff_route.toUrl(pa)})); 620 try addLink(allocator, &row, "view files at this commit", try filesObjectLink(pa, self.data.handle.location, commit.oid)); 621 row.getFocus().child_id = row.children.keys()[0]; 622 try inner.children.put(allocator, row.getFocus().id, .{ .widget = .{ .box = row }, .rect = null, .min_size = null }); 623 } 624 if (commit.merge) if (self.data.handle.location.commitsMergeRoute(commit.oid)) |route| { 625 try addLink(allocator, inner, "view commits from this merge", try pa.allocator().print("a:{s}", .{try route.toUrl(pa)})); 626 }; 627 { 628 var row = try wgt.Box(ui.Widget).init(allocator, .{ .border = null, .direction = .horiz }); 629 errdefer row.deinit(allocator); 630 if (commit.author != .unknown) { 631 var tb = try ui.authorBox(allocator, pa, commit.author); 632 errdefer tb.deinit(allocator); 633 try row.children.put(allocator, tb.getFocus().id, .{ .widget = .{ .text_box = tb }, .rect = null, .min_size = null }); 634 } 635 if (commit.committer != .unknown) { 636 var tb = try ui.authorBox(allocator, pa, commit.committer); 637 errdefer tb.deinit(allocator); 638 tb.options.top_label.text = " committer "; 639 try row.children.put(allocator, tb.getFocus().id, .{ .widget = .{ .text_box = tb }, .rect = null, .min_size = null }); 640 } 641 const timestamp = try ui.timestamp.format(pa.allocator(), commit.timestamp, try self.session.nowSeconds()); 642 var tb = try wgt.TextBox.init(allocator, timestamp.relative, .{ .border = .single, .round_corners = true, .wrap_kind = .none, .bottom_label = .{ .text = timestamp.exact } }); 643 errdefer tb.deinit(allocator); 644 tb.getFocus().mode = .all; 645 try row.children.put(allocator, tb.getFocus().id, .{ .widget = .{ .text_box = tb }, .rect = null, .min_size = null }); 646 row.getFocus().child_id = row.children.keys()[0]; 647 try inner.children.put(allocator, row.getFocus().id, .{ .widget = .{ .box = row }, .rect = null, .min_size = null }); 648 } 649 if (commit.stats) |stats| { 650 var text: std.Io.Writer.Allocating = .init(allocator); 651 defer text.deinit(); 652 try text.writer.print("lines changed: {d}", .{stats.lines_added + stats.lines_changed}); 653 if (stats.lines_removed != 0) try text.writer.print("\nlines removed: {d}", .{stats.lines_removed}); 654 const bytes_added = stats.bytes_added >= stats.bytes_removed; 655 const bytes = if (bytes_added) stats.bytes_added - stats.bytes_removed else stats.bytes_removed - stats.bytes_added; 656 try text.writer.print("\nbytes {s}: {d}\nfiles changed: {d}", .{ 657 if (bytes_added) "added" else "removed", bytes, stats.files_added + stats.files_changed, 658 }); 659 if (stats.files_removed != 0) try text.writer.print("\nfiles removed: {d}", .{stats.files_removed}); 660 var tb = try wgt.TextBox.init(allocator, text.written(), .{ .border = .single, .round_corners = true, .wrap_kind = .none, .top_label = .{ .text = " stats " } }); 661 errdefer tb.deinit(allocator); 662 tb.getFocus().mode = .all; 663 try inner.children.put(allocator, tb.getFocus().id, .{ .widget = .{ .text_box = tb }, .rect = null, .min_size = null }); 664 } 665 try self.addMessageBox(allocator, inner, commit, .preview); 666 } 667 668 // point the pane at its first row so focus recovery can land here. 669 if (inner.children.count() > 0) inner.getFocus().child_id = inner.children.keys()[0]; 670 671 // reset the scroll to the top for the newly-shown commit: directly on the 672 // terminal (the wasm offset), and via a version bump on the web (so the 673 // renderer's scroll id changes and JS drops the preserved position). 674 const sc = self.detailScroll(); 675 sc.x = 0; 676 sc.y = 0; 677 sc.getFocus().version +%= 1; 678 } 679 680 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 681 if (self.data.no_commits) return self.box.input(allocator, key, root_focus); 682 // scrolling crosses the sub header boundary the same way arrows do 683 const direction = inp.vertDirection(key); 684 if (self.headerActive()) { 685 // active means there is one 686 const header_view = self.header() orelse unreachable; 687 if (direction == .down) { 688 root_focus.setFocus(self.contentBox().getFocus().id); 689 return; 690 } 691 if (key == .enter) if (try header_view.submittedText(allocator)) |text| { 692 defer allocator.free(text); 693 return self.submit(text); 694 }; 695 return header_view.input(allocator, key, root_focus); 696 } 697 if (direction == .up and self.contentAtTop() and self.focusHeader(root_focus)) return; 698 if (self.detailActive()) { 699 const inner = self.detailInner(); 700 if (inp.rowDelta(key, @intCast(inner.children.count()))) |delta| { 701 ui.widget.moveRowFocus(inner, self.detailScroll(), root_focus, delta); 702 } else if (key == .arrow_left) { 703 if (!ui.widget.moveInSelectedRow(inner, root_focus, false)) self.focusList(root_focus); 704 } else if (key == .arrow_right) { 705 _ = ui.widget.moveInSelectedRow(inner, root_focus, true); 706 } 707 } else { 708 try self.listInput(allocator, key, root_focus); 709 } 710 } 711 712 // navigate to the typed query's results, pinned to the list's ref. an 713 // empty query leaves the results for the plain log. 714 fn submit(self: *View, text: []const u8) !void { 715 if (text.len == 0 and self.data.search == null) return; 716 // an object view or a base-bounded list searches the default branch, so the url says so 717 const route = if (self.data.default_branch.len != 0) 718 self.data.handle.location.commitsRoute(.branch, self.data.default_branch, "") 719 else 720 self.data.handle.location.commitsRoute(self.data.ref_or_oid, self.data.ref_or_oid_value, self.data.base_oid); 721 try self.session.navigate((route orelse return).withSearch(text) orelse return); 722 } 723 724 fn listInput(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 725 // up/down (and the scroll wheel) move the selection a row; page up/down 726 // jump a fixed amount. right/Enter cross into the detail pane. Enter/clicks 727 // on the "next" row become navigation in the host before reaching here. 728 if (inp.rowDelta(key, @intCast(self.listBox().children.count()))) |delta| { 729 ui.widget.moveRowFocus(self.listBox(), self.listScroll(), root_focus, delta); 730 return; 731 } 732 switch (key) { 733 .enter => if (self.selectedCommitIndex() != null) 734 self.focusDetail(root_focus) 735 else if (self.data.next_start) |next| { 736 if (pageRoute(self.data, next)) |route| try self.session.navigate(route); 737 }, 738 .arrow_right => self.focusDetail(root_focus), 739 // when the window is too narrow to lay out the detail pane beside 740 // the list, a click on a row opens it like enter. the row was just 741 // selected, so the detail is swapped to it ahead of the build. 742 .mouse => |mouse| if (self.contentBox().children.values()[detail_index].rect == null and ui.widget.clickOnSelectedRow(self.listBox(), root_focus, mouse)) { 743 try self.refreshDetail(allocator); 744 self.focusDetail(root_focus); 745 }, 746 else => {}, 747 } 748 } 749 750 // enter the detail pane. the host arrives here on right-arrow or Enter from the 751 // list. a pane with no rows can't be entered. setFocus handles the too-narrow 752 // case where the pane isn't laid out yet (it gets selected, then focused after 753 // the next build, landing on its remembered row). 754 fn focusDetail(self: *View, root_focus: *Focus) void { 755 if (self.detailInner().children.count() == 0) return; 756 root_focus.setFocus(self.detailOuter().getFocus().id); 757 } 758 759 // return to the list. 760 fn focusList(self: *View, root_focus: *Focus) void { 761 root_focus.setFocus(self.listScroll().getFocus().id); 762 } 763 764 pub fn clearGrid(self: *View) void { 765 self.box.clearGrid(); 766 } 767 768 pub fn getGrid(self: View) ?Grid { 769 return self.box.getGrid(); 770 } 771 772 pub fn getFocus(self: *View) *Focus { 773 return self.box.getFocus(); 774 } 775 776 fn contentAtTop(self: *View) bool { 777 if (self.detailActive()) { 778 const inner = self.detailInner(); 779 const cid = inner.getFocus().child_id orelse return true; 780 const first_focused = inner.children.count() > 0 and cid == inner.children.keys()[0]; 781 return first_focused and self.detailScroll().y == 0; 782 } 783 const lb = self.listBox(); 784 const cid = lb.getFocus().child_id orelse return true; 785 return lb.children.getIndex(cid) == 0; 786 } 787 788 // only the header's own row sits directly below the repository header. 789 pub fn atTop(self: *View) bool { 790 if (self.data.no_commits) return true; 791 const focusable = if (self.header()) |header_view| header_view.hasFocusable() else false; 792 return self.headerActive() or (!focusable and self.contentAtTop()); 793 } 794 795 pub fn focusHeader(self: *View, root_focus: *Focus) bool { 796 const header_view = self.header() orelse return false; 797 return header_view.focusHeader(root_focus); 798 } 799 }; 800 801 // the "a:" navigation link for the commits page walking from commit `oid` within 802 // `data.handle.location`. 803 fn commitsLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 804 const route = data.handle.location.commitsRoute(.object, oid, data.base_oid) orelse return error.RouteTooLong; 805 const url = try route.toUrl(page_arena); 806 return page_arena.allocator().print("a:{s}", .{url}); 807 } 808 809 // this list's page starting at `oid`: a repo's branch or tag keeps its ref (and 810 // its query) and moves `from` along, so the search box survives paging. a fork 811 // or an object view roots the page at the commit itself. 812 fn pageRoute(data: *const Self, oid: []const u8) ?ui.RoutablePage { 813 if (data.handle.location != .repo or data.ref_or_oid == .object) { 814 return data.handle.location.commitsRoute(.object, oid, data.base_oid); 815 } 816 const route = data.handle.location.commitsRoute(data.ref_or_oid, data.ref_or_oid_value, data.base_oid) orelse return null; 817 const paged = route.withFrom(oid) orelse return null; 818 return paged.withSearch(data.search orelse return paged); 819 } 820 821 fn nextPageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 822 const route = pageRoute(data, oid) orelse return error.RouteTooLong; 823 const url = try route.toUrl(page_arena); 824 return page_arena.allocator().print("a:{s}", .{url}); 825 } 826 827 // the "a:" link to the files tab at commit `oid` (an object ref), at its root 828 // directory, within `location`. 829 fn filesObjectLink(page_arena: *std.heap.ArenaAllocator, location: ui.RoutablePage.RepoLocation, oid: []const u8) ![]const u8 { 830 const route = location.filesRoute(.object, oid, "", 0) orelse return error.RouteTooLong; 831 const url = try route.toUrl(page_arena); 832 return page_arena.allocator().print("a:{s}", .{url}); 833 } 834 835 // the in-page "ai:" anchor for selecting a commit, showing its whole message 836 // when `message` is set. the href is only followed with js off. 837 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, commit: Commit, message: bool) ![]const u8 { 838 // a result roots the same results page at its commit, so the query 839 // survives following the row 840 if (data.search != null) { 841 const route = pageRoute(data, commit.oid) orelse return error.RouteTooLong; 842 return page_arena.allocator().print("ai:{s}", .{try route.toUrl(page_arena)}); 843 } 844 const route = (if (message) 845 data.handle.location.commitMessageRoute(.object, commit.oid, data.base_oid) 846 else 847 data.handle.location.commitsRoute(.object, commit.oid, data.base_oid)) orelse return error.RouteTooLong; 848 const url = try route.toUrl(page_arena); 849 return page_arena.allocator().print("ai:{s}", .{url}); 850 } 851 852 // the "a:" link to the page showing `oid`'s message on its own. 853 fn messageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 854 const route = data.handle.location.commitMessageRoute(.object, oid, data.base_oid) orelse return error.RouteTooLong; 855 const url = try route.toUrl(page_arena); 856 return page_arena.allocator().print("a:{s}", .{url}); 857 } 858