Files
pages/templates/pages/config.gohtml
T

813 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="{{ .ThemeCSS }}">
</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-main">
<div 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="editor" onclick="showConfigPanel('editor'); return false;">
Editor
</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-content">
<section
id="panel-home"
class="config-section config-panel active"
>
<h1>{{ T "config.title" }}</h1>
<p class="muted">
Current District:
<span class="mono">{{ .Context.District.Name }}</span>
/
<span class="mono">{{ .Context.District.Title }}</span>
</p>
<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"
>
{{ range .ThemeOptions }}
<option value="{{ .ID }}" {{ if eq $.Theme .ID }}selected{{ end }}>
{{ .Label }}
</option>
{{ end }}
</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
id="panel-editor"
class="config-section config-panel"
>
<h2>Editor</h2>
<form
method="post"
action="/-/sys/config"
>
<input
type="hidden"
name="section"
value="editor"
>
<label>
Keymap
</label>
<select name="editor_keymap">
<option value="default" {{ if eq .EditorKeymap "default" }}selected{{ end }}>
Default
</option>
<option value="vim" {{ if eq .EditorKeymap "vim" }}selected{{ end }}>
Vim
</option>
</select>
<br>
<br>
<label>
<input
type="checkbox"
name="editor_syntax_highlight"
{{ if .EditorSyntax }}checked{{ end }}
>
Syntax highlighting
</label>
<br>
<br>
<label>
<input
type="checkbox"
name="editor_autocomplete"
{{ if .EditorAutocomplete }}checked{{ end }}
>
Autocomplete
</label>
<br>
<br>
<button type="submit">
Save
</button>
</form>
</section>
</section>
</div>
</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
)
}
}
</script>
<style>
body.mode-config .config-main {
padding: 1.25rem;
display: block;
}
body.mode-config .config-layout {
display: grid !important;
grid-template-columns: 16rem minmax(0, 1fr) !important;
gap: 1.5rem !important;
align-items: start !important;
}
body.mode-config .config-sidebar {
grid-column: 1;
position: sticky;
top: 4rem;
align-self: start;
border-right: 1px solid var(--border-soft);
padding: 0.75rem;
min-height: calc(100vh - 6rem);
}
body.mode-config .config-sidebar.collapsed {
width: 2.5rem;
overflow: hidden;
}
body.mode-config .config-sidebar.collapsed .sidebar-nav {
display: none;
}
body.mode-config .config-content {
grid-column: 2;
min-width: 0;
}
body.mode-config .config-panel {
display: none;
}
body.mode-config .config-panel.active {
display: block;
}
body.mode-config .sidebar-nav {
display: flex;
flex-direction: column;
gap: 0.5rem;
margin-top: 1rem;
}
body.mode-config .sidebar-nav a {
text-decoration: none;
}
body.mode-config .sidebar-nav a.active {
color: var(--link-hover);
}
body.mode-config .config-section {
margin-bottom: 2rem;
min-width: 0;
}
body.mode-config .config-section input[type="text"],
body.mode-config .config-section input[type="number"],
body.mode-config .config-section select {
max-width: 42rem;
}
body.mode-config .config-section input[type="text"] {
width: 100%;
padding: 0.6rem;
font-family: monospace;
}
body.mode-config .recent-table {
width: 100%;
border-collapse: collapse;
}
body.mode-config .recent-table th,
body.mode-config .recent-table td {
border-bottom: 1px solid var(--border-soft);
padding: 0.4rem;
}
body.mode-config .recent-table th {
text-align: left;
color: var(--muted);
font-weight: normal;
}
body.mode-config .recent-table tr:hover {
background: var(--row-hover);
}
body.mode-config .mono {
font-family: "JetBrains Mono", monospace;
}
body.mode-config .muted {
color: var(--muted);
}
</style>
</body>
</html>
{{ end }}