From 4db18631a12a1e971bb2ac8cfdc5836075bd5792 Mon Sep 17 00:00:00 2001 From: Yader Velasquez Date: Wed, 14 Feb 2024 12:16:33 -0600 Subject: [PATCH] Fix broken advanced form and add new functions to shorts References: https://todo.code.netlandish.com/~netlandish/links/47 --- short/routes.go | 9 +++++++-- templates/link_short_list.html | 18 +++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/short/routes.go b/short/routes.go index 7fc9ab7..662b94e 100644 --- a/short/routes.go +++ b/short/routes.go @@ -9,6 +9,7 @@ import ( "links/internal/localizer" "links/models" "net/http" + "net/url" "strconv" "strings" "time" @@ -118,14 +119,17 @@ func (s *Service) LinkShortList(c echo.Context) error { op.Var("slug", slug) var tag, excludeTag string + queries := make(url.Values) if c.QueryParam("tag") != "" { tag = c.QueryParam("tag") op.Var("tag", tag) + queries.Add("tag", tag) } if c.QueryParam("exclude") != "" { excludeTag = c.QueryParam("exclude") op.Var("excludeTag", excludeTag) + queries.Add("exclude", excludeTag) } if c.QueryParam("next") != "" { @@ -168,9 +172,10 @@ func (s *Service) LinkShortList(c echo.Context) error { "links": linkShorts, "org": org, "navFlag": "short", - "tagFilter": tag, - "excludeTagFilter": excludeTag, + "tagFilter": strings.Replace(tag, ",", ", ", -1), + "excludeTagFilter": strings.Replace(excludeTag, ",", ", ", -1), "advancedSearch": true, + "queries": queries, } if result.LinkShorts.PageInfo.HasPrevPage { diff --git a/templates/link_short_list.html b/templates/link_short_list.html index 9f294d9..2d01341 100644 --- a/templates/link_short_list.html +++ b/templates/link_short_list.html @@ -3,12 +3,10 @@

{{ .org.Name }} {{.pd.Title}}

{{.pd.Data.add}} - -
- {{if .advancedSearch}} -

{{.pd.Data.advanced_search}}

-
-
+{{ if not .hideNav }}

{{.pd.Data.advanced_search}}

{{ end }} +{{if and (not .hideNav) (.advancedSearch)}} +
+
@@ -29,8 +27,10 @@
- - {{end}} +
+{{end}} + +
@@ -58,7 +58,7 @@ #{{.Name}} {{else}} #{{.Name}} + href="{{if $.queries}}?{{addQueryElement $.queries "tag" .Slug}}{{else}}?tag={{.Slug}}{{end}}">#{{.Name}} {{end}} {{end}} -- 2.45.2