diff --git a/pug/includes/layout.pug b/pug/includes/layout.pug index 9a3deb1..98590f6 100644 --- a/pug/includes/layout.pug +++ b/pug/includes/layout.pug @@ -53,6 +53,12 @@ html .pl6 Region tags #location-tags-loading input(type="hidden" name="account" value=account) + if filter_field + input(type="hidden" name="filter_field" value=filter_field) + if filter + input(type="hidden" name="filter" value=filter) + if filter_fuzzy + input(type="hidden" name="filter_fuzzy" value=filter_fuzzy) .s-toggle-switch.s-toggle-switch__multiple - const locationTagsSetting = h3.getCookie(event, "bcex-location-tags") || "all" input#location-tags-all(type="radio" name="location_tags" value="all" autocomplete="off" checked=(locationTagsSetting === "all")) diff --git a/routes/schema.js b/routes/schema.js index 0037f5c..6d003c5 100644 --- a/routes/schema.js +++ b/routes/schema.js @@ -29,7 +29,10 @@ const schema = { }), locationTags: z.object({ location_tags: z.enum(["all", "hide", "only"]), - account + account, + filter_field: z.enum(["band_name", "band_url", "item_title", "item_id", "tag", "why"]).optional(), + filter: z.string().regex(/^[^%]+$/).optional(), + filter_fuzzy: z.enum(["true"]).optional() }) } diff --git a/routes/settings.js b/routes/settings.js index c98babd..b635cd9 100644 --- a/routes/settings.js +++ b/routes/settings.js @@ -17,7 +17,11 @@ router.post("/api/settings/inline-player", defineEventHandler(async event => { })) router.post("/api/settings/location-tags", defineEventHandler(async event => { - const {location_tags, account} = await readValidatedBody(event, schema.schema.locationTags.parse) + const {location_tags, account, filter, filter_field, filter_fuzzy} = await readValidatedBody(event, schema.schema.locationTags.parse) setCookie(event, "bcex-location-tags", location_tags) - return sendRedirect(event, `/${account}/?arrange=tag&shape=grid`) + const params = new URLSearchParams({arrange: "tag", shape: "grid"}) + if (filter) params.set("filter", filter) + if (filter_field) params.set("filter_field", filter_field) + if (filter_fuzzy) params.set("filter_fuzzy", filter_fuzzy) + return sendRedirect(event, `/${account}/?${params}`) }))