From 3777b818e3aae4fbe9489084f9770bf81ff2fe41 Mon Sep 17 00:00:00 2001 From: mitteneer Date: Sat, 31 May 2025 14:45:45 -0400 Subject: [PATCH] Create view for groups One of the largest components that makes zuletzt unique - implementing groups the way MusicBrainz has (release groups in particular). I thought for a while that I would just connect songs via a shared ID, but for remixes and such, I don't think they should be so tightly coupled. This also gives the user freedom for how they want to do the grouping (a remix can be included in the group if they choose to, or it may not). This will allow someone to see a combined scrobble number for an album with, for example, a regular release, a deluxe release, and an anniversary release, in addition to the individual releases. This will complicate SQL queries rather significantly I imagine, and I'm not sure what the interface for creating/deleting groups will be (although it will likely be easier when I have full use of TS), but it's a necessity for the project. --- src/app/views/groups.zig | 104 +++++++++++++++++++++++++++++++ src/app/views/groups/delete.zmpl | 3 + src/app/views/groups/edit.zmpl | 3 + src/app/views/groups/get.zmpl | 3 + src/app/views/groups/index.zmpl | 3 + src/app/views/groups/new.zmpl | 3 + src/app/views/groups/patch.zmpl | 3 + src/app/views/groups/post.zmpl | 3 + src/app/views/groups/put.zmpl | 3 + 9 files changed, 128 insertions(+) create mode 100644 src/app/views/groups.zig create mode 100644 src/app/views/groups/delete.zmpl create mode 100644 src/app/views/groups/edit.zmpl create mode 100644 src/app/views/groups/get.zmpl create mode 100644 src/app/views/groups/index.zmpl create mode 100644 src/app/views/groups/new.zmpl create mode 100644 src/app/views/groups/patch.zmpl create mode 100644 src/app/views/groups/post.zmpl create mode 100644 src/app/views/groups/put.zmpl diff --git a/src/app/views/groups.zig b/src/app/views/groups.zig new file mode 100644 index 0000000..85505c8 --- /dev/null +++ b/src/app/views/groups.zig @@ -0,0 +1,104 @@ +const std = @import("std"); +const jetzig = @import("jetzig"); + +pub fn index(request: *jetzig.Request) !jetzig.View { + return request.render(.ok); +} + +pub fn get(id: []const u8, request: *jetzig.Request) !jetzig.View { + _ = id; + return request.render(.ok); +} + +pub fn new(request: *jetzig.Request) !jetzig.View { + return request.render(.ok); +} + +pub fn edit(id: []const u8, request: *jetzig.Request) !jetzig.View { + _ = id; + return request.render(.ok); +} + +pub fn post(request: *jetzig.Request) !jetzig.View { + return request.render(.created); +} + +pub fn put(id: []const u8, request: *jetzig.Request) !jetzig.View { + _ = id; + return request.render(.ok); +} + +pub fn patch(id: []const u8, request: *jetzig.Request) !jetzig.View { + _ = id; + return request.render(.ok); +} + +pub fn delete(id: []const u8, request: *jetzig.Request) !jetzig.View { + _ = id; + return request.render(.ok); +} + + +test "index" { + var app = try jetzig.testing.app(std.testing.allocator, @import("routes")); + defer app.deinit(); + + const response = try app.request(.GET, "/groups", .{}); + try response.expectStatus(.ok); +} + +test "get" { + var app = try jetzig.testing.app(std.testing.allocator, @import("routes")); + defer app.deinit(); + + const response = try app.request(.GET, "/groups/example-id", .{}); + try response.expectStatus(.ok); +} + +test "new" { + var app = try jetzig.testing.app(std.testing.allocator, @import("routes")); + defer app.deinit(); + + const response = try app.request(.GET, "/groups/new", .{}); + try response.expectStatus(.ok); +} + +test "edit" { + var app = try jetzig.testing.app(std.testing.allocator, @import("routes")); + defer app.deinit(); + + const response = try app.request(.GET, "/groups/example-id/edit", .{}); + try response.expectStatus(.ok); +} + +test "post" { + var app = try jetzig.testing.app(std.testing.allocator, @import("routes")); + defer app.deinit(); + + const response = try app.request(.POST, "/groups", .{}); + try response.expectStatus(.created); +} + +test "put" { + var app = try jetzig.testing.app(std.testing.allocator, @import("routes")); + defer app.deinit(); + + const response = try app.request(.PUT, "/groups/example-id", .{}); + try response.expectStatus(.ok); +} + +test "patch" { + var app = try jetzig.testing.app(std.testing.allocator, @import("routes")); + defer app.deinit(); + + const response = try app.request(.PATCH, "/groups/example-id", .{}); + try response.expectStatus(.ok); +} + +test "delete" { + var app = try jetzig.testing.app(std.testing.allocator, @import("routes")); + defer app.deinit(); + + const response = try app.request(.DELETE, "/groups/example-id", .{}); + try response.expectStatus(.ok); +} diff --git a/src/app/views/groups/delete.zmpl b/src/app/views/groups/delete.zmpl new file mode 100644 index 0000000..76457d0 --- /dev/null +++ b/src/app/views/groups/delete.zmpl @@ -0,0 +1,3 @@ +
+ Content goes here +
diff --git a/src/app/views/groups/edit.zmpl b/src/app/views/groups/edit.zmpl new file mode 100644 index 0000000..76457d0 --- /dev/null +++ b/src/app/views/groups/edit.zmpl @@ -0,0 +1,3 @@ +
+ Content goes here +
diff --git a/src/app/views/groups/get.zmpl b/src/app/views/groups/get.zmpl new file mode 100644 index 0000000..76457d0 --- /dev/null +++ b/src/app/views/groups/get.zmpl @@ -0,0 +1,3 @@ +
+ Content goes here +
diff --git a/src/app/views/groups/index.zmpl b/src/app/views/groups/index.zmpl new file mode 100644 index 0000000..76457d0 --- /dev/null +++ b/src/app/views/groups/index.zmpl @@ -0,0 +1,3 @@ +
+ Content goes here +
diff --git a/src/app/views/groups/new.zmpl b/src/app/views/groups/new.zmpl new file mode 100644 index 0000000..76457d0 --- /dev/null +++ b/src/app/views/groups/new.zmpl @@ -0,0 +1,3 @@ +
+ Content goes here +
diff --git a/src/app/views/groups/patch.zmpl b/src/app/views/groups/patch.zmpl new file mode 100644 index 0000000..76457d0 --- /dev/null +++ b/src/app/views/groups/patch.zmpl @@ -0,0 +1,3 @@ +
+ Content goes here +
diff --git a/src/app/views/groups/post.zmpl b/src/app/views/groups/post.zmpl new file mode 100644 index 0000000..76457d0 --- /dev/null +++ b/src/app/views/groups/post.zmpl @@ -0,0 +1,3 @@ +
+ Content goes here +
diff --git a/src/app/views/groups/put.zmpl b/src/app/views/groups/put.zmpl new file mode 100644 index 0000000..76457d0 --- /dev/null +++ b/src/app/views/groups/put.zmpl @@ -0,0 +1,3 @@ +
+ Content goes here +