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(),
},
+1 -1
View File
@@ -20,7 +20,7 @@ func (s *Server) startGCWorker() {
deleted, err :=
s.store.PurgeZombieObjects(
24*60*60,
s.getZombieGraceSeconds(),
100,
)
+60 -56
View File
@@ -6,64 +6,68 @@ import (
var translations = map[string]map[string]string{
"en": {
"config.title": "Config",
"config.home": "Home",
"config.wiki_name": "Wiki name",
"config.locale": "Language",
"config.home_path": "Home semantic path",
"config.save": "Save",
"config.nav": "Navigation",
"config.objects": "Recent Objects",
"config.primary": "Primary Link",
"config.size": "Size",
"config.updated": "Updated",
"config.object": "Object",
"config.nav_label": "Label",
"config.nav_href": "Href",
"config.nav_order": "Order",
"config.nav_save": "Save Navigation",
"config.nav_home": "Home Navigation",
"config.nav_system": "System Navigation",
"link.title": "Link Manager",
"link.object": "Object",
"link.primary": "Primary",
"link.path": "Path",
"link.linked_at": "Linked At",
"link.action": "Action",
"link.delete": "Delete",
"link.add": "Add",
"link.add_path": "Add Link",
"link.placeholder": "/pageswiki/example",
"config.title": "Config",
"config.home": "Home",
"config.wiki_name": "Wiki name",
"config.locale": "Language",
"config.timezone": "Timezone",
"config.zombie_grace_hours": "Zombie grace period (hours)",
"config.home_path": "Home semantic path",
"config.save": "Save",
"config.nav": "Navigation",
"config.objects": "Recent Objects",
"config.primary": "Primary Link",
"config.size": "Size",
"config.updated": "Updated",
"config.object": "Object",
"config.nav_label": "Label",
"config.nav_href": "Href",
"config.nav_order": "Order",
"config.nav_save": "Save Navigation",
"config.nav_home": "Home Navigation",
"config.nav_system": "System Navigation",
"link.title": "Link Manager",
"link.object": "Object",
"link.primary": "Primary",
"link.path": "Path",
"link.linked_at": "Linked At",
"link.action": "Action",
"link.delete": "Delete",
"link.add": "Add",
"link.add_path": "Add Link",
"link.placeholder": "/pageswiki/example",
},
"ja": {
"config.title": "設定",
"config.home": "ホーム",
"config.wiki_name": "Wiki名称",
"config.locale": "言語",
"config.home_path": "トップページ",
"config.save": "保存",
"config.nav": "ナビゲーション",
"config.nav_home": "ホームナビゲーション",
"config.nav_system": "システムナビゲーション",
"config.objects": "最近のオブジェクト",
"link.title": "リンク管理",
"link.object": "オブジェクト",
"link.primary": "主リンク",
"link.path": "パス",
"link.linked_at": "リンクされた日時",
"link.action": "操作",
"link.delete": "削除",
"link.add": "追加",
"link.add_path": "リンクを追加",
"link.placeholder": "/pageswiki/example",
"config.primary": "主なリンク",
"config.size": "サイズ",
"config.updated": "最終更新",
"config.object": "オブジェクト",
"config.nav_label": "表示名",
"config.nav_href": "リンク先",
"config.nav_order": "順序",
"config.nav_save": "ナビゲーションを保存",
"config.title": "設定",
"config.home": "ホーム",
"config.wiki_name": "Wiki名称",
"config.locale": "言語",
"config.timezone": "タイムゾーン",
"config.zombie_grace_hours": "ゾンビ判定猶予時間(時間)",
"config.home_path": "トップページ",
"config.save": "保存",
"config.nav": "ナビゲーション",
"config.nav_home": "ホームナビゲーション",
"config.nav_system": "システムナビゲーション",
"config.objects": "最近のオブジェクト",
"link.title": "リンク管理",
"link.object": "オブジェクト",
"link.primary": "主リンク",
"link.path": "パス",
"link.linked_at": "リンクされた日時",
"link.action": "操作",
"link.delete": "削除",
"link.add": "追加",
"link.add_path": "リンクを追加",
"link.placeholder": "/pageswiki/example",
"config.primary": "主なリンク",
"config.size": "サイズ",
"config.updated": "最終更新",
"config.object": "オブジェクト",
"config.nav_label": "表示名",
"config.nav_href": "リンク先",
"config.nav_order": "順序",
"config.nav_save": "ナビゲーションを保存",
},
}
+3
View File
@@ -7,10 +7,12 @@ import (
func mergeTemplateData(
data any,
wikiName string,
theme string,
) map[string]any {
out := map[string]any{
"WikiName": wikiName,
"Theme": theme,
}
if data == nil {
@@ -43,6 +45,7 @@ func (s *Server) render(
mergeTemplateData(
data,
s.getWikiName(),
s.getTheme(),
),
)
+4 -1
View File
@@ -139,7 +139,10 @@ func (s *Server) mustLoadTemplates() {
return "-"
}
return time.Unix(ts, 0).Format("2006-01-02 15:04")
return time.
Unix(ts, 0).
In(s.getLocation()).
Format("2006-01-02 15:04")
},
}
+20
View File
@@ -0,0 +1,20 @@
package server
func (s *Server) getTheme() string {
theme, err :=
s.store.GetConfig(
"theme",
)
if err != nil || theme == "" {
return "dark"
}
switch theme {
case "dark", "light", "monokai", "solarized-dark", "solarized-light":
return theme
default:
return "dark"
}
}
+37
View File
@@ -0,0 +1,37 @@
package server
import "time"
func (s *Server) getTimezoneName() string {
tz, err :=
s.store.GetConfig(
"timezone",
)
if err != nil || tz == "" {
return "UTC"
}
_, err = time.LoadLocation(tz)
if err != nil {
return "UTC"
}
return tz
}
func (s *Server) getLocation() *time.Location {
loc, err :=
time.LoadLocation(
s.getTimezoneName(),
)
if err != nil {
return time.UTC
}
return loc
}
+33
View File
@@ -0,0 +1,33 @@
package server
import "strconv"
func (s *Server) getZombieGraceHours() int64 {
raw, err :=
s.store.GetConfig(
"zombie_grace_hours",
)
if err != nil || raw == "" {
return 24
}
n, err :=
strconv.ParseInt(
raw,
10,
64,
)
if err != nil || n < 0 {
return 24
}
return n
}
func (s *Server) getZombieGraceSeconds() int64 {
return s.getZombieGraceHours() * 60 * 60
}
+97
View File
@@ -0,0 +1,97 @@
:root {
--bg: #111;
--fg: #e8e8e8;
--muted: #888;
--panel: transparent;
--border: rgba(255,255,255,0.10);
--border-soft: rgba(255,255,255,0.05);
--link: #8ecbff;
--link-hover: #d8efff;
--input-bg: #0b0b0b;
--input-fg: #f0f0f0;
--input-border: rgba(255,255,255,0.16);
--button-bg: #161616;
--button-fg: #eee;
--button-border: rgba(255,255,255,0.18);
--button-hover-bg: #222;
--danger: #ff6d6d;
--accent: #b077ff;
}
html,
body {
background: var(--bg);
color: var(--fg);
}
a {
color: var(--link);
}
a:hover {
color: var(--link-hover);
}
input,
select,
textarea,
button {
background: var(--input-bg);
color: var(--input-fg);
border: 1px solid var(--input-border);
border-radius: 0.2rem;
font: inherit;
}
input,
select,
textarea {
padding: 0.45rem 0.55rem;
}
button,
input[type="button"],
input[type="submit"] {
background: var(--button-bg);
color: var(--button-fg);
border: 1px solid var(--button-border);
padding: 0.38rem 0.75rem;
cursor: pointer;
}
button:hover,
input[type="button"]:hover,
input[type="submit"]:hover {
background: var(--button-hover-bg);
}
input:focus,
select:focus,
textarea:focus,
button:focus {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0.45rem color-mix(in srgb, var(--accent) 28%, transparent);
}
table {
color: var(--fg);
}
th {
color: var(--muted);
}
td,
th {
border-color: var(--border-soft);
}
.topbar {
background: var(--bg);
border-bottom: 1px solid var(--border-soft);
}
.muted {
color: var(--muted);
}
+17
View File
@@ -0,0 +1,17 @@
:root {
--bg: #0d0f10;
--fg: #e8e8e8;
--muted: #8a8f98;
--border: rgba(255,255,255,0.10);
--border-soft: rgba(255,255,255,0.045);
--link: #84c7ff;
--link-hover: #d5eeff;
--input-bg: #090b0c;
--input-fg: #f0f0f0;
--input-border: rgba(255,255,255,0.15);
--button-bg: #15191c;
--button-fg: #e8e8e8;
--button-border: rgba(255,255,255,0.18);
--button-hover-bg: #20262a;
--accent: #a879ff;
}
+17
View File
@@ -0,0 +1,17 @@
:root {
--bg: #f7f7f7;
--fg: #202020;
--muted: #666;
--border: rgba(0,0,0,0.16);
--border-soft: rgba(0,0,0,0.08);
--link: #075fb0;
--link-hover: #003f7a;
--input-bg: #ffffff;
--input-fg: #202020;
--input-border: rgba(0,0,0,0.22);
--button-bg: #ffffff;
--button-fg: #202020;
--button-border: rgba(0,0,0,0.24);
--button-hover-bg: #efefef;
--accent: #006cc9;
}
+18
View File
@@ -0,0 +1,18 @@
:root {
--bg: #272822;
--fg: #f8f8f2;
--muted: #aaa;
--border: rgba(248,248,242,0.16);
--border-soft: rgba(248,248,242,0.07);
--link: #66d9ef;
--link-hover: #a6e9f4;
--input-bg: #1e1f1c;
--input-fg: #f8f8f2;
--input-border: rgba(248,248,242,0.18);
--button-bg: #33342d;
--button-fg: #f8f8f2;
--button-border: rgba(248,248,242,0.22);
--button-hover-bg: #3e3f36;
--danger: #f92672;
--accent: #a6e22e;
}
+17
View File
@@ -0,0 +1,17 @@
:root {
--bg: #002b36;
--fg: #eee8d5;
--muted: #839496;
--border: rgba(238,232,213,0.16);
--border-soft: rgba(238,232,213,0.07);
--link: #268bd2;
--link-hover: #6cbeff;
--input-bg: #073642;
--input-fg: #eee8d5;
--input-border: rgba(238,232,213,0.18);
--button-bg: #073642;
--button-fg: #eee8d5;
--button-border: rgba(238,232,213,0.22);
--button-hover-bg: #0b4655;
--accent: #b58900;
}
+17
View File
@@ -0,0 +1,17 @@
:root {
--bg: #fdf6e3;
--fg: #586e75;
--muted: #839496;
--border: rgba(88,110,117,0.18);
--border-soft: rgba(88,110,117,0.09);
--link: #268bd2;
--link-hover: #0066a8;
--input-bg: #fffdf2;
--input-fg: #586e75;
--input-border: rgba(88,110,117,0.24);
--button-bg: #eee8d5;
--button-fg: #586e75;
--button-border: rgba(88,110,117,0.24);
--button-hover-bg: #e5dec8;
--accent: #b58900;
}
+112
View File
@@ -6,6 +6,9 @@
<title>{{ T "config.title" }}</title>
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body class="mode-config">
@@ -117,6 +120,51 @@ English
<br>
<br>
<label>
{{ T "config.timezone" }}
</label>
<input
name="timezone"
type="text"
value="{{ .Timezone }}"
placeholder="Asia/Tokyo"
>
<br>
<br>
<label>
{{ T "config.theme" }}
</label>
<select
name="theme"
>
<option value="dark" {{ if eq .Theme "dark" }}selected{{ end }}>Dark</option>
<option value="light" {{ if eq .Theme "light" }}selected{{ end }}>Light</option>
<option value="monokai" {{ if eq .Theme "monokai" }}selected{{ end }}>Monokai</option>
<option value="solarized-dark" {{ if eq .Theme "solarized-dark" }}selected{{ end }}>Solarized Dark</option>
<option value="solarized-light" {{ if eq .Theme "solarized-light" }}selected{{ end }}>Solarized Light</option>
</select>
<br>
<br>
<label>
{{ T "config.zombie_grace_hours" }}
</label>
<input
name="zombie_grace_hours"
type="number"
min="0"
value="{{ .ZombieGraceHours }}"
>
<br>
<br>
<label>
{{ T "config.home_path" }}
</label>
@@ -188,6 +236,70 @@ Save
</table>
<h2>Zombie Objects</h2>
<p class="muted">
Unlinked and empty objects older than the grace period.
</p>
<table class="recent-table">
<thead>
<tr>
<th>UUID</th>
<th>Created</th>
<th>Revisions</th>
<th>Max Body</th>
</tr>
</thead>
<tbody>
{{ range .ZombieObjects }}
<tr>
<td class="mono">
<a href="/o/uuid:{{ .UUID }}">{{ .UUID }}</a>
</td>
<td class="mono">
{{ formatUnix .CreatedAt }}
</td>
<td class="mono">
{{ .RevisionCount }}
</td>
<td class="mono">
{{ formatBytes .MaxBodyLength }}
</td>
</tr>
{{ end }}
</tbody>
</table>
<form
method="post"
action="/-/sys/config"
onsubmit="return confirm('Purge zombie objects?')"
>
<input
type="hidden"
name="section"
value="zombie-purge"
>
<button type="submit">
Purge Zombies
</button>
</form>
</section>
+3
View File
@@ -18,6 +18,9 @@
href="/o/path:/system/static/css/modes.css"
>
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body class="mode-editor">
+3
View File
@@ -6,6 +6,9 @@
<title>{{ .WikiName }}</title>
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body class="mode-home">
+3
View File
@@ -6,6 +6,9 @@
<title>{{ T "link.title" }}</title>
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body>
+3
View File
@@ -18,6 +18,9 @@
href="/o/path:/system/static/css/modes.css"
>
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body class="mode-links">
+3
View File
@@ -6,6 +6,9 @@
<title>{{ .Title }}</title>
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body class="mode-editor">
+3
View File
@@ -6,6 +6,9 @@
<title>{{ .Title }}</title>
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body>
+3
View File
@@ -7,6 +7,9 @@
<title>{{ .Name }}</title>
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body class="mode-page {{ if .IsHome }}is-home-page{{ end }}">
+3
View File
@@ -10,6 +10,9 @@
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
<link rel="stylesheet" href="/o/path:/system/static/css/revisions.css">
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body>
+3
View File
@@ -18,6 +18,9 @@
href="/o/path:/system/static/css/revisions.css"
>
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body class="mode-revision-view">
+3
View File
@@ -18,6 +18,9 @@
href="/o/path:/system/static/css/revisions.css"
>
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>
<body class="mode-revisions">
+3
View File
@@ -544,6 +544,9 @@ body {
</style>
<link rel="stylesheet" href="/static/css/theme/base.css">
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
</head>