diff --git a/blog.go b/blog.go
index abb6d94..19b5dab 100644
--- a/blog.go
+++ b/blog.go
@@ -18,7 +18,7 @@ const (
authorInfo = `
-  |
+  |
%v%v |
`
)
@@ -28,19 +28,19 @@ func latestBlogsHandle(w http.ResponseWriter, _ *http.Request) {
if err != nil {
if err == backend.ErrNotFound {
w.WriteHeader(404)
- sendIndexWithContent(w, "Page not found")
+ sendIndexWithContent(w, "Page not found", "", "")
return
}
w.WriteHeader(http.StatusInternalServerError)
log.Println("error getting latest blogs:", err)
- sendIndexWithContent(w, "Error getting page")
+ sendIndexWithContent(w, "Error getting page", "", "")
return
}
var out string
for _, b := range latest {
out += blogElement(b)
}
- sendIndexWithContent(w, out)
+ sendIndexWithContent(w, out, "", "")
}
func blogHandle(w http.ResponseWriter, blog string) {
@@ -48,15 +48,15 @@ func blogHandle(w http.ResponseWriter, blog string) {
if err != nil {
if err == backend.ErrNotFound {
w.WriteHeader(404)
- sendIndexWithContent(w, "Page not found")
+ sendIndexWithContent(w, "Page not found", "", "")
return
}
w.WriteHeader(http.StatusInternalServerError)
log.Printf("error getting blog %v: %v\n", blog, err)
- sendIndexWithContent(w, "Error getting page")
+ sendIndexWithContent(w, "Error getting page", "", "")
return
}
- sendIndexWithContent(w, blogElement(bl))
+ sendIndexWithContent(w, blogElement(bl), bl.Title, bl.Favicon)
}
func blogElement(b *blog.Blog) (out string) {
diff --git a/files.go b/files.go
index 271e0bb..e844280 100644
--- a/files.go
+++ b/files.go
@@ -48,6 +48,6 @@ func filesRequest(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("contentOnly") == "true" {
w.Write([]byte(pageContent))
} else {
- sendIndexWithContent(w, pageContent)
+ sendIndexWithContent(w, pageContent, "Files", "")
}
}
diff --git a/portfolio.go b/portfolio.go
index ce0ceeb..cfaae0c 100644
--- a/portfolio.go
+++ b/portfolio.go
@@ -23,16 +23,16 @@ 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")
+ sendIndexWithContent(w, "Error getting portfolio", "", "")
return
}
- aboutMe := "About Me
"
+ aboutMe := ""
if me, err := blogApp.AboutMe(); err != nil {
aboutMe += "Error getting info about me :("
} else {
aboutMe += authorSection(me)
}
- aboutMe += "My Projects
"
+ aboutMe += ""
langs := make(map[string]struct{})
out := ""
for _, p := range proj {
@@ -63,5 +63,5 @@ func portfolioRequest(w http.ResponseWriter, r *http.Request) {
}
}
out = aboutMe + fmt.Sprintf(portfolioSelector, tmp) + out
- sendIndexWithContent(w, out)
+ sendIndexWithContent(w, out, "Portfolio", "")
}
diff --git a/web.go b/web.go
index 755b65c..ac8da29 100644
--- a/web.go
+++ b/web.go
@@ -9,9 +9,13 @@ import (
"path/filepath"
)
-const replacementComment = ""
+const (
+ contentReplace = ""
+ faviconReplace = ""
+ titleReplace = ""
+)
-func sendIndexWithContent(w http.ResponseWriter, content string) {
+func sendIndexWithContent(w http.ResponseWriter, content string, title string, favicon string) {
indexFile, err := os.Open(filepath.Join(*webRoot, "index.html"))
if err != nil {
log.Println("error when opening main index.html:", err)
@@ -24,7 +28,15 @@ func sendIndexWithContent(w http.ResponseWriter, content string) {
w.WriteHeader(http.StatusInternalServerError)
return
}
- dat = bytes.ReplaceAll(dat, []byte(replacementComment), []byte(content))
+ dat = bytes.ReplaceAll(dat, []byte(contentReplace), []byte(content))
+ if title == "" {
+ title = "Darkstorm.tech"
+ }
+ dat = bytes.ReplaceAll(dat, []byte(titleReplace), []byte(title))
+ if favicon == "" {
+ favicon = "https://darkstorm.tech/favicon.png"
+ }
+ dat = bytes.ReplaceAll(dat, []byte(faviconReplace), []byte(favicon))
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Write(dat)
}