╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
802 } 803 804 // this list's page starting at `oid`: a repo's branch or tag keeps its ref (and 805 // its query) and moves `from` along, so the search box survives paging. a fork 806 // or an object view roots the page at the commit itself. 807 fn pageRoute(data: *const Self, oid: []const u8) ?ui.RoutablePage { 808 if (data.location != .repo or data.ref_or_oid == .object) { 809 return data.location.commitsRoute(.object, oid, 0, "", data.base_oid); 810 } 811 const route = data.location.commitsRoute(data.ref_or_oid, data.ref_or_oid_value, 0, "", data.base_oid) orelse return null; 812 const paged = route.withFrom(oid) orelse return null; 813 return paged.withSearch(data.search orelse return paged); 814 } 815 816 fn nextPageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 817 const route = pageRoute(data, oid) orelse return error.RouteTooLong; 818 const url = try route.toUrl(page_arena); 819 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 820 } 821 822 // the "a:" link to the files tab at commit `oid` (an object ref), at its root 823 // directory, within `location`. 824 fn filesObjectLink(page_arena: *std.heap.ArenaAllocator, location: ui.RoutablePage.RepoLocation, oid: []const u8) ![]const u8 { 825 const route = location.filesRoute(.object, oid, "", 0) orelse return error.RouteTooLong; 826 const url = try route.toUrl(page_arena); 827 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 828 } 829 830 // the in-page "ai:" anchor for selecting a commit with its current pane content 831 // and window. the href is only followed with js off. 832 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, commit: Commit, content: Content) ![]const u8 { 833 // a result roots the same results page at its commit, so the query 834 // survives following the row 835 if (data.search != null) { 836 const route = pageRoute(data, commit.oid) orelse return error.RouteTooLong; 837 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{try route.toUrl(page_arena)}); 838 } 839 const route = (switch (content) { 840 .message => data.location.commitMessageRoute(.object, commit.oid, data.base_oid), 841 .diff => |diff| data.location.commitsRoute(.object, commit.oid, commit.window.start, diff.path, data.base_oid), 842 }) orelse return error.RouteTooLong; 843 const url = try route.toUrl(page_arena); 844 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{url}); 845 } 846 847 // the "a:" link to the page showing `oid`'s message on its own. 848 fn messageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 849 const route = data.location.commitMessageRoute(.object, oid, data.base_oid) orelse return error.RouteTooLong; 850 const url = try route.toUrl(page_arena); 851 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 852 } 853