From a6a7f26a42f71c75652bb362f695aa293b72fb50 Mon Sep 17 00:00:00 2001 From: kilo Date: Wed, 2 Aug 2017 19:34:17 +0200 Subject: [PATCH] Keep search content and keep refine open in no_results page (#1319) * Update search.go * Improvement You don't actually need to set a variable type. Golang infers it from the right side of the equal :). I needed in templates to do that since I need to use it in conditions. But since you removed the condition, it's not necessary --- controllers/search/search.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/controllers/search/search.go b/controllers/search/search.go index e9fb9573..afac1d59 100644 --- a/controllers/search/search.go +++ b/controllers/search/search.go @@ -48,12 +48,6 @@ func SearchHandler(c *gin.Context) { return } - maxPages := math.Ceil(float64(nbTorrents) / float64(searchParam.Max)) - if pagenum > int(maxPages) { - templates.Static(c, "errors/no_results.jet.html") - return - } - // Convert back to strings for now. category := "" if len(searchParam.Category) > 0 { @@ -67,5 +61,13 @@ func SearchHandler(c *gin.Context) { searchForm.ShowRefine = true } + maxPages := math.Ceil(float64(nbTorrents) / float64(searchParam.Max)) + if pagenum > int(maxPages) { + variables := templates.Commonvariables(c) + variables.Set("Search", searchForm) + templates.Render(c, "errors/no_results.jet.html", variables) + return + } + templates.ModelList(c, "site/torrents/listing.jet.html", models.TorrentsToJSON(torrents), nav, searchForm) }