From e565019669ae8e14803a8b7cd6617d77fbad3090 Mon Sep 17 00:00:00 2001 From: Shawn Smith Date: Wed, 20 Sep 2017 15:32:40 +0900 Subject: [PATCH] #205 add footer. closes #205 --- handlers/about.go | 2 +- handlers/error.go | 2 +- handlers/high_scores.go | 2 +- handlers/home.go | 2 +- handlers/report.go | 2 +- templates/404.html | 19 +------------------ templates/about.html | 19 +------------------ templates/footer.html | 20 ++++++++++++++++++++ templates/high_scores.html | 19 +------------------ templates/home.html | 19 +------------------ templates/report.html | 19 +------------------ 11 files changed, 30 insertions(+), 95 deletions(-) create mode 100644 templates/footer.html diff --git a/handlers/about.go b/handlers/about.go index 5a33219..3145e4a 100644 --- a/handlers/about.go +++ b/handlers/about.go @@ -10,7 +10,7 @@ import ( func AboutHandler(w http.ResponseWriter, r *http.Request) { log.Println("Serving about page") - t := template.Must(template.New("about.html").Delims("[[", "]]").ParseFiles("templates/about.html")) + t := template.Must(template.New("about.html").Delims("[[", "]]").ParseFiles("templates/about.html", "templates/footer.html")) t.Execute(w, map[string]interface{}{ "google_analytics_key": googleAnalyticsKey, }) diff --git a/handlers/error.go b/handlers/error.go index 14956a1..c3434d4 100644 --- a/handlers/error.go +++ b/handlers/error.go @@ -8,7 +8,7 @@ import ( func errorHandler(w http.ResponseWriter, r *http.Request, status int) { w.WriteHeader(status) if status == http.StatusNotFound { - t := template.Must(template.New("404.html").ParseFiles("templates/404.html")) + t := template.Must(template.New("404.html").ParseFiles("templates/404.html", "templates/footer.html")) t.Execute(w, nil) } } diff --git a/handlers/high_scores.go b/handlers/high_scores.go index c0d70fb..4774031 100644 --- a/handlers/high_scores.go +++ b/handlers/high_scores.go @@ -72,7 +72,7 @@ func HighScoresHandler(w http.ResponseWriter, r *http.Request) { } funcs := template.FuncMap{"add": add, "formatScore": formatScore} - t := template.Must(template.New("high_scores.html").Delims("[[", "]]").Funcs(funcs).ParseFiles("templates/high_scores.html")) + t := template.Must(template.New("high_scores.html").Delims("[[", "]]").Funcs(funcs).ParseFiles("templates/high_scores.html", "templates/footer.html")) sortedScores := make([]scoreItem, len(*scores)) for i := range sortedScores { diff --git a/handlers/home.go b/handlers/home.go index c38f33d..a156cda 100644 --- a/handlers/home.go +++ b/handlers/home.go @@ -48,7 +48,7 @@ func HomeHandler(w http.ResponseWriter, r *http.Request) { j-- } - t := template.Must(template.New("home.html").Delims("[[", "]]").ParseFiles("templates/home.html")) + t := template.Must(template.New("home.html").Delims("[[", "]]").ParseFiles("templates/home.html", "templates/footer.html")) t.Execute(w, map[string]interface{}{ "Recent": recentRepos, "google_analytics_key": googleAnalyticsKey, diff --git a/handlers/report.go b/handlers/report.go index 26af07d..6911547 100644 --- a/handlers/report.go +++ b/handlers/report.go @@ -15,7 +15,7 @@ var googleAnalyticsKey = flag.String("google_analytics_key", "UA-58936835-1", "G // ReportHandler handles the report page func ReportHandler(w http.ResponseWriter, r *http.Request, repo string, dev bool) { log.Printf("Displaying report: %q", repo) - t := template.Must(template.New("report.html").Delims("[[", "]]").ParseFiles("templates/report.html")) + t := template.Must(template.New("report.html").Delims("[[", "]]").ParseFiles("templates/report.html", "templates/footer.html")) resp, err := getFromCache(repo) needToLoad := false if err != nil { diff --git a/templates/404.html b/templates/404.html index 2b582a1..e9fdbf7 100644 --- a/templates/404.html +++ b/templates/404.html @@ -67,24 +67,7 @@ - + [[ template "footer" . ]]