From b7e625dd9844e455496b729ddb9433a4560dcdc3 Mon Sep 17 00:00:00 2001 From: mitteneer Date: Mon, 23 Jun 2025 10:18:17 -0400 Subject: [PATCH] Start ratings This is actually fantastic, I'm really happy with how this has worked so far. My only concern for the future is how posting reviews from the `/ratings` path might work, since it's currently designed around posting reviews from the song page itself, but I think some HTMX and/or JS wil alleviate any problems I run into --- src/app/views/ratings/songs.zig | 12 ++++++++++++ src/app/views/ratings/songs/post.zmpl | 2 ++ src/app/views/songs/get.zmpl | 9 +++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/app/views/ratings/songs.zig create mode 100644 src/app/views/ratings/songs/post.zmpl diff --git a/src/app/views/ratings/songs.zig b/src/app/views/ratings/songs.zig new file mode 100644 index 0000000..3145fb4 --- /dev/null +++ b/src/app/views/ratings/songs.zig @@ -0,0 +1,12 @@ +const std = @import("std"); +const jetzig = @import("jetzig"); +pub fn post(request: *jetzig.Request) !jetzig.View { + var root = try request.data(.object); + const params = try request.params(); + const id = params.getT(.integer, "song_id"); + const review = params.getT(.string, "review"); + try root.put("song_id", id); + try root.put("review", review); + + return request.render(.created); +} diff --git a/src/app/views/ratings/songs/post.zmpl b/src/app/views/ratings/songs/post.zmpl new file mode 100644 index 0000000..3366a0c --- /dev/null +++ b/src/app/views/ratings/songs/post.zmpl @@ -0,0 +1,2 @@ +{{.song_id}} +{{.review}} \ No newline at end of file diff --git a/src/app/views/songs/get.zmpl b/src/app/views/songs/get.zmpl index 1ceddef..33e6886 100644 --- a/src/app/views/songs/get.zmpl +++ b/src/app/views/songs/get.zmpl @@ -5,6 +5,7 @@ + @@ -24,9 +25,13 @@

Rating

- - +
+ + + +
+
No reviews
\ No newline at end of file