╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Attachment.zig ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
77 } 78 } 79 80 // whether a row is an attachment's, by the remove link on its ✕ 81 pub fn isRow(row: *wgt.Box(ui.Widget)) bool { 82 const last = row.children.values()[row.children.count() - 1].widget; 83 if (last != .text_box) return false; 84 const link = switch (last.text_box.focus.kind) { 85 .custom => |custom| custom, 86 else => return false, 87 }; 88 return std.mem.startsWith(u8, link, "a:") and std.mem.indexOf(u8, link, "/attachment:") != null and std.mem.endsWith(u8, link, "/remove"); 89 } 90 91 // the url an attachment's bytes are served from 92 pub fn url(page_arena: *std.heap.ArenaAllocator, identity: []const u8, id: []const u8) ![]const u8 { 93 return if (identity.len == 0) 94 try page_arena.allocator().print("/attachment:{s}", .{id}) 95 else 96 try page_arena.allocator().print("/{s}/attachment:{s}", .{ identity, id }); 97 } 98