diff --git a/blog.go b/blog.go index 447cd6f..474181b 100644 --- a/blog.go +++ b/blog.go @@ -23,40 +23,40 @@ const ( ` ) -func latestBlogsHandle(w http.ResponseWriter, _ *http.Request) { +func latestBlogsHandle(w http.ResponseWriter, r *http.Request) { latest, err := blogApp.LatestBlogs(0) if err != nil { if err == backend.ErrNotFound { w.WriteHeader(404) - sendIndexWithContent(w, "Page not found", "", "") + sendContent(w, r, "Page not found", "", "") return } w.WriteHeader(http.StatusInternalServerError) log.Println("error getting latest blogs:", err) - sendIndexWithContent(w, "Error getting page", "", "") + sendContent(w, r, "Error getting page", "", "") return } var out string for _, b := range latest { out += blogElement(b) } - sendIndexWithContent(w, out, "", "") + sendContent(w, r, out, "", "") } -func blogHandle(w http.ResponseWriter, blog string) { +func blogHandle(w http.ResponseWriter, r *http.Request, blog string) { bl, err := blogApp.Blog(blog) if err != nil { if err == backend.ErrNotFound { w.WriteHeader(404) - sendIndexWithContent(w, "Page not found", "", "") + sendContent(w, r, "Page not found", "", "") return } w.WriteHeader(http.StatusInternalServerError) log.Printf("error getting blog %v: %v\n", blog, err) - sendIndexWithContent(w, "Error getting page", "", "") + sendContent(w, r, "Error getting page", "", "") return } - sendIndexWithContent(w, blogElement(bl), bl.Title, bl.Favicon) + sendContent(w, r, blogElement(bl), bl.Title, bl.Favicon) } func blogElement(b *blog.Blog) (out string) { diff --git a/files.go b/files.go index e844280..97ba543 100644 --- a/files.go +++ b/files.go @@ -45,9 +45,5 @@ func filesRequest(w http.ResponseWriter, r *http.Request) { return } } - if r.URL.Query().Get("contentOnly") == "true" { - w.Write([]byte(pageContent)) - } else { - sendIndexWithContent(w, pageContent, "Files", "") - } + sendContent(w, r, pageContent, "Files", "") } diff --git a/main.go b/main.go index 081b47d..3ca93c8 100644 --- a/main.go +++ b/main.go @@ -107,5 +107,5 @@ func mainHandle(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, filepath.Join(*webRoot, spl[0], "index.html")) return } - blogHandle(w, path) + blogHandle(w, r, path) } diff --git a/portfolio.go b/portfolio.go index cfaae0c..8f49d82 100644 --- a/portfolio.go +++ b/portfolio.go @@ -23,7 +23,7 @@ func portfolioRequest(w http.ResponseWriter, r *http.Request) { if err != nil { log.Println("error getting portfolio projects:", err) w.WriteHeader(http.StatusInternalServerError) - sendIndexWithContent(w, "Error getting portfolio", "", "") + sendContent(w, r, "Error getting portfolio", "", "") return } aboutMe := "