summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornavanchauhan <navanchauhan@gmail.com>2022-10-17 22:37:56 -0600
committernavanchauhan <navanchauhan@gmail.com>2022-10-17 22:37:56 -0600
commitd040c7f166c58c5d065eb4c4fcf5e687b603b2ef (patch)
tree5113acd05ff95830cf70bbb7a8c35c1b6abdc6a3
parent24a0e7942a2e3917b856157344d3302fbac8a6d5 (diff)
add templates
-rw-r--r--main.go14
1 files 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)
}