Add Timezone, Zombie GC. Improved and select theme.

This commit is contained in:
Anya Tokugawa committed 2026-06-01 00:13:30 +09:00
1 parent ea3eba180b
commit 5a596985e0
26 files changed
+605 -59

No files matched your search

+119 -1
View File
@@ -3,7 +3,9 @@ package server
import (
"encoding/json"
"net/http"
"strconv"
"strings"
"time"
)
func parseNavItemsFromForm(
@@ -132,6 +134,87 @@ func (s *Server) handleConfig(
return
}
timezoneName :=
strings.TrimSpace(
r.FormValue("timezone"),
)
if timezoneName == "" {
timezoneName = "UTC"
}
_, err = time.LoadLocation(
timezoneName,
)
if err != nil {
http.Error(w, "invalid timezone", http.StatusBadRequest)
return
}
err = s.store.SetConfig(
"timezone",
timezoneName,
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
theme :=
s.getTheme()
if v := strings.TrimSpace(r.FormValue("theme")); v != "" {
switch v {
case "dark", "light", "monokai", "solarized-dark", "solarized-light":
theme = v
default:
http.Error(w, "invalid theme", http.StatusBadRequest)
return
}
}
err = s.store.SetConfig(
"theme",
theme,
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
graceHours :=
strings.TrimSpace(
r.FormValue("zombie_grace_hours"),
)
if graceHours == "" {
graceHours = "24"
}
_, err = strconv.ParseInt(
graceHours,
10,
64,
)
if err != nil {
http.Error(w, "invalid zombie grace hours", http.StatusBadRequest)
return
}
err = s.store.SetConfig(
"zombie_grace_hours",
graceHours,
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
case "nav-home":
err = s.saveNavConfig(
@@ -156,6 +239,18 @@ func (s *Server) handleConfig(
return
}
case "zombie-purge":
_, err = s.store.PurgeZombieObjects(
s.getZombieGraceSeconds(),
100,
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
default:
http.Error(
@@ -167,10 +262,16 @@ func (s *Server) handleConfig(
return
}
panel := section
if section == "zombie-purge" {
panel = "objects"
}
http.Redirect(
w,
r,
"/-/sys/config?panel="+section,
"/-/sys/config?panel="+panel,
http.StatusFound,
)
@@ -201,6 +302,9 @@ func (s *Server) handleConfig(
wikiName = "Pages Wiki"
}
zombieGraceHours :=
s.getZombieGraceHours()
recent, err :=
s.store.ListRecentObjects(
50,
@@ -211,6 +315,16 @@ func (s *Server) handleConfig(
return
}
zombies, err :=
s.store.ListZombieObjects(
s.getZombieGraceSeconds(),
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
s.render(
w,
"config.gohtml",
@@ -222,7 +336,11 @@ func (s *Server) handleConfig(
"HomePath": homePath,
"WikiName": wikiName,
"Locale": s.getLocale(),
"Timezone": s.getTimezoneName(),
"Theme": s.getTheme(),
"ZombieGraceHours": zombieGraceHours,
"Objects": recent,
"ZombieObjects": zombies,
"HomeNavItemsConfig": s.getHomeNavItems(),
"SystemNavItemsConfig": s.getSystemNavItems(),
},