add config: define custom wiki_name

This commit is contained in:
Anya Tokugawa committed 2026-05-31 21:18:13 +09:00
1 parent 12decb7862
commit 49a88460b4
12 files changed
+152 -28

No files matched your search

+31 -18
View File
@@ -20,8 +20,7 @@ func (s *Server) handleConfig(
return
}
section :=
r.FormValue("section")
section := r.FormValue("section")
switch section {
@@ -29,7 +28,17 @@ func (s *Server) handleConfig(
err = s.store.SetConfig(
"home_path",
r.FormValue("home_path"),
strings.TrimSpace(r.FormValue("home_path")),
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err = s.store.SetConfig(
"wiki_name",
strings.TrimSpace(r.FormValue("wiki_name")),
)
if err != nil {
@@ -39,18 +48,14 @@ func (s *Server) handleConfig(
case "nav":
labels :=
r.Form["nav_label"]
hrefs :=
r.Form["nav_href"]
labels := r.Form["nav_label"]
hrefs := r.Form["nav_href"]
var items []NavItem
for i := range labels {
label :=
strings.TrimSpace(labels[i])
label := strings.TrimSpace(labels[i])
if label == "" {
continue
@@ -60,8 +65,7 @@ func (s *Server) handleConfig(
continue
}
href :=
strings.TrimSpace(hrefs[i])
href := strings.TrimSpace(hrefs[i])
if href == "" {
continue
@@ -76,8 +80,7 @@ func (s *Server) handleConfig(
)
}
raw, err :=
json.Marshal(items)
raw, err := json.Marshal(items)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -115,16 +118,25 @@ func (s *Server) handleConfig(
return
}
homePath, err :=
s.store.GetConfig("home_path")
homePath, err := s.store.GetConfig("home_path")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
recent, err :=
s.store.ListRecentObjects(50)
wikiName, err := s.store.GetConfig("wiki_name")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if wikiName == "" {
wikiName = "Pages Wiki"
}
recent, err := s.store.ListRecentObjects(50)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -136,6 +148,7 @@ func (s *Server) handleConfig(
"config.gohtml",
map[string]any{
"HomePath": homePath,
"WikiName": wikiName,
"Objects": recent,
"NavItemsConfig": s.getNavItems(),
},