From 61a312aba0a0414bba9f02719593cc62e483ebd3 Mon Sep 17 00:00:00 2001 From: orangix Date: Fri, 23 Jan 2026 16:54:56 +0100 Subject: [PATCH] implement random gallery (#245) closes #229 Reviewed-on: https://codeberg.org/rimgo/rimgo/pulls/245 Co-authored-by: orangix Co-committed-by: orangix --- api/trending.go | 4 ++++ pages/trending.go | 2 +- views/trending.hbs | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/api/trending.go b/api/trending.go index b69a345..9339981 100644 --- a/api/trending.go +++ b/api/trending.go @@ -36,6 +36,8 @@ func (client *Client) FetchTrending(section, sort, page string) ([]Submission, e case "best": q.Add("filter[window]", "all") q.Add("sort", "-top") + case "random": + q.Add("sort", "random") case "popular": fallthrough default: @@ -51,6 +53,8 @@ func (client *Client) FetchTrending(section, sort, page string) ([]Submission, e case "top": q.Add("filter[section]", "eq:top") q.Add("filter[window]", "day") + case "random": + q.Add("filter[section]", "eq:random") default: q.Add("filter[section]", "eq:hot") section = "hot" diff --git a/pages/trending.go b/pages/trending.go index c44a6d0..b513ca1 100644 --- a/pages/trending.go +++ b/pages/trending.go @@ -25,7 +25,7 @@ func HandleTrending(c *fiber.Ctx) error { section := c.Query("section") switch section { - case "hot", "new", "top": + case "hot", "new", "top", "random": default: section = "hot" } diff --git a/views/trending.hbs b/views/trending.hbs index eaaf732..3f786cf 100644 --- a/views/trending.hbs +++ b/views/trending.hbs @@ -30,20 +30,35 @@ Hot New Top + Random {{/equal}} {{#equal section "new"}} Hot New Top + Random {{/equal}} {{#equal section "top"}} Hot New Top + Random + {{/equal}} + {{#equal section "random"}} + Hot + New + Top + Random {{/equal}}
+ {{#equal section "random"}} + Popular + Newest + Best + {{/equal}} + {{#noteq section "random"}} {{#equal sort "popular"}} Popular Newest @@ -59,6 +74,7 @@ Newest Best {{/equal}} + {{/noteq}}