806 lines
11 KiB
Go Template
806 lines
11 KiB
Go Template
{{ define "config.gohtml" }}
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<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">
|
|
|
|
<header class="topbar">
|
|
<div class="brand">
|
|
<a href="/">{{ .WikiName }}</a>
|
|
</div>
|
|
|
|
|
|
<nav>
|
|
{{ range .NavItems }}
|
|
<a href="{{ .ResolvedHref }}">{{ .Label }}</a>
|
|
{{ end }}
|
|
</nav>
|
|
|
|
</header>
|
|
|
|
<main class="config-layout">
|
|
|
|
<aside
|
|
id="config-sidebar"
|
|
class="config-sidebar"
|
|
>
|
|
|
|
<button
|
|
type="button"
|
|
class="sidebar-toggle"
|
|
onclick="toggleSidebar()"
|
|
>
|
|
☰
|
|
</button>
|
|
|
|
<nav class="sidebar-nav">
|
|
|
|
<a href="#" data-panel="home" onclick="showConfigPanel('home'); return false;">
|
|
{{ T "config.home" }}
|
|
</a>
|
|
|
|
<a href="#" data-panel="objects" onclick="showConfigPanel('objects'); return false;">
|
|
{{ T "config.objects" }}
|
|
</a>
|
|
|
|
<a href="#" data-panel="nav-home" onclick="showConfigPanel('nav-home'); return false;">
|
|
{{ T "config.nav_home" }}
|
|
</a>
|
|
|
|
<a href="#" data-panel="nav-system" onclick="showConfigPanel('nav-system'); return false;">
|
|
{{ T "config.nav_system" }}
|
|
</a>
|
|
|
|
</nav>
|
|
|
|
</aside>
|
|
|
|
<section class="config-main">
|
|
|
|
<section
|
|
id="panel-home"
|
|
class="config-section config-panel active"
|
|
>
|
|
|
|
<h1>{{ T "config.title" }}</h1>
|
|
|
|
<h2>{{ T "config.home" }}</h2>
|
|
|
|
<form
|
|
method="post"
|
|
action="/-/sys/config"
|
|
>
|
|
|
|
<input
|
|
type="hidden"
|
|
name="section"
|
|
value="home"
|
|
>
|
|
|
|
<label>
|
|
{{ T "config.wiki_name" }}
|
|
</label>
|
|
|
|
<input
|
|
name="wiki_name"
|
|
type="text"
|
|
value="{{ .WikiName }}"
|
|
placeholder="Pages Wiki"
|
|
>
|
|
|
|
<br>
|
|
<br>
|
|
|
|
|
|
<label>
|
|
{{ T "config.locale" }}
|
|
</label>
|
|
|
|
<select
|
|
name="locale"
|
|
>
|
|
<option value="en" {{ if eq .Locale "en" }}selected{{ end }}>
|
|
English
|
|
</option>
|
|
|
|
<option value="ja" {{ if eq .Locale "ja" }}selected{{ end }}>
|
|
日本語
|
|
</option>
|
|
</select>
|
|
|
|
<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>
|
|
|
|
<input
|
|
name="home_path"
|
|
type="text"
|
|
value="{{ .HomePath }}"
|
|
placeholder="/home"
|
|
>
|
|
<br>
|
|
<button type="submit">
|
|
Save
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
<section
|
|
id="panel-objects"
|
|
class="config-section config-panel"
|
|
>
|
|
|
|
<h2>{{ T "config.objects" }}</h2>
|
|
|
|
<table class="recent-table">
|
|
|
|
<thead>
|
|
<tr>
|
|
<th>{{ T "config.primary" }}</th>
|
|
<th>{{ T "config.size" }}</th>
|
|
<th>{{ T "config.updated" }}</th>
|
|
<th>{{ T "config.object" }}</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{{ range .Objects }}
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
{{ if .Path }}
|
|
<a href="{{ .Path }}">{{ .Path }}</a>
|
|
{{ else }}
|
|
<span class="muted">unlinked</span>
|
|
{{ end }}
|
|
</td>
|
|
|
|
<td class="mono">
|
|
{{ formatBytes .Size }}
|
|
</td>
|
|
|
|
<td class="mono">
|
|
{{ formatUnix .UpdatedAt }}
|
|
</td>
|
|
|
|
<td class="mono">
|
|
<a href="/o/uuid:{{ .UUID }}">{{ .UUID }}</a>
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
</tbody>
|
|
|
|
</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>
|
|
|
|
|
|
<section
|
|
id="panel-nav-home"
|
|
class="config-section config-panel"
|
|
>
|
|
|
|
<h2>{{ T "config.nav_home" }}</h2>
|
|
|
|
<form
|
|
method="post"
|
|
action="/-/sys/config"
|
|
>
|
|
|
|
<input
|
|
type="hidden"
|
|
name="section"
|
|
value="nav-home"
|
|
>
|
|
|
|
<table class="recent-table">
|
|
|
|
<thead>
|
|
<tr>
|
|
<th>{{ T "config.nav_label" }}</th>
|
|
<th>{{ T "config.nav_href" }}</th>
|
|
<th>{{ T "config.nav_order" }}</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{{ range .HomeNavItemsConfig }}
|
|
|
|
<tr>
|
|
<td>
|
|
<input
|
|
name="nav_label"
|
|
type="text"
|
|
value="{{ .Label }}"
|
|
>
|
|
</td>
|
|
|
|
<td>
|
|
<input
|
|
name="nav_href"
|
|
type="text"
|
|
value="{{ .Href }}"
|
|
>
|
|
</td>
|
|
|
|
<td>
|
|
<button type="button" onclick="moveNavRow(this, -1)">↑</button>
|
|
<button type="button" onclick="moveNavRow(this, 1)">↓</button>
|
|
</td>
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
<tr>
|
|
<td>
|
|
<input
|
|
name="nav_label"
|
|
type="text"
|
|
placeholder="Label"
|
|
>
|
|
</td>
|
|
|
|
<td>
|
|
<input
|
|
name="nav_href"
|
|
type="text"
|
|
placeholder="/path"
|
|
>
|
|
</td>
|
|
|
|
<td>
|
|
<button type="button" onclick="moveNavRow(this, -1)">↑</button>
|
|
<button type="button" onclick="moveNavRow(this, 1)">↓</button>
|
|
</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<button type="submit">
|
|
{{ T "config.nav_save" }}
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
<section
|
|
id="panel-nav-system"
|
|
class="config-section config-panel"
|
|
>
|
|
|
|
<h2>{{ T "config.nav_system" }}</h2>
|
|
|
|
<form
|
|
method="post"
|
|
action="/-/sys/config"
|
|
>
|
|
|
|
<input
|
|
type="hidden"
|
|
name="section"
|
|
value="nav-system"
|
|
>
|
|
|
|
<table class="recent-table">
|
|
|
|
<thead>
|
|
<tr>
|
|
<th>{{ T "config.nav_label" }}</th>
|
|
<th>{{ T "config.nav_href" }}</th>
|
|
<th>{{ T "config.nav_order" }}</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{{ range .SystemNavItemsConfig }}
|
|
|
|
<tr>
|
|
<td>
|
|
<input
|
|
name="nav_label"
|
|
type="text"
|
|
value="{{ .Label }}"
|
|
>
|
|
</td>
|
|
|
|
<td>
|
|
<input
|
|
name="nav_href"
|
|
type="text"
|
|
value="{{ .Href }}"
|
|
>
|
|
</td>
|
|
|
|
<td>
|
|
<button type="button" onclick="moveNavRow(this, -1)">↑</button>
|
|
<button type="button" onclick="moveNavRow(this, 1)">↓</button>
|
|
</td>
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
<tr>
|
|
<td>
|
|
<input
|
|
name="nav_label"
|
|
type="text"
|
|
placeholder="Label"
|
|
>
|
|
</td>
|
|
|
|
<td>
|
|
<input
|
|
name="nav_href"
|
|
type="text"
|
|
placeholder="/path"
|
|
>
|
|
</td>
|
|
|
|
<td>
|
|
<button type="button" onclick="moveNavRow(this, -1)">↑</button>
|
|
<button type="button" onclick="moveNavRow(this, 1)">↓</button>
|
|
</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<button type="submit">
|
|
{{ T "config.nav_save" }}
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
|
|
</section>
|
|
|
|
</main>
|
|
|
|
<script>
|
|
function toggleSidebar() {
|
|
|
|
const sidebar =
|
|
document.getElementById(
|
|
"config-sidebar"
|
|
)
|
|
|
|
sidebar.classList.toggle(
|
|
"collapsed"
|
|
)
|
|
}
|
|
|
|
function showConfigPanel(name) {
|
|
|
|
for (
|
|
const panel
|
|
of document.querySelectorAll(
|
|
".config-panel"
|
|
)
|
|
) {
|
|
|
|
panel.classList.remove(
|
|
"active"
|
|
)
|
|
}
|
|
|
|
const target =
|
|
document.getElementById(
|
|
"panel-" + name
|
|
)
|
|
|
|
if (target) {
|
|
|
|
target.classList.add(
|
|
"active"
|
|
)
|
|
}
|
|
|
|
for (
|
|
const link
|
|
of document.querySelectorAll(
|
|
".sidebar-nav a"
|
|
)
|
|
) {
|
|
|
|
link.classList.toggle(
|
|
"active",
|
|
link.dataset.panel === name
|
|
)
|
|
}
|
|
|
|
history.replaceState(
|
|
null,
|
|
"",
|
|
"/-/sys/config?panel=" + encodeURIComponent(name)
|
|
)
|
|
}
|
|
|
|
document.addEventListener(
|
|
"DOMContentLoaded",
|
|
() => {
|
|
|
|
const params =
|
|
new URLSearchParams(
|
|
location.search
|
|
)
|
|
|
|
let panel =
|
|
params.get("panel") || "home"
|
|
|
|
if (panel === "nav") {
|
|
panel = "nav-home"
|
|
}
|
|
|
|
showConfigPanel(
|
|
panel
|
|
)
|
|
},
|
|
)
|
|
|
|
function moveNavRow(button, direction) {
|
|
|
|
const row =
|
|
button.closest(
|
|
"tr"
|
|
)
|
|
|
|
const tbody =
|
|
row.parentElement
|
|
|
|
if (direction < 0) {
|
|
|
|
const prev =
|
|
row.previousElementSibling
|
|
|
|
if (prev) {
|
|
|
|
tbody.insertBefore(
|
|
row,
|
|
prev
|
|
)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
const next =
|
|
row.nextElementSibling
|
|
|
|
if (next) {
|
|
|
|
tbody.insertBefore(
|
|
next,
|
|
row
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
function moveNavRow(button, direction) {
|
|
|
|
const row =
|
|
button.closest(
|
|
"tr"
|
|
)
|
|
|
|
const tbody =
|
|
row.parentElement
|
|
|
|
if (direction < 0) {
|
|
|
|
const prev =
|
|
row.previousElementSibling
|
|
|
|
if (prev) {
|
|
|
|
tbody.insertBefore(
|
|
row,
|
|
prev
|
|
)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
const next =
|
|
row.nextElementSibling
|
|
|
|
if (next) {
|
|
|
|
tbody.insertBefore(
|
|
next,
|
|
row
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
function moveNavRow(button, direction) {
|
|
|
|
const row =
|
|
button.closest(
|
|
"tr"
|
|
)
|
|
|
|
const tbody =
|
|
row.parentElement
|
|
|
|
if (direction < 0) {
|
|
|
|
const prev =
|
|
row.previousElementSibling
|
|
|
|
if (prev) {
|
|
|
|
tbody.insertBefore(
|
|
row,
|
|
prev
|
|
)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
const next =
|
|
row.nextElementSibling
|
|
|
|
if (next) {
|
|
|
|
tbody.insertBefore(
|
|
next,
|
|
row
|
|
)
|
|
}
|
|
}
|
|
|
|
</script>
|
|
|
|
<style>
|
|
|
|
.config-layout {
|
|
display: grid;
|
|
grid-template-columns: 14rem 1fr;
|
|
min-height: calc(100vh - 48px);
|
|
}
|
|
|
|
.config-sidebar {
|
|
border-right: 1px solid rgba(255,255,255,0.06);
|
|
padding: 0.75rem;
|
|
transition: width 0.12s linear;
|
|
}
|
|
|
|
.config-sidebar.collapsed {
|
|
width: 2.5rem;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.sidebar-toggle {
|
|
background: transparent;
|
|
color: #aaa;
|
|
border: 1px solid rgba(255,255,255,0.08);
|
|
padding: 0.25rem 0.5rem;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.sidebar-nav {
|
|
display: flex;
|
|
flex-direction: column;
|
|
margin-top: 1rem;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.sidebar-nav a {
|
|
text-decoration: none;
|
|
}
|
|
|
|
.config-main {
|
|
padding: 1.25rem;
|
|
}
|
|
|
|
.config-section {
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.config-section input[type="text"] {
|
|
width: 100%;
|
|
max-width: 42rem;
|
|
background: var(--input-bg);
|
|
color: var(--fg);
|
|
border: 1px solid var(--input-border);
|
|
padding: 0.6rem;
|
|
font-family: monospace;
|
|
}
|
|
|
|
.recent-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
.recent-table th {
|
|
text-align: left;
|
|
font-weight: normal;
|
|
color: var(--muted);
|
|
border-bottom: 1px solid rgba(255,255,255,0.08);
|
|
padding: 0.45rem 0.35rem;
|
|
}
|
|
|
|
.recent-table td {
|
|
border-bottom: 1px solid rgba(255,255,255,0.035);
|
|
padding: 0.38rem 0.35rem;
|
|
}
|
|
|
|
.recent-table tr:hover {
|
|
background: rgba(255,255,255,0.025);
|
|
}
|
|
|
|
.mono {
|
|
font-family:
|
|
"JetBrains Mono",
|
|
monospace;
|
|
}
|
|
|
|
.muted {
|
|
color: var(--muted);
|
|
}
|
|
|
|
|
|
.config-panel {
|
|
display: none;
|
|
}
|
|
|
|
.config-panel.active {
|
|
display: block;
|
|
}
|
|
|
|
.sidebar-nav a.active {
|
|
color: var(--link-hover);
|
|
text-shadow:
|
|
0 0 0.45rem rgba(180,120,255,0.35);
|
|
}
|
|
|
|
.config-sidebar.collapsed .sidebar-nav {
|
|
display: none;
|
|
}
|
|
|
|
</style>
|
|
|
|
</body>
|
|
</html>
|
|
{{ end }}
|