Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming. Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
565 lines
13 KiB
Go Template
565 lines
13 KiB
Go Template
{{ define "tree.gohtml" }}
|
|
<!DOCTYPE html>
|
|
<html lang="{{ .Locale }}">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>{{ T "tree.title" }}</title>
|
|
|
|
<link rel="stylesheet" href="/static/css/fonts.css">
|
|
<link rel="stylesheet" href="/static/css/main.css">
|
|
<link rel="stylesheet" href="/static/css/theme/base.css">
|
|
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
|
|
|
<style>
|
|
|
|
:root {
|
|
--tree-dir: color-mix(in srgb, var(--accent) 70%, var(--link));
|
|
--tree-file: var(--link);
|
|
--tree-edit: #e0c25f;
|
|
--tree-rename: #64d7ee;
|
|
--tree-delete: var(--danger);
|
|
}
|
|
|
|
body {
|
|
margin: 0;
|
|
min-height: 100vh;
|
|
font-family: Inter, "Noto Sans JP", sans-serif;
|
|
}
|
|
|
|
.container {
|
|
padding: 1rem 1rem 4rem 1rem;
|
|
}
|
|
|
|
.card {
|
|
background: transparent;
|
|
border: none;
|
|
padding: 1rem 1rem 2rem 1rem;
|
|
}
|
|
|
|
.tree-toolbar {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 1.25rem;
|
|
}
|
|
|
|
.tree-toolbar input {
|
|
width: 28rem;
|
|
font-family: monospace;
|
|
}
|
|
|
|
.tree {
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: transparent;
|
|
}
|
|
|
|
.tree-row {
|
|
position: relative;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
height: 30px;
|
|
border-bottom: 1px solid var(--border-soft);
|
|
border-left: 1px solid transparent;
|
|
padding-left: 0.2rem;
|
|
background: transparent;
|
|
transition: background 0.08s linear, border-color 0.08s linear;
|
|
}
|
|
|
|
.tree-row:hover {
|
|
background: var(--row-hover, rgba(127,127,127,0.06));
|
|
border-left-color: color-mix(in srgb, var(--accent) 45%, transparent);
|
|
}
|
|
|
|
.tree-left {
|
|
display: flex;
|
|
align-items: center;
|
|
min-width: 0;
|
|
flex: 1;
|
|
}
|
|
|
|
.tree-select {
|
|
margin: 0 0.5rem 0 0.2rem;
|
|
}
|
|
|
|
.tree-indent {
|
|
width: 18px;
|
|
height: 30px;
|
|
border-left: 1px solid var(--border-soft);
|
|
}
|
|
|
|
.tree-node {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.48rem;
|
|
min-width: 0;
|
|
}
|
|
|
|
.tree-toggle {
|
|
width: 1.25rem;
|
|
height: 1.5rem;
|
|
display: inline-grid;
|
|
place-items: center;
|
|
padding: 0;
|
|
border: 0;
|
|
background: transparent;
|
|
color: var(--muted);
|
|
cursor: pointer;
|
|
font-size: 0.8rem;
|
|
transition: transform 0.12s ease, color 0.12s ease;
|
|
}
|
|
|
|
.tree-toggle[aria-expanded="true"] { transform: rotate(90deg); color: var(--accent); }
|
|
.tree-toggle-spacer { width: 1.25rem; flex: 0 0 1.25rem; }
|
|
|
|
.tree-icon {
|
|
width: 1.2rem;
|
|
text-align: center;
|
|
font-family: "Hack Nerd Font";
|
|
font-size: 1rem;
|
|
opacity: 0.92;
|
|
transition: transform 0.08s linear, opacity 0.08s linear;
|
|
}
|
|
|
|
.tree-row:hover .tree-icon {
|
|
transform: translateY(-1px);
|
|
opacity: 1;
|
|
}
|
|
|
|
.tree-icon.dir {
|
|
color: var(--tree-dir);
|
|
}
|
|
|
|
.tree-icon.file {
|
|
color: var(--tree-file);
|
|
}
|
|
|
|
.tree-icon.draft {
|
|
color: var(--muted);
|
|
opacity: 0.65;
|
|
}
|
|
|
|
.tree-link {
|
|
text-decoration: none;
|
|
color: var(--link);
|
|
font-family: "JetBrains Mono", monospace;
|
|
font-size: 0.92rem;
|
|
letter-spacing: -0.01em;
|
|
transition: color 0.08s linear, text-shadow 0.08s linear, transform 0.08s linear;
|
|
}
|
|
|
|
.tree-link:hover {
|
|
color: var(--link-hover);
|
|
text-shadow: 0 0 0.45rem color-mix(in srgb, var(--accent) 32%, transparent);
|
|
transform: translateX(1px);
|
|
}
|
|
|
|
.tree-actions {
|
|
display: flex;
|
|
gap: 0.85rem;
|
|
opacity: 0.58;
|
|
padding-right: 0.5rem;
|
|
transition: opacity 0.08s linear;
|
|
}
|
|
|
|
.tree-row:hover .tree-actions {
|
|
opacity: 1;
|
|
}
|
|
|
|
.tree-btn {
|
|
border: none;
|
|
background: transparent;
|
|
cursor: pointer;
|
|
font-size: 0.78rem;
|
|
font-family: "JetBrains Mono", monospace;
|
|
text-decoration: none;
|
|
padding: 0;
|
|
}
|
|
|
|
.tree-btn.edit {
|
|
color: var(--tree-edit);
|
|
}
|
|
|
|
.tree-btn.rename {
|
|
color: var(--tree-rename);
|
|
}
|
|
|
|
.tree-btn.delete {
|
|
color: var(--tree-delete);
|
|
}
|
|
|
|
.tree-btn:hover {
|
|
filter: brightness(1.18);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.count-badge {
|
|
margin-left: 0.35rem;
|
|
padding: 0.04rem 0.38rem;
|
|
border-radius: 999px;
|
|
background: color-mix(in srgb, var(--fg) 10%, transparent);
|
|
color: var(--muted);
|
|
font-size: 0.65rem;
|
|
font-family: "JetBrains Mono", monospace;
|
|
}
|
|
|
|
.draft-row {
|
|
opacity: 0.45;
|
|
}
|
|
|
|
.rename-progress-inner {
|
|
min-width: 22rem;
|
|
padding: 1rem;
|
|
}
|
|
|
|
.rename-progress-label,
|
|
.rename-progress-count {
|
|
margin-top: 0.5rem;
|
|
margin-bottom: 1rem;
|
|
color: var(--muted);
|
|
}
|
|
|
|
#rename-progress {
|
|
background: var(--bg);
|
|
color: var(--fg);
|
|
border: 1px solid var(--border);
|
|
}
|
|
|
|
#rename-progress progress {
|
|
width: 100%;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<header class="topbar">
|
|
<div class="brand">
|
|
<a href="/">{{ .WikiName }}</a>
|
|
</div>
|
|
|
|
<nav>
|
|
{{ range .NavItems }}
|
|
<a href="{{ .ResolvedHref }}">{{ .Label }}</a>
|
|
{{ end }}
|
|
</nav>
|
|
{{ template "auth-menu" . }}</header>
|
|
|
|
<main class="container">
|
|
<section class="card">
|
|
|
|
<h1>{{ T "tree.title" }}</h1>
|
|
<nav aria-label="{{ T "tree.title" }}" class="tree-breadcrumbs">
|
|
<a href="/v/tree">/</a>
|
|
{{ range .Breadcrumbs }}<a href="/v/tree{{ .Path }}">{{ .Name }}</a> / {{ end }}
|
|
</nav>
|
|
|
|
<div class="tree-toolbar">
|
|
<div>
|
|
<input
|
|
id="tree-filter"
|
|
type="text"
|
|
placeholder="{{ T "tree.filter" }}"
|
|
oninput="filterTree()"
|
|
>
|
|
</div>
|
|
<div>
|
|
<button type="button" onclick="expandAllTree()">{{ T "tree.expand_all" }}</button>
|
|
<button type="button" onclick="collapseAllTree()">{{ T "tree.collapse_all" }}</button>
|
|
<label><input id="tree-select-all" type="checkbox" onchange="selectAllVisible(this.checked)"> {{ T "tree.select_all" }}</label>
|
|
<a href="/v/upload?path={{ .Path }}">{{ T "upload.submit" }}</a>
|
|
<button type="button" onclick="moveSelected()">{{ T "tree.move_selected" }}</button>
|
|
<button type="button" onclick="deleteSelected()">{{ T "tree.delete_selected" }}</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tree">
|
|
{{ range .Nodes }}
|
|
|
|
<div
|
|
class="tree-row {{ if .IsDraft }}draft-row{{ end }}"
|
|
data-path="{{ .Path }}"
|
|
data-depth="{{ .Depth }}"
|
|
data-is-dir="{{ .IsDir }}"
|
|
>
|
|
|
|
<div class="tree-left">
|
|
<input class="tree-select" type="checkbox" value="{{ .Path }}" aria-label="{{ .Path }}">
|
|
|
|
{{ range $i := until .Depth }}
|
|
<div class="tree-indent"></div>
|
|
{{ end }}
|
|
|
|
<div class="tree-node">
|
|
|
|
{{ if .IsDir }}
|
|
<button class="tree-toggle" type="button" aria-expanded="true" aria-label="Collapse" title="Collapse">▶</button>
|
|
{{ else }}
|
|
<span class="tree-toggle-spacer" aria-hidden="true"></span>
|
|
{{ end }}
|
|
|
|
<div class="tree-icon {{ if .IsDir }}dir{{ else }}file{{ end }} {{ if .IsDraft }}draft{{ end }}">
|
|
{{ if .IsDir }}
|
|
|
|
{{ else }}
|
|
|
|
{{ end }}
|
|
</div>
|
|
|
|
<a href="{{ .Href }}" class="tree-link">
|
|
{{ .Name }}
|
|
</a>
|
|
|
|
{{ if .IsDir }}
|
|
<a href="/v/tree{{ .Path }}" class="tree-btn" title="{{ T "tree.open_subtree" }}">↳</a>
|
|
<span class="count-badge">
|
|
{{ .ChildCount }}
|
|
</span>
|
|
{{ end }}
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tree-actions">
|
|
|
|
<a href="/e/-{{ .Path }}" class="tree-btn edit">
|
|
✎ {{ T "tree.edit" }}
|
|
</a>
|
|
|
|
<button class="tree-btn rename" onclick="renamePath('{{ .Path }}')">
|
|
⟲ {{ T "tree.rename" }}
|
|
</button>
|
|
|
|
<button class="tree-btn delete" onclick="deletePath('{{ .Path }}')">
|
|
⌫ {{ T "tree.delete" }}
|
|
</button>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
{{ end }}
|
|
</div>
|
|
|
|
</section>
|
|
</main>
|
|
|
|
<script>
|
|
async function renamePath(oldPath) {
|
|
const newPath =
|
|
prompt(
|
|
"{{ T "tree.new_path" }}:",
|
|
oldPath
|
|
)
|
|
|
|
if (!newPath || newPath === oldPath) {
|
|
return
|
|
}
|
|
|
|
await renameSinglePath(oldPath, newPath, true)
|
|
location.reload()
|
|
}
|
|
|
|
async function deletePath(path) {
|
|
if (!confirm("{{ T "tree.confirm_delete" }}\\n\\n" + path)) {
|
|
return
|
|
}
|
|
await removePaths([path])
|
|
location.reload()
|
|
}
|
|
|
|
function selectedPaths() {
|
|
const paths = Array.from(document.querySelectorAll(".tree-select:checked"))
|
|
.map(input => input.value)
|
|
.sort((a, b) => a.length - b.length)
|
|
return paths.filter((path, index) =>
|
|
!paths.slice(0, index).some(parent => path.startsWith(parent + "/"))
|
|
)
|
|
}
|
|
|
|
function selectAllVisible(checked) {
|
|
for (const input of document.querySelectorAll(".tree-select")) {
|
|
if (input.closest(".tree-row").style.display !== "none") {
|
|
input.checked = checked
|
|
}
|
|
}
|
|
}
|
|
|
|
async function deleteSelected() {
|
|
const paths = selectedPaths()
|
|
if (!paths.length || !confirm("{{ T "tree.confirm_delete" }}\\n\\n" + paths.join("\\n"))) return
|
|
await removePaths(paths)
|
|
location.reload()
|
|
}
|
|
|
|
async function moveSelected() {
|
|
const paths = selectedPaths()
|
|
if (!paths.length) return
|
|
const target = prompt("{{ T "tree.target_directory" }}:", "/")
|
|
if (!target) return
|
|
const base = target.endsWith("/") ? target.slice(0, -1) : target
|
|
for (const oldPath of paths) {
|
|
const name = oldPath.split("/").filter(Boolean).pop()
|
|
const newPath = base + "/" + name
|
|
await renameSinglePath(oldPath, newPath, true)
|
|
}
|
|
location.reload()
|
|
}
|
|
|
|
async function removePaths(paths) {
|
|
const res = await fetch("/_/api/v1/path/remove", {
|
|
method: "POST",
|
|
headers: {"Content-Type": "application/json"},
|
|
body: JSON.stringify({paths, recursive: true}),
|
|
})
|
|
if (!res.ok) {
|
|
alert("{{ T "tree.operation_failed" }}: " + await res.text())
|
|
throw new Error("remove failed")
|
|
}
|
|
}
|
|
|
|
function filterTree() {
|
|
const q =
|
|
document
|
|
.getElementById("tree-filter")
|
|
.value
|
|
.toLowerCase()
|
|
|
|
applyTreeVisibility(q)
|
|
}
|
|
|
|
window.addEventListener('pageshow', event => { if (event.persisted) location.reload() })
|
|
const treeStateKey = "pageswiki.tree.collapsed." + location.host + ":" + {{ if .AuthUser }}{{ .AuthUser.UUID }}{{ else }}"anonymous"{{ end }} + ":" + {{ .Path }}
|
|
let collapsedTreePaths = new Set()
|
|
try { collapsedTreePaths = new Set(JSON.parse(localStorage.getItem(treeStateKey) || "[]")) } catch (_) {}
|
|
|
|
function saveTreeState() {
|
|
localStorage.setItem(treeStateKey, JSON.stringify(Array.from(collapsedTreePaths)))
|
|
}
|
|
|
|
function refreshTreeToggles() {
|
|
for (const row of document.querySelectorAll('.tree-row[data-is-dir="true"]')) {
|
|
setToggleState(row, !collapsedTreePaths.has(row.dataset.path))
|
|
}
|
|
applyTreeVisibility()
|
|
}
|
|
|
|
function expandAllTree() {
|
|
collapsedTreePaths.clear()
|
|
saveTreeState()
|
|
refreshTreeToggles()
|
|
}
|
|
|
|
function collapseAllTree() {
|
|
collapsedTreePaths = new Set(Array.from(document.querySelectorAll('.tree-row[data-is-dir="true"]'), row => row.dataset.path))
|
|
saveTreeState()
|
|
refreshTreeToggles()
|
|
}
|
|
|
|
function setToggleState(row, expanded) {
|
|
const button = row.querySelector(".tree-toggle")
|
|
if (!button) return
|
|
button.setAttribute("aria-expanded", String(expanded))
|
|
const label = document.documentElement.lang.startsWith("ja")
|
|
? (expanded ? "折りたたむ" : "展開する")
|
|
: (expanded ? "Collapse" : "Expand")
|
|
button.setAttribute("aria-label", label)
|
|
button.title = label
|
|
}
|
|
|
|
function applyTreeVisibility(query = document.getElementById("tree-filter").value.toLowerCase()) {
|
|
const rows = Array.from(document.querySelectorAll(".tree-row"))
|
|
if (query) {
|
|
const visible = new Set()
|
|
for (const row of rows) {
|
|
const path = row.dataset.path.toLowerCase()
|
|
if (!path.includes(query)) continue
|
|
visible.add(row.dataset.path)
|
|
let parent = row.dataset.path
|
|
while ((parent = parent.slice(0, parent.lastIndexOf("/")))) visible.add(parent || "/")
|
|
}
|
|
for (const row of rows) row.style.display = visible.has(row.dataset.path) ? "flex" : "none"
|
|
return
|
|
}
|
|
const collapsedDepths = []
|
|
for (const row of rows) {
|
|
const depth = Number(row.dataset.depth)
|
|
while (collapsedDepths.length && collapsedDepths[collapsedDepths.length - 1] >= depth) collapsedDepths.pop()
|
|
row.style.display = collapsedDepths.length ? "none" : "flex"
|
|
if (row.dataset.isDir === "true" && collapsedTreePaths.has(row.dataset.path)) collapsedDepths.push(depth)
|
|
}
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
for (const row of document.querySelectorAll('.tree-row[data-is-dir="true"]')) {
|
|
setToggleState(row, !collapsedTreePaths.has(row.dataset.path))
|
|
row.querySelector(".tree-toggle")?.addEventListener("click", event => {
|
|
event.preventDefault()
|
|
event.stopPropagation()
|
|
const expanded = collapsedTreePaths.has(row.dataset.path)
|
|
if (expanded) collapsedTreePaths.delete(row.dataset.path)
|
|
else collapsedTreePaths.add(row.dataset.path)
|
|
setToggleState(row, expanded)
|
|
saveTreeState()
|
|
applyTreeVisibility()
|
|
})
|
|
}
|
|
applyTreeVisibility()
|
|
})
|
|
|
|
async function renameSinglePath(oldPath, newPath, recursive) {
|
|
const res =
|
|
await fetch(
|
|
"/_/api/v1/path/rename",
|
|
{
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
old_path: oldPath,
|
|
new_path: newPath,
|
|
recursive: recursive,
|
|
}),
|
|
}
|
|
)
|
|
|
|
if (!res.ok) {
|
|
alert("{{ T "tree.operation_failed" }}: " + await res.text())
|
|
throw new Error("rename failed: " + oldPath)
|
|
}
|
|
}
|
|
|
|
function createRenameProgressDialog() {
|
|
let dlg =
|
|
document.getElementById("rename-progress")
|
|
|
|
if (dlg) {
|
|
return dlg
|
|
}
|
|
|
|
dlg =
|
|
document.createElement("dialog")
|
|
|
|
dlg.id =
|
|
"rename-progress"
|
|
|
|
dlg.innerHTML = `
|
|
<div class="rename-progress-inner">
|
|
<h3>{{ T "tree.rename" }}</h3>
|
|
<div class="rename-progress-label"></div>
|
|
<progress value="0" max="100"></progress>
|
|
</div>
|
|
`
|
|
|
|
document.body.appendChild(dlg)
|
|
|
|
return dlg
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
{{ end }}
|