From d040c7f166c58c5d065eb4c4fcf5e687b603b2ef Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Mon, 17 Oct 2022 22:37:56 -0600 Subject: add templates --- main.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index c88f2b9..d2e6600 100644 --- a/main.go +++ b/main.go @@ -56,9 +56,9 @@ func main() { searchResTemplate := template.Must(template.New("results.gtpl").Funcs(funcMap).ParseFiles("templates/results.gtpl")) // v2.0 UI Templates - indexTemplate := template.Must(template.ParseFiles("templates/home.html")) - searchResultsTemplate2 := template.Must(template.New("search_results.html").Funcs(funcMap).ParseFiles("templates/search_results.html")) - documentDetailsTemplate2 := template.Must(template.ParseFiles("templates/document_details.html")) + indexTemplate := template.Must(template.ParseFiles("templates/home.html", "templates/components/section.html", "templates/components/header.html")) + searchResultsTemplate2 := template.Must(template.New("search_results.html").Funcs(funcMap).ParseFiles("templates/search_results.html", "templates/components/section.html", "templates/components/header.html")) + documentDetailsTemplate2 := template.Must(template.New("document_details.html").Funcs(funcMap).ParseFiles("templates/document_details.html", "templates/components/section.html", "templates/components/header.html")) index := client.Index("510k") @@ -68,6 +68,10 @@ func main() { }) }) + http.HandleFunc("/classic/search", func(w http.ResponseWriter, r *http.Request) { + searchHandler(w, r, index, searchResTemplate) + }) + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { indexTemplate.Execute(w, BaseResponse{ GlobalVars: globalVariables, @@ -82,10 +86,6 @@ func main() { searchHandler(w, r, index, searchResultsTemplate2) }) - http.HandleFunc("/classic/search", func(w http.ResponseWriter, r *http.Request) { - searchHandler(w, r, index, searchResTemplate) - }) - fmt.Println("Listening on port 8080") http.ListenAndServe(":8080", nil) } -- cgit v1.2.3