init
This commit is contained in:
commit
fa6a4c650f
93 files changed
+6555
No files matched your search
@@ -0,0 +1,60 @@
|
||||
{{ define "base" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>{{ .Title }}</title>
|
||||
|
||||
<link rel="stylesheet" href="/static/css/main.css">
|
||||
<link rel="stylesheet" href="/static/css/modes.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body class="{{ template "body-class" . }}">
|
||||
|
||||
<header class="topbar">
|
||||
|
||||
<div class="brand">
|
||||
<a href="/">Pages Wiki</a>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
|
||||
<a href="/new">New</a>
|
||||
<a href="/l">Links</a>
|
||||
|
||||
{{ if .Path }}
|
||||
|
||||
<a href="{{ .Path }}">
|
||||
View
|
||||
</a>
|
||||
|
||||
<a href="/e{{ .Path }}">
|
||||
Edit
|
||||
</a>
|
||||
|
||||
<a href="/raw{{ .Path }}">
|
||||
Raw
|
||||
</a>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
{{ template "content" . }}
|
||||
</main>
|
||||
|
||||
{{ template "scripts" . }}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
|
||||
{{ define "body-class" }}
|
||||
mode-view
|
||||
{{ end }}
|
||||
@@ -0,0 +1,3 @@
|
||||
Insert before </body>
|
||||
|
||||
{{ template "scripts" . }}
|
||||
@@ -0,0 +1,3 @@
|
||||
{{ define "body-class" }}
|
||||
mode-view
|
||||
{{ end }}
|
||||
@@ -0,0 +1,8 @@
|
||||
{{ define "scripts" }}
|
||||
|
||||
<script src="/static/js/editor.js"></script>
|
||||
<script src="/static/js/navigation.js"></script>
|
||||
<script src="/static/js/revisions.js"></script>
|
||||
<script src="/static/js/search.js"></script>
|
||||
|
||||
{{ end }}
|
||||
@@ -0,0 +1,148 @@
|
||||
{{ define "editor.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<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"
|
||||
>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="mode-editor">
|
||||
|
||||
<header class="topbar">
|
||||
|
||||
<div class="brand">
|
||||
<a href="/">Pages Wiki</a>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
|
||||
<a href="/">Home</a>
|
||||
|
||||
{{ if .Path }}
|
||||
|
||||
<a href="{{ .Path }}">
|
||||
View
|
||||
</a>
|
||||
|
||||
<a href="/r/history/{{ .ObjectUUID }}">
|
||||
History
|
||||
</a>
|
||||
|
||||
<a href="/l?object_uuid={{ .ObjectUUID }}">
|
||||
Links
|
||||
</a>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
|
||||
<section class="card">
|
||||
|
||||
<div class="path-label">
|
||||
{{ .Path }}
|
||||
</div>
|
||||
|
||||
<div class="editor-toolbar">
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="PagesEditor.saveNow()"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="PagesPathActions.renameCurrentPath()"
|
||||
>
|
||||
Rename
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="PagesPathActions.removeCurrentPath()"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
|
||||
<a
|
||||
class="button"
|
||||
href="/r/history/{{ .ObjectUUID }}"
|
||||
>
|
||||
History
|
||||
</a>
|
||||
|
||||
<select id="editor-type">
|
||||
|
||||
<option
|
||||
value="html"
|
||||
{{ if eq .EditType "html" }}selected{{ end }}
|
||||
>
|
||||
HTML
|
||||
</option>
|
||||
|
||||
<option
|
||||
value="markdown"
|
||||
{{ if eq .EditType "markdown" }}selected{{ end }}
|
||||
>
|
||||
Markdown
|
||||
</option>
|
||||
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="editor-grid">
|
||||
|
||||
<textarea
|
||||
id="editor"
|
||||
class="editor"
|
||||
>{{ .Body }}</textarea>
|
||||
|
||||
<article
|
||||
id="preview"
|
||||
class="preview"
|
||||
></article>
|
||||
|
||||
</div>
|
||||
|
||||
<input
|
||||
type="hidden"
|
||||
id="object-uuid"
|
||||
value="{{ .ObjectUUID }}"
|
||||
>
|
||||
|
||||
<input
|
||||
type="hidden"
|
||||
id="edit-type"
|
||||
value="{{ .EditType }}"
|
||||
>
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
<script src="/o/path:/system/static/js/editor.js"></script>
|
||||
<script src="/o/path:/system/static/js/path-actions.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,3 @@
|
||||
{{ define "editor-body-class" }}
|
||||
mode-editor
|
||||
{{ end }}
|
||||
@@ -0,0 +1,41 @@
|
||||
{{ define "explorer.gohtml" }}
|
||||
{{ template "base" . }}
|
||||
{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
|
||||
<section class="card">
|
||||
|
||||
<h1>Explorer</h1>
|
||||
|
||||
<div class="tree-root">
|
||||
{{ template "tree-node" .Tree }}
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
{{ end }}
|
||||
|
||||
{{ define "tree-node" }}
|
||||
|
||||
<ul class="tree">
|
||||
|
||||
{{ range . }}
|
||||
|
||||
<li>
|
||||
|
||||
<a href="{{ .Path }}">
|
||||
{{ .Path }}
|
||||
</a>
|
||||
|
||||
{{ if .Children }}
|
||||
{{ template "tree-node" .Children }}
|
||||
{{ end }}
|
||||
|
||||
</li>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</ul>
|
||||
|
||||
{{ end }}
|
||||
@@ -0,0 +1,200 @@
|
||||
{{ define "home.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Pages Wiki</title>
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/o/path:/system/static/css/main.css"
|
||||
>
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/o/path:/system/static/css/modes.css"
|
||||
>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="mode-home">
|
||||
|
||||
<header class="topbar">
|
||||
|
||||
<div class="brand">
|
||||
<a href="/">Pages Wiki</a>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
|
||||
<a href="/tree">
|
||||
Tree
|
||||
</a>
|
||||
|
||||
<a href="/new">
|
||||
Draft
|
||||
</a>
|
||||
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
|
||||
<section class="card">
|
||||
|
||||
<h1>Pages Wiki</h1>
|
||||
|
||||
<p>
|
||||
Path-first semantic wiki.
|
||||
</p>
|
||||
|
||||
<div class="create-path-box">
|
||||
|
||||
<input
|
||||
id="new-path"
|
||||
type="text"
|
||||
placeholder="/pageswiki/hogehoge"
|
||||
autofocus
|
||||
>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="createOrEditPath()"
|
||||
>
|
||||
Create / Edit
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<p class="hint">
|
||||
Examples:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>/pageswiki/network/bgp</li>
|
||||
<li>/notes/todo</li>
|
||||
<li>/dc/cooling</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
|
||||
<h2>Recent Objects</h2>
|
||||
|
||||
<ul class="object-list">
|
||||
|
||||
{{ range .Objects }}
|
||||
|
||||
<li>
|
||||
<a href="/e/{{ .UUID }}">
|
||||
{{ .UUID }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
|
||||
function normalizePath(input) {
|
||||
|
||||
let p = input.trim()
|
||||
|
||||
if (!p.startsWith("/")) {
|
||||
p = "/" + p
|
||||
}
|
||||
|
||||
p = p.replace(/\/+/g, "/")
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
function createOrEditPath() {
|
||||
|
||||
const input =
|
||||
document.getElementById(
|
||||
"new-path",
|
||||
)
|
||||
|
||||
if (!input.value.trim()) {
|
||||
return
|
||||
}
|
||||
|
||||
const path =
|
||||
normalizePath(
|
||||
input.value,
|
||||
)
|
||||
|
||||
location.href =
|
||||
"/e" + path
|
||||
}
|
||||
|
||||
document
|
||||
.getElementById(
|
||||
"new-path",
|
||||
)
|
||||
.addEventListener(
|
||||
"keydown",
|
||||
(ev) => {
|
||||
|
||||
if (ev.key === "Enter") {
|
||||
|
||||
ev.preventDefault()
|
||||
|
||||
createOrEditPath()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
.create-path-box {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.create-path-box input {
|
||||
flex: 1;
|
||||
background: #111;
|
||||
color: #eee;
|
||||
border: 1px solid #333;
|
||||
padding: 0.6rem;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.create-path-box button {
|
||||
padding: 0.6rem 1rem;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-top: 1rem;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.object-list {
|
||||
margin: 0;
|
||||
padding-left: 1.2rem;
|
||||
}
|
||||
|
||||
.object-list li {
|
||||
margin: 0.2rem 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,89 @@
|
||||
{{ define "links.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<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"
|
||||
>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="mode-links">
|
||||
|
||||
<header class="topbar">
|
||||
|
||||
<div class="brand">
|
||||
<a href="/">Pages Wiki</a>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
|
||||
<a href="/">Home</a>
|
||||
<a href="/new">New</a>
|
||||
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
|
||||
<section class="card">
|
||||
|
||||
<h1>Path Link Manager</h1>
|
||||
|
||||
<div class="link-grid">
|
||||
|
||||
<div>
|
||||
|
||||
<label>
|
||||
Object UUID
|
||||
</label>
|
||||
|
||||
<input
|
||||
id="link-object-uuid"
|
||||
class="input"
|
||||
value="{{ .ObjectUUID }}"
|
||||
>
|
||||
|
||||
<label>
|
||||
Semantic Path
|
||||
</label>
|
||||
|
||||
<input
|
||||
id="link-path"
|
||||
class="input"
|
||||
placeholder="/research/network/bgp"
|
||||
>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="bindPath()"
|
||||
>
|
||||
Bind Path
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
<script src="/o/path:/system/static/js/navigation.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,90 @@
|
||||
{{ define "page.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<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"
|
||||
>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="mode-page">
|
||||
|
||||
<header class="topbar">
|
||||
|
||||
<div class="brand">
|
||||
<a href="/">Pages Wiki</a>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
|
||||
<a href="/">Home</a>
|
||||
|
||||
{{ if .Path }}
|
||||
|
||||
<a href="/e{{ .Path }}">
|
||||
Edit
|
||||
</a>
|
||||
|
||||
<a href="/r/history/{{ .ObjectUUID }}">
|
||||
History
|
||||
</a>
|
||||
|
||||
<a href="/l?object_uuid={{ .ObjectUUID }}">
|
||||
Links
|
||||
</a>
|
||||
|
||||
<a href="/raw{{ .Path }}">
|
||||
Raw
|
||||
</a>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
|
||||
<section class="card">
|
||||
|
||||
<div class="path-label">
|
||||
{{ .Path }}
|
||||
</div>
|
||||
|
||||
<article class="page-html">
|
||||
{{ .RenderedHTML }}
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
<style>
|
||||
|
||||
.children-list ul {
|
||||
margin: 0;
|
||||
padding-left: 1.2rem;
|
||||
}
|
||||
|
||||
.children-list li {
|
||||
margin: 0.15rem 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,49 @@
|
||||
{{ define "revision_diff.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>{{ .Title }}</title>
|
||||
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/revisions.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<main class="container">
|
||||
|
||||
<section class="card">
|
||||
|
||||
<h1>Revision Diff</h1>
|
||||
|
||||
<div class="revision-meta">
|
||||
|
||||
<div>
|
||||
Before:
|
||||
<code>{{ .Before.Hash }}</code>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
After:
|
||||
<code>{{ .After.Hash }}</code>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
|
||||
{{ .DiffHTML }}
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,106 @@
|
||||
{{ define "revision_view.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>{{ .Title }}</title>
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/o/path:/system/static/css/main.css"
|
||||
>
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/o/path:/system/static/css/revisions.css"
|
||||
>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="mode-revision-view">
|
||||
|
||||
<header class="topbar">
|
||||
|
||||
<div class="brand">
|
||||
<a href="/">Pages Wiki</a>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
|
||||
<a
|
||||
href="/r/history/{{ .Revision.ObjectUUID }}"
|
||||
>
|
||||
History
|
||||
</a>
|
||||
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
|
||||
<section class="card">
|
||||
|
||||
<h1>Revision View</h1>
|
||||
|
||||
<div class="revision-meta">
|
||||
|
||||
<div>
|
||||
Revision Hash:
|
||||
<code>{{ .Revision.Hash }}</code>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
Object UUID:
|
||||
<code>{{ .Revision.ObjectUUID }}</code>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
Message:
|
||||
{{ .Revision.Message }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
Created:
|
||||
{{ .Revision.CreatedAt }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
|
||||
<h2>Rendered</h2>
|
||||
|
||||
<article class="page-html">
|
||||
{{ .RenderedHTML }}
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
|
||||
<details>
|
||||
|
||||
<summary>
|
||||
Raw HTML Source
|
||||
</summary>
|
||||
|
||||
<textarea
|
||||
readonly
|
||||
class="revision-textarea"
|
||||
>{{ .Revision.Body }}</textarea>
|
||||
|
||||
</details>
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,108 @@
|
||||
{{ define "revisions.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>{{ .Title }}</title>
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/o/path:/system/static/css/main.css"
|
||||
>
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/o/path:/system/static/css/revisions.css"
|
||||
>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="mode-revisions">
|
||||
|
||||
<header class="topbar">
|
||||
|
||||
<div class="brand">
|
||||
<a href="/">Pages Wiki</a>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
|
||||
<a href="/">Home</a>
|
||||
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
|
||||
<section class="card">
|
||||
|
||||
<h1>Revision History</h1>
|
||||
|
||||
<p>
|
||||
Object UUID:
|
||||
<code>{{ .ObjectUUID }}</code>
|
||||
</p>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="revision-timeline">
|
||||
|
||||
{{ range $i, $r := .Revisions }}
|
||||
|
||||
<article class="revision-card">
|
||||
|
||||
<div class="revision-header">
|
||||
|
||||
<div>
|
||||
<code>{{ $r.Hash }}</code>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ $r.CreatedAt }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="revision-message">
|
||||
{{ $r.Message }}
|
||||
</div>
|
||||
|
||||
<div class="revision-actions">
|
||||
|
||||
<a
|
||||
class="button"
|
||||
href="/r/view/{{ $r.Hash }}"
|
||||
>
|
||||
View
|
||||
</a>
|
||||
|
||||
{{ if lt (add $i 1) (len $.Revisions) }}
|
||||
|
||||
{{ $prev := index $.Revisions (add $i 1) }}
|
||||
|
||||
<a
|
||||
class="button"
|
||||
href="/r/diff/{{ $prev.Hash }}/{{ $r.Hash }}"
|
||||
>
|
||||
Diff Prev
|
||||
</a>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
|
||||
</article>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,978 @@
|
||||
{{ define "tree.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Tree</title>
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@fontsource/jetbrains-mono@5.0.20/index.css"
|
||||
/>
|
||||
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/o/path:/system/static/css/main.css"
|
||||
>
|
||||
|
||||
<style>
|
||||
|
||||
:root {
|
||||
|
||||
--bg: #0b0b0c;
|
||||
--panel: var(--bg);
|
||||
|
||||
--line:
|
||||
rgba(255,255,255,0.06);
|
||||
|
||||
--link:
|
||||
#c27cff;
|
||||
|
||||
--link-hover:
|
||||
#e2b9ff;
|
||||
|
||||
--edit:
|
||||
#e0c25f;
|
||||
|
||||
--rename:
|
||||
#64d7ee;
|
||||
|
||||
--delete:
|
||||
#ff6d6d;
|
||||
}
|
||||
|
||||
body {
|
||||
|
||||
background: var(--bg);
|
||||
|
||||
color: #ddd;
|
||||
|
||||
margin: 0;
|
||||
|
||||
font-family:
|
||||
Inter,
|
||||
"Noto Sans JP",
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
|
||||
height: 48px;
|
||||
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
|
||||
justify-content: space-between;
|
||||
|
||||
padding: 0 1rem;
|
||||
|
||||
border-bottom:
|
||||
1px solid rgba(255,255,255,0.05);
|
||||
}
|
||||
|
||||
.topbar a {
|
||||
|
||||
color: #9cc8ff;
|
||||
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.container {
|
||||
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
|
||||
.card {
|
||||
|
||||
background: transparent;
|
||||
|
||||
border: none;
|
||||
|
||||
padding: 1rem 1rem 2rem 1rem;
|
||||
}
|
||||
|
||||
|
||||
.tree-toolbar {
|
||||
|
||||
display: flex;
|
||||
|
||||
justify-content: space-between;
|
||||
|
||||
align-items: center;
|
||||
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.tree-toolbar input {
|
||||
|
||||
width: 28rem;
|
||||
|
||||
background: #090909;
|
||||
|
||||
color: #ddd;
|
||||
|
||||
border:
|
||||
1px solid rgba(255,255,255,0.08);
|
||||
|
||||
padding: 0.7rem;
|
||||
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.tree {
|
||||
|
||||
display: flex;
|
||||
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.tree-row {
|
||||
|
||||
position: relative;
|
||||
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
|
||||
justify-content: space-between;
|
||||
|
||||
height: 30px;
|
||||
|
||||
|
||||
border-bottom:
|
||||
1px solid rgba(255,255,255,0.045);
|
||||
|
||||
|
||||
transition:
|
||||
background 0.08s linear;
|
||||
}
|
||||
|
||||
.tree-row:hover {
|
||||
|
||||
|
||||
background:
|
||||
rgba(255,255,255,0.018);
|
||||
|
||||
}
|
||||
|
||||
.tree-left {
|
||||
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
|
||||
min-width: 0;
|
||||
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.tree-indent {
|
||||
|
||||
width: 18px;
|
||||
|
||||
height: 30px;
|
||||
|
||||
border-left:
|
||||
1px solid rgba(255,255,255,0.08);
|
||||
}
|
||||
|
||||
.tree-node {
|
||||
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.tree-icon {
|
||||
|
||||
width: 1rem;
|
||||
|
||||
text-align: center;
|
||||
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.tree-link {
|
||||
|
||||
text-decoration: none;
|
||||
|
||||
color: var(--link);
|
||||
|
||||
font-family:
|
||||
"JetBrains Mono",
|
||||
monospace;
|
||||
|
||||
transition:
|
||||
color 0.08s linear,
|
||||
text-shadow 0.08s linear;
|
||||
}
|
||||
|
||||
.tree-link:hover {
|
||||
|
||||
color: var(--link-hover);
|
||||
|
||||
text-shadow:
|
||||
0 0 0.45rem rgba(220,180,255,0.35);
|
||||
}
|
||||
|
||||
.tree-actions {
|
||||
|
||||
display: flex;
|
||||
|
||||
gap: 0.85rem;
|
||||
|
||||
opacity: 0.52;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
.tree-btn.edit {
|
||||
|
||||
color: var(--edit);
|
||||
}
|
||||
|
||||
.tree-btn.rename {
|
||||
|
||||
color: var(--rename);
|
||||
}
|
||||
|
||||
.tree-btn.delete {
|
||||
|
||||
color: var(--delete);
|
||||
}
|
||||
|
||||
.tree-btn:hover {
|
||||
|
||||
filter: brightness(1.18);
|
||||
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.count-badge {
|
||||
|
||||
margin-left: 0.35rem;
|
||||
|
||||
padding:
|
||||
0.08rem 0.42rem;
|
||||
|
||||
border-radius: 999px;
|
||||
|
||||
background:
|
||||
rgba(255,255,255,0.12);
|
||||
|
||||
color: #ddd;
|
||||
|
||||
font-size: 0.68rem;
|
||||
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.draft-row {
|
||||
|
||||
opacity: 0.45;
|
||||
}
|
||||
|
||||
|
||||
|
||||
body {
|
||||
|
||||
background:
|
||||
var(--bg);
|
||||
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.container {
|
||||
|
||||
padding:
|
||||
1rem 1rem 4rem 1rem;
|
||||
}
|
||||
|
||||
.tree {
|
||||
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.tree-row {
|
||||
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.tree-toolbar {
|
||||
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.tree-toolbar input {
|
||||
|
||||
background:
|
||||
rgba(255,255,255,0.02);
|
||||
|
||||
border:
|
||||
1px solid rgba(255,255,255,0.06);
|
||||
}
|
||||
|
||||
.tree-toolbar input:focus {
|
||||
|
||||
outline: none;
|
||||
|
||||
border-color:
|
||||
rgba(180,120,255,0.45);
|
||||
|
||||
box-shadow:
|
||||
0 0 0.6rem rgba(180,120,255,0.12);
|
||||
}
|
||||
|
||||
|
||||
|
||||
.rename-progress-inner {
|
||||
|
||||
min-width: 22rem;
|
||||
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.rename-progress-count {
|
||||
|
||||
margin-top: 0.5rem;
|
||||
|
||||
margin-bottom: 1rem;
|
||||
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
#rename-progress {
|
||||
|
||||
background: #111;
|
||||
|
||||
color: #eee;
|
||||
|
||||
border:
|
||||
1px solid rgba(255,255,255,0.08);
|
||||
}
|
||||
|
||||
#rename-progress progress {
|
||||
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.tree-node {
|
||||
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
|
||||
gap: 0.48rem;
|
||||
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tree-icon {
|
||||
|
||||
width: 1.2rem;
|
||||
|
||||
text-align: center;
|
||||
|
||||
font-family:
|
||||
"Hack Nerd Font";
|
||||
|
||||
font-size: 1rem;
|
||||
|
||||
opacity: 0.92;
|
||||
|
||||
transition:
|
||||
transform 0.08s linear,
|
||||
text-shadow 0.08s linear,
|
||||
opacity 0.08s linear;
|
||||
}
|
||||
|
||||
.tree-row:hover .tree-icon {
|
||||
|
||||
transform:
|
||||
translateY(-1px);
|
||||
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.tree-icon.dir {
|
||||
|
||||
color:
|
||||
#c792ff;
|
||||
|
||||
text-shadow:
|
||||
0 0 0.4rem rgba(180,120,255,0.18);
|
||||
}
|
||||
|
||||
.tree-icon.file {
|
||||
|
||||
color:
|
||||
#8ad6ff;
|
||||
|
||||
text-shadow:
|
||||
0 0 0.4rem rgba(120,180,255,0.12);
|
||||
}
|
||||
|
||||
.tree-icon.draft {
|
||||
|
||||
color:
|
||||
#999;
|
||||
|
||||
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:
|
||||
#f0d7ff;
|
||||
|
||||
text-shadow:
|
||||
0 0 0.45rem rgba(220,180,255,0.32);
|
||||
|
||||
transform:
|
||||
translateX(1px);
|
||||
}
|
||||
|
||||
.tree-row {
|
||||
|
||||
position: relative;
|
||||
|
||||
border-left:
|
||||
1px solid rgba(255,255,255,0.04);
|
||||
|
||||
padding-left: 0.2rem;
|
||||
}
|
||||
|
||||
.tree-row:hover {
|
||||
|
||||
border-left-color:
|
||||
rgba(200,140,255,0.35);
|
||||
}
|
||||
|
||||
.count-badge {
|
||||
|
||||
margin-left: 0.35rem;
|
||||
|
||||
padding:
|
||||
0.04rem 0.38rem;
|
||||
|
||||
border-radius: 999px;
|
||||
|
||||
background:
|
||||
rgba(255,255,255,0.08);
|
||||
|
||||
color:
|
||||
rgba(255,255,255,0.72);
|
||||
|
||||
font-size: 0.65rem;
|
||||
|
||||
font-family:
|
||||
"JetBrains Mono",
|
||||
monospace;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
@font-face {
|
||||
|
||||
font-family:
|
||||
"Hack Nerd Font";
|
||||
|
||||
src:
|
||||
url(
|
||||
"https://cdn.jsdelivr.net/gh/ryanoasis/nerd-fonts@master/patched-fonts/Hack/Regular/HackNerdFont-Regular.ttf"
|
||||
)
|
||||
format("truetype");
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<header class="topbar">
|
||||
|
||||
<div>
|
||||
Pages Wiki
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
|
||||
<a href="/">
|
||||
Home
|
||||
</a>
|
||||
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
|
||||
<section class="card">
|
||||
|
||||
<h1>Content Tree</h1>
|
||||
|
||||
<div class="tree-toolbar">
|
||||
|
||||
<input
|
||||
id="tree-filter"
|
||||
type="text"
|
||||
placeholder="filter paths..."
|
||||
oninput="filterTree()"
|
||||
>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tree">
|
||||
|
||||
{{ range .Nodes }}
|
||||
|
||||
<div
|
||||
class="tree-row {{ if .IsDraft }}draft-row{{ end }}"
|
||||
data-path="{{ .Path }}"
|
||||
>
|
||||
|
||||
<div class="tree-left">
|
||||
|
||||
{{ range $i := until .Depth }}
|
||||
<div class="tree-indent"></div>
|
||||
{{ end }}
|
||||
|
||||
<div class="tree-node">
|
||||
|
||||
<div
|
||||
class="tree-icon
|
||||
{{ if .IsDir }}dir{{ else }}file{{ end }}
|
||||
{{ if .IsDraft }}draft{{ end }}"
|
||||
>
|
||||
|
||||
{{ if .IsDir }}
|
||||
|
||||
|
||||
|
||||
{{ else }}
|
||||
|
||||
|
||||
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
|
||||
<a
|
||||
href="{{ .Path }}"
|
||||
class="tree-link"
|
||||
>
|
||||
{{ .Name }}
|
||||
</a>
|
||||
|
||||
{{ if .IsDir }}
|
||||
|
||||
<span class="count-badge">
|
||||
{{ .ChildCount }}
|
||||
</span>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tree-actions">
|
||||
|
||||
<a
|
||||
href="/e{{ .Path }}"
|
||||
class="tree-btn edit"
|
||||
>
|
||||
✎ edit
|
||||
</a>
|
||||
|
||||
<button
|
||||
class="tree-btn rename"
|
||||
onclick="renamePath('{{ .Path }}')">
|
||||
⟲ rename
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="tree-btn delete"
|
||||
onclick="deletePath('{{ .Path }}')"
|
||||
>
|
||||
⌫ delete
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
async function renamePath(oldPath) {
|
||||
|
||||
const newPath =
|
||||
prompt(
|
||||
"Rename path:",
|
||||
oldPath,
|
||||
)
|
||||
|
||||
if (
|
||||
!newPath
|
||||
||
|
||||
newPath === oldPath
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
let recursive = false
|
||||
|
||||
if (
|
||||
confirm(
|
||||
oldPath + "\n\n" + newPath,
|
||||
)
|
||||
) {
|
||||
recursive = true
|
||||
}
|
||||
|
||||
if (!recursive) {
|
||||
|
||||
await renameSinglePath(
|
||||
oldPath,
|
||||
newPath,
|
||||
)
|
||||
|
||||
location.reload()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
const previewRes =
|
||||
await fetch(
|
||||
"/_/api/v1/path/rename-preview?old_path=" +
|
||||
encodeURIComponent(
|
||||
oldPath,
|
||||
),
|
||||
)
|
||||
|
||||
if (!previewRes.ok) {
|
||||
|
||||
alert(
|
||||
"preview failed",
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
const preview =
|
||||
await previewRes.json()
|
||||
|
||||
const targets =
|
||||
preview.targets
|
||||
|
||||
const ok =
|
||||
confirm(
|
||||
"Affected paths: " + "\n" + targets.length + "\n" + "Execute recursive rename?",
|
||||
)
|
||||
|
||||
if (!ok) {
|
||||
return
|
||||
}
|
||||
|
||||
const dlg =
|
||||
createRenameProgressDialog()
|
||||
|
||||
const bar =
|
||||
dlg.querySelector(
|
||||
"progress",
|
||||
)
|
||||
|
||||
const label =
|
||||
dlg.querySelector(
|
||||
".rename-progress-label",
|
||||
)
|
||||
|
||||
dlg.showModal()
|
||||
|
||||
let done = 0
|
||||
|
||||
for (const oldTarget of targets) {
|
||||
|
||||
const newTarget =
|
||||
oldTarget.replace(
|
||||
oldPath,
|
||||
newPath,
|
||||
)
|
||||
|
||||
label.textContent =
|
||||
oldTarget
|
||||
|
||||
await renameSinglePath(
|
||||
oldTarget,
|
||||
newTarget,
|
||||
)
|
||||
|
||||
done += 1
|
||||
|
||||
bar.value =
|
||||
done
|
||||
|
||||
bar.max =
|
||||
targets.length
|
||||
}
|
||||
|
||||
dlg.close()
|
||||
|
||||
location.reload()
|
||||
}
|
||||
|
||||
|
||||
async function deletePath(path) {
|
||||
|
||||
if (
|
||||
!confirm(
|
||||
"Delete path?\n\n" + path,
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
const res =
|
||||
await fetch(
|
||||
"/_/api/v1/path/remove",
|
||||
{
|
||||
method: "POST",
|
||||
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/json",
|
||||
},
|
||||
|
||||
body: JSON.stringify({
|
||||
path: path,
|
||||
}),
|
||||
},
|
||||
)
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
alert(
|
||||
"delete failed",
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
location.reload()
|
||||
}
|
||||
|
||||
function filterTree() {
|
||||
|
||||
const q =
|
||||
document
|
||||
.getElementById(
|
||||
"tree-filter",
|
||||
)
|
||||
.value
|
||||
.toLowerCase()
|
||||
|
||||
for (
|
||||
const row
|
||||
of document.querySelectorAll(
|
||||
".tree-row",
|
||||
)
|
||||
) {
|
||||
|
||||
const path =
|
||||
row.dataset.path
|
||||
.toLowerCase()
|
||||
|
||||
row.style.display =
|
||||
path.includes(q)
|
||||
? "flex"
|
||||
: "none"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function showRenameProgress(count) {
|
||||
|
||||
let dlg =
|
||||
document.getElementById(
|
||||
"rename-progress",
|
||||
)
|
||||
|
||||
if (!dlg) {
|
||||
|
||||
dlg =
|
||||
document.createElement("dialog")
|
||||
|
||||
dlg.id =
|
||||
"rename-progress"
|
||||
|
||||
dlg.innerHTML =
|
||||
"<div class=\"rename-progress-inner\">" +
|
||||
"<h3>Renaming namespace</h3>" +
|
||||
"<div class=\"rename-progress-count\">" +
|
||||
"affected pages: " + count +c
|
||||
"</div>" +
|
||||
"<progress></progress>" +
|
||||
"</div>"
|
||||
|
||||
document.body.appendChild(
|
||||
dlg,
|
||||
)
|
||||
}
|
||||
|
||||
dlg.showModal()
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function renameSinglePath(
|
||||
oldPath,
|
||||
newPath,
|
||||
) {
|
||||
|
||||
const res =
|
||||
await fetch(
|
||||
"/_/api/v1/path/rename",
|
||||
{
|
||||
method: "POST",
|
||||
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/json",
|
||||
},
|
||||
|
||||
body: JSON.stringify({
|
||||
old_path: oldPath,
|
||||
new_path: newPath,
|
||||
}),
|
||||
},
|
||||
)
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
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>
|
||||
Renaming namespace
|
||||
</h3>
|
||||
|
||||
<div class="rename-progress-label">
|
||||
</div>
|
||||
|
||||
<progress
|
||||
value="0"
|
||||
max="100"
|
||||
></progress>
|
||||
|
||||
</div>
|
||||
`
|
||||
|
||||
document.body.appendChild(
|
||||
dlg,
|
||||
)
|
||||
|
||||
return dlg
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,18 @@
|
||||
{{ define "breadcrumbs" }}
|
||||
|
||||
<nav class="breadcrumbs">
|
||||
|
||||
<a href="/">root</a>
|
||||
|
||||
{{ range .Breadcrumbs }}
|
||||
|
||||
/
|
||||
<a href="{{ .Path }}">
|
||||
{{ .Name }}
|
||||
</a>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</nav>
|
||||
|
||||
{{ end }}
|
||||
@@ -0,0 +1,15 @@
|
||||
{{ define "search_dialog" }}
|
||||
|
||||
<dialog id="search-dialog" class="dialog">
|
||||
<div class="dialog-body">
|
||||
<input
|
||||
id="search-input"
|
||||
class="search-input"
|
||||
placeholder="Search..."
|
||||
>
|
||||
|
||||
<ul id="search-results" class="search-results"></ul>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
{{ end }}
|
||||
Reference in new issue
Block a user