╭ changed ──╮ │src/web.zig│ ╰───────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────╮ │91 │ │92 // POST routes can be scoped by any page, so they can redirect using │ │93 // the base of the URL. this allows logging in to keep you on the page│ │94 - // you were on. local mode has no accounts, so only the issue routes. │ │94 + // you were on. local mode has no accounts, so only the repo routes. │ │95 if (method == .POST) { │ │96 switch (host) { │ │97 .remote => |remote| { │ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 98 - const PostRoute = enum { login, logout, ansi, issue, comment, open, close, edit, resolve };│ │ 98 + const PostRoute = enum { login, logout, ansi, new, edit, open, close, resolve }; │ │ 99 inline for (@typeInfo(PostRoute).@"enum".fields) |field| { │ │100 const suffix = "/" ++ field.name; │ │101 if (std.mem.endsWith(u8, path, suffix)) { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │104 .login => handleLogin(io, request, allocator, base, remote.admin_repo_path, remote.session_store),│ │105 .logout => handleLogout(request, base, remote.session_store), │ │106 .ansi => handleAnsi(io, request, allocator, base, remote.admin_repo_path, remote.session_store), │ │107 - .issue => handleIssue(io, request, allocator, base, host), │ │108 - .comment => handleComment(io, request, allocator, base, host), │ │107 + .new => handleNew(io, request, allocator, base, host), │ │108 + .edit => handleEdit(io, request, allocator, base, host), │ │109 .open => handleIssueStatus(io, request, allocator, base, host, .open), │ │110 .close => handleIssueStatus(io, request, allocator, base, host, .closed), │ │111 - .edit => handleEdit(io, request, allocator, base, host), │ │111 .resolve => handleIssueResolve(io, request, allocator, base, host), │ │112 }; │ │113 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │114 } │ │115 }, │ │116 .local => { │ │118 - const PostRoute = enum { issue, comment, open, close, edit, resolve };│ │117 + const PostRoute = enum { new, edit, open, close, resolve }; │ │118 inline for (@typeInfo(PostRoute).@"enum".fields) |field| { │ │119 const suffix = "/" ++ field.name; │ │120 if (std.mem.endsWith(u8, path, suffix)) { │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │121 const base = path[0 .. path.len - suffix.len]; │ │122 return switch (@field(PostRoute, field.name)) { │ │124 - .issue => handleIssue(io, request, allocator, base, host), │ │125 - .comment => handleComment(io, request, allocator, base, host), │ │123 + .new => handleNew(io, request, allocator, base, host), │ │124 + .edit => handleEdit(io, request, allocator, base, host), │ │125 .open => handleIssueStatus(io, request, allocator, base, host, .open), │ │126 .close => handleIssueStatus(io, request, allocator, base, host, .closed),│ │128 - .edit => handleEdit(io, request, allocator, base, host), │ │127 .resolve => handleIssueResolve(io, request, allocator, base, host), │ │128 }; │ │129 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │396 }); │ │397 } │ │398 │ │401 -// create an issue in the repo the form's page names (base is │ │402 -// "/repo/<owner>/<name>", or "" in local mode) and redirect to it │ │403 -fn handleIssue( │ │399 +// new actions share a suffix; the base identifies whether the form creates an │ │400 +// issue or comment. │ │401 +fn handleNew( │ │402 + io: std.Io, │ │403 + request: *std.http.Server.Request, │ │404 + allocator: std.mem.Allocator, │ │405 + base: []const u8, │ │406 + host: Host, │ │407 +) !void { │ │408 + if (commentBaseParts(base) != null) return handleCommentNew(io, request, allocator, base, host); │ │409 + │ │410 + const issues_suffix = "/issues"; │ │411 + if (std.mem.endsWith(u8, base, issues_suffix)) │ │412 + return handleIssueNew(io, request, allocator, base[0 .. base.len - issues_suffix.len], host);│ │413 + │ │414 + try request.respond("new event target not found", .{ │ │415 + .status = .not_found, │ │416 + .extra_headers = &.{.{ .name = "content-type", .value = "text/plain" }}, │ │417 + }); │ │418 +} │ │419 + │ │420 +// create an issue in the repo the form's page names and redirect to it. │ │421 +fn handleIssueNew( │ │422 io: std.Io, │ │423 request: *std.http.Server.Request, │ │424 allocator: std.mem.Allocator, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │501 try evt.consume(.xit, .{}, io, allocator, &repo, evt.events_ref, &[_]evt.EventWithId{event});│ │502 }, │ │503 .local => |src| { │ │486 - // the local form posts to "/issue", so base is empty │ │504 + // local routes elide the repo base │ │505 if (base.len != 0) { │ │506 try request.respond(not_found, .{ │ │507 .status = .not_found, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────╮ │558 │ │559 // create a reply from an issue or comment /new form, then redirect to its│ │560 // permalink. the rest of the url identifies the thread and parent. │ │543 -fn handleComment( │ │561 +fn handleCommentNew( │ │562 io: std.Io, │ │563 request: *std.http.Server.Request, │ │564 allocator: std.mem.Allocator, │ ╰───────────────────────────────────────────────────────────────────────────────╯