Got actual HTML stuff for blog & portfolio done
This commit is contained in:
+30
-1
@@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,13 +18,21 @@ const (
|
||||
)
|
||||
|
||||
func portfolioRequest(w http.ResponseWriter, r *http.Request) {
|
||||
proj, err := blogApp.Projects(r.URL.Query().Get("lang"))
|
||||
selectedLang := r.URL.Query().Get("lang")
|
||||
proj, err := blogApp.Projects(selectedLang)
|
||||
if err != nil {
|
||||
log.Println("error getting portfolio projects:", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
sendIndexWithContent(w, "Error getting portfolio")
|
||||
return
|
||||
}
|
||||
aboutMe := "<h1 style='margin-bottom:-5px'>About Me</h1>"
|
||||
if me, err := blogApp.AboutMe(); err != nil {
|
||||
aboutMe += "Error getting info about me :("
|
||||
} else {
|
||||
aboutMe += authorSection(me)
|
||||
}
|
||||
aboutMe += "<h1 style='margin-bottom:15px'>My Projects</h1>"
|
||||
langs := make(map[string]struct{})
|
||||
out := ""
|
||||
for _, p := range proj {
|
||||
@@ -34,5 +44,24 @@ func portfolioRequest(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
out += fmt.Sprintf(portfolioDesc, p.Description)
|
||||
}
|
||||
langKeys := make([]string, 0, len(langs))
|
||||
for k := range langs {
|
||||
langKeys = append(langKeys, k)
|
||||
}
|
||||
slices.Sort(langKeys)
|
||||
var tmp string
|
||||
if selectedLang == "" {
|
||||
tmp = fmt.Sprintf(portfolioSelectorOption, "", " selected=true", "All")
|
||||
} else {
|
||||
tmp = fmt.Sprintf(portfolioSelectorOption, "", "", "All")
|
||||
}
|
||||
for _, k := range langKeys {
|
||||
if selectedLang == strings.ToLower(k) {
|
||||
tmp += fmt.Sprintf(portfolioSelectorOption, strings.ToLower(k), " selected=true", k)
|
||||
} else {
|
||||
tmp += fmt.Sprintf(portfolioSelectorOption, strings.ToLower(k), "", k)
|
||||
}
|
||||
}
|
||||
out = aboutMe + fmt.Sprintf(portfolioSelector, tmp) + out
|
||||
sendIndexWithContent(w, out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user