added "next" button for videos

This commit is contained in:
partisan 2024-06-10 13:12:09 +02:00
parent b3eb7e39ea
commit fe96287442
2 changed files with 35 additions and 18 deletions

View file

@ -180,16 +180,23 @@ func handleVideoSearch(w http.ResponseWriter, query, safe, lang string, page int
}
elapsed := time.Since(start)
tmpl, err := template.ParseFiles("templates/videos.html")
tmpl, err := template.New("videos.html").Funcs(funcs).ParseFiles("templates/videos.html")
if err != nil {
log.Printf("Error parsing template: %v", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return
}
tmpl.Execute(w, map[string]interface{}{
err = tmpl.Execute(w, map[string]interface{}{
"Results": results,
"Query": query,
"Fetched": fmt.Sprintf("%.2f seconds", elapsed.Seconds()),
"Page": page,
"HasPrevPage": page > 1,
"HasNextPage": len(results) > 0, // assuming you have a way to determine if there are more pages
})
if err != nil {
log.Printf("Error executing template: %v", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
}
}