diff --git a/api/images_list.go b/api/images_list.go
index 135554c..22e24e1 100644
--- a/api/images_list.go
+++ b/api/images_list.go
@@ -17,7 +17,7 @@ import (
type ImageListParams struct {
Q string
- SFW bool
+ NSFW int32
OrderBy string
Sort string
Offset int64
@@ -29,14 +29,15 @@ type ImageListParams struct {
func (ilp *ImageListParams) FillFromQuery(query Queryable) {
ilp.Q = query.Get("q")
- ilp.SFW, _ = strconv.ParseBool(query.Get("sfw"))
+ if nsfw, err := strconv.Atoi(query.Get("nsfw")); err == nil {
+ ilp.NSFW = int32(nsfw)
+ } else {
+ ilp.NSFW = -1
+ }
ilp.OrderBy = query.Get("order_by")
ilp.Sort = strings.ToLower(query.Get("sort"))
ilp.Offset, _ = strconv.ParseInt(query.Get("offset"), 10, 64)
ilp.Limit, _ = strconv.ParseInt(query.Get("limit"), 10, 64)
- if ilp.Limit > 100 {
- ilp.Limit = 100
- }
if ilp.Limit < 1 {
ilp.Limit = 25
}
@@ -64,8 +65,8 @@ func (ilp ImageListParams) CountQuery() (expr []bob.Mod[*dialect.SelectQuery]) {
)
}
- if ilp.SFW {
- expr = append(expr, models.SelectWhere.Images.NSFW.EQ(0))
+ if ilp.NSFW >= 0 {
+ expr = append(expr, models.SelectWhere.Images.NSFW.EQ(ilp.NSFW))
}
if len(ilp.Device) > 0 {
diff --git a/views/homeview/homeview.templ b/views/homeview/homeview.templ
index 9a4dce5..68199fa 100644
--- a/views/homeview/homeview.templ
+++ b/views/homeview/homeview.templ
@@ -5,6 +5,7 @@ import "github.com/tigorlazuardi/redmage/views"
import "github.com/tigorlazuardi/redmage/views/utils"
import "strconv"
import "fmt"
+import "github.com/tigorlazuardi/redmage/api"
templ Home(c *views.Context, data Data) {
@components.Doctype() {
@@ -83,16 +84,30 @@ templ filterBar(c *views.Context, data Data) {
class="grid grid-cols-[1fr,4fr] sm:grid-cols-[1fr,4fr,1fr,4fr] items-center gap-4"
>
@nsfwToggle(data)
+ @limitInput(data.ImageListParams)
@recentRangeInput(c.Query.Get("created_at"))
}
+templ limitInput(params api.ImageListParams) {
+
+
+}
+
templ recentRangeInput(current string) {
}
@@ -113,10 +128,11 @@ templ nsfwToggle(data Data) {
}