╭ changed ────╮ │src/event.zig│ ╰─────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │30 pub const admin_repo_opts: rp.RepoOpts(.xit) = .{}; │ │31 pub const AdminDB = rp.Repo(.xit, admin_repo_opts).DB; │ │32 │ │33 +// the admin repo's file the home page renders │ │34 +pub const admin_about_path = "ABOUT.md"; │ │35 + │ │36 +// create the admin repo with a master branch holding the default about page. │ │37 +// pushes to master update its work dir. │ │38 +pub fn initAdminRepo(io: std.Io, allocator: std.mem.Allocator, path: []const u8) !rp.Repo(.xit, admin_repo_opts) { │ │39 + var repo = try rp.Repo(.xit, admin_repo_opts).init(io, allocator, .{ .path = path }); │ │40 + errdefer repo.deinit(io, allocator); │ │41 + try repo.addConfig(io, allocator, .{ .name = "receive.denycurrentbranch", .value = "updateInstead" }); │ │42 + { │ │43 + const file = try repo.core.work_dir.createFile(io, admin_about_path, .{}); │ │44 + defer file.close(io); │ │45 + try file.writeStreamingAll(io, "# HAXY\n\nWelcome to your Haxy instance!\n\nEdit `admin/ABOUT.md` in the server dir to change what this page says.");│ │46 + } │ │47 + try repo.add(io, allocator, &.{admin_about_path}); │ │48 + _ = try repo.commit(io, allocator, .{ .author = "haxy <haxy@localhost>", .message = "init" }); │ │49 + return repo; │ │50 +} │ │51 + │ │52 // the xitdb type events are stored in. it only depends on the hash kind, so │ │53 // this matches the db of any xit repo using that hash kind. │ │54 pub fn EventDB(comptime hash_kind: hash.HashKind) type { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯