Gallery: Retain search filters when toggling card types

face-detect
Noah Petherbridge 2023-11-05 14:20:41 -07:00
parent 3d01fc55f4
commit fae995e486
2 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import (
"html/template"
"net/http"
"net/url"
"sort"
"strings"
"time"
@ -211,6 +212,10 @@ func QueryPlus(r *http.Request) func(...interface{}) template.URL {
)
}
}
// Sort them deterministically.
sort.Strings(parts)
return template.URL(strings.Join(parts, "&"))
}
}

View File

@ -212,10 +212,10 @@
<div class="tabs is-toggle is-small is-hidden-mobile">
<ul>
<li{{if eq .ViewStyle "cards"}} class="is-active"{{end}}>
<a href="{{.Request.URL.Path}}?view=cards">Cards</a>
<a href="{{.Request.URL.Path}}?{{QueryPlus "view" "cards"}}">Cards</a>
</li>
<li{{if eq .ViewStyle "full"}} class="is-active"{{end}}>
<a href="{{.Request.URL.Path}}?view=full">Full</a>
<a href="{{.Request.URL.Path}}?{{QueryPlus "view" "full"}}">Full</a>
</li>
</ul>
</div>
@ -345,6 +345,9 @@
</div>
</div>
<!-- Retain cards vs. full parameter -->
<input type="hidden" name="view" value="{{.ViewStyle}}">
</form>
</div>