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.
1068 lines
23 KiB
Go Template
1068 lines
23 KiB
Go Template
{{ define "browser.gohtml" }}
|
||
<!DOCTYPE html>
|
||
<html lang="en">
|
||
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>Browser</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="/static/css/content-viewer.css">
|
||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||
<script defer src="/static/js/browser-thumbnails.js?v=1"></script>
|
||
|
||
<style>
|
||
|
||
.browser-layout {
|
||
display: grid;
|
||
grid-template-columns: var(--browser-sidebar-width, 14rem) 6px 1fr 6px var(--browser-preview-width, 22rem);
|
||
min-height: calc(100vh - 48px);
|
||
}
|
||
|
||
.browser-sidebar,
|
||
.browser-preview {
|
||
border-color: var(--border-soft);
|
||
padding: 0.75rem;
|
||
overflow: auto;
|
||
}
|
||
|
||
.browser-sidebar {
|
||
border-right: 1px solid var(--border-soft);
|
||
}
|
||
|
||
.browser-preview {
|
||
border-left: 1px solid var(--border-soft);
|
||
}
|
||
|
||
.browser-layout.no-sidebar .browser-sidebar {
|
||
display: none;
|
||
}
|
||
|
||
.browser-layout.no-preview .browser-preview {
|
||
display: none;
|
||
}
|
||
|
||
.browser-layout.no-sidebar {
|
||
grid-template-columns: 1fr 6px var(--browser-preview-width, 22rem);
|
||
}
|
||
|
||
.browser-layout.no-preview {
|
||
grid-template-columns: var(--browser-sidebar-width, 14rem) 6px 1fr;
|
||
}
|
||
|
||
.browser-layout.no-sidebar.no-preview {
|
||
grid-template-columns: 1fr;
|
||
}
|
||
|
||
.browser-main {
|
||
padding: 1rem;
|
||
overflow: auto;
|
||
}
|
||
|
||
.browser-toolbar {
|
||
display: flex;
|
||
gap: 0.5rem;
|
||
align-items: center;
|
||
margin-bottom: 0.75rem;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.icon-button {
|
||
min-width: 2.25rem;
|
||
height: 2.25rem;
|
||
padding: 0;
|
||
display: inline-grid;
|
||
place-items: center;
|
||
font-family: "JetBrains Mono", monospace;
|
||
}
|
||
|
||
.segmented {
|
||
display: inline-flex;
|
||
border: 1px solid var(--button-border);
|
||
border-radius: 0.25rem;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.segmented button {
|
||
border: none;
|
||
border-right: 1px solid var(--button-border);
|
||
border-radius: 0;
|
||
background: var(--button-bg);
|
||
}
|
||
|
||
.segmented button:last-child {
|
||
border-right: none;
|
||
}
|
||
|
||
.segmented button.active {
|
||
background: var(--row-hover);
|
||
color: var(--link-hover);
|
||
}
|
||
|
||
.sidebar-link {
|
||
display: block;
|
||
margin: 0.25rem 0;
|
||
font-family: "JetBrains Mono", monospace;
|
||
text-decoration: none;
|
||
}
|
||
|
||
.browser-sidebar.is-drop-target {
|
||
background: color-mix(in srgb, var(--accent) 12%, transparent);
|
||
box-shadow: inset 0 0 0 2px var(--accent);
|
||
}
|
||
|
||
.navigator-links {
|
||
min-height: 3rem;
|
||
margin-top: .45rem;
|
||
padding-top: .35rem;
|
||
border-top: 1px solid var(--border-soft);
|
||
}
|
||
|
||
.navigator-hint {
|
||
color: var(--muted);
|
||
font-size: .76rem;
|
||
line-height: 1.35;
|
||
}
|
||
|
||
.navigator-link {
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.pane-close {
|
||
min-width: 2rem;
|
||
height: 2rem;
|
||
padding: 0;
|
||
display: inline-grid;
|
||
place-items: center;
|
||
float: right;
|
||
}
|
||
|
||
.browser-path {
|
||
padding: 0.35rem 0;
|
||
border-bottom: 1px solid var(--border-soft);
|
||
}
|
||
|
||
.browser-path {
|
||
font-family: "JetBrains Mono", monospace;
|
||
color: var(--muted);
|
||
margin-bottom: 0.75rem;
|
||
}
|
||
|
||
.browser-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
|
||
gap: 0.55rem;
|
||
}
|
||
|
||
.browser-grid.details {
|
||
display: table;
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
}
|
||
|
||
.browser-row {
|
||
border: 1px solid var(--border-soft);
|
||
padding: 0.55rem;
|
||
cursor: default;
|
||
user-select: none;
|
||
background: var(--panel);
|
||
}
|
||
|
||
.browser-row:hover,
|
||
.browser-row.selected {
|
||
background: var(--row-hover);
|
||
border-color: var(--accent);
|
||
}
|
||
|
||
.browser-row.selected {
|
||
box-shadow: inset 0 0 0 1px var(--accent);
|
||
}
|
||
|
||
.browser-grid.details .browser-row {
|
||
display: table-row;
|
||
border: none;
|
||
}
|
||
|
||
.browser-grid.details .browser-cell {
|
||
display: table-cell;
|
||
padding: 0.42rem;
|
||
border-bottom: 1px solid var(--border-soft);
|
||
}
|
||
|
||
.browser-icon {
|
||
font-family: "Hack Nerd Font";
|
||
font-size: 1.35rem;
|
||
color: var(--link);
|
||
}
|
||
|
||
.browser-icon.dir {
|
||
color: var(--accent);
|
||
}
|
||
|
||
.browser-thumbnail {
|
||
display: block;
|
||
width: 100%;
|
||
height: 7rem;
|
||
border-radius: .35rem;
|
||
}
|
||
|
||
.browser-grid.details .browser-icon {
|
||
width: 3.5rem;
|
||
}
|
||
|
||
.browser-grid.details .browser-thumbnail {
|
||
width: 3rem;
|
||
height: 2.5rem;
|
||
}
|
||
|
||
.browser-name {
|
||
font-family: "JetBrains Mono", monospace;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.browser-meta {
|
||
color: var(--muted);
|
||
font-size: 0.82rem;
|
||
}
|
||
|
||
.context-menu {
|
||
position: fixed;
|
||
z-index: 1000;
|
||
min-width: 12rem;
|
||
display: none;
|
||
background: var(--bg);
|
||
border: 1px solid var(--border);
|
||
box-shadow: 0 0.4rem 1.4rem rgba(0,0,0,0.35);
|
||
}
|
||
|
||
.selection-marquee {
|
||
position: fixed;
|
||
z-index: 900;
|
||
display: none;
|
||
pointer-events: none;
|
||
border: 1px solid var(--accent);
|
||
background: color-mix(in srgb, var(--accent) 18%, transparent);
|
||
border-radius: .2rem;
|
||
}
|
||
|
||
.browser-selection-status {
|
||
min-width: 8rem;
|
||
color: var(--muted);
|
||
font-size: .82rem;
|
||
}
|
||
|
||
.browser-operation-stack {
|
||
position: fixed;
|
||
z-index: 1200;
|
||
left: 1rem;
|
||
bottom: 1rem;
|
||
width: min(22rem, calc(100vw - 2rem));
|
||
display: grid;
|
||
gap: .45rem;
|
||
pointer-events: none;
|
||
}
|
||
|
||
.browser-operation {
|
||
display: grid;
|
||
grid-template-columns: 2.65rem 1fr;
|
||
gap: .7rem;
|
||
align-items: center;
|
||
padding: .65rem .8rem;
|
||
border: 1px solid var(--border-soft);
|
||
border-radius: .7rem;
|
||
background: color-mix(in srgb, var(--panel) 92%, transparent);
|
||
box-shadow: 0 .45rem 1.6rem rgba(0,0,0,.28);
|
||
backdrop-filter: blur(14px);
|
||
pointer-events: auto;
|
||
}
|
||
|
||
.operation-ring {
|
||
width: 2.45rem;
|
||
height: 2.45rem;
|
||
transform: rotate(-90deg);
|
||
}
|
||
|
||
.operation-ring circle {
|
||
fill: none;
|
||
stroke-width: 3;
|
||
}
|
||
|
||
.operation-ring-track { stroke: var(--border-soft); }
|
||
.operation-ring-value {
|
||
stroke: var(--accent);
|
||
stroke-linecap: round;
|
||
stroke-dasharray: 100;
|
||
stroke-dashoffset: calc(100 - var(--operation-progress, 0));
|
||
transition: stroke-dashoffset .18s ease;
|
||
}
|
||
|
||
.browser-operation.indeterminate .operation-ring {
|
||
animation: browser-operation-spin .8s linear infinite;
|
||
}
|
||
|
||
.browser-operation.done .operation-ring-value { stroke: var(--success, #64c878); }
|
||
.browser-operation.failed .operation-ring-value { stroke: var(--danger, #e45b69); }
|
||
.operation-title { font-size: .88rem; }
|
||
.operation-detail { color: var(--muted); font-size: .75rem; }
|
||
|
||
@keyframes browser-operation-spin { to { transform: rotate(270deg); } }
|
||
|
||
.context-menu button {
|
||
display: block;
|
||
width: 100%;
|
||
text-align: left;
|
||
border: none;
|
||
border-bottom: 1px solid var(--border-soft);
|
||
background: transparent;
|
||
color: var(--fg);
|
||
padding: 0.5rem 0.75rem;
|
||
}
|
||
|
||
.context-menu button:hover {
|
||
background: var(--row-hover);
|
||
}
|
||
|
||
.context-adapters {
|
||
margin: .25rem 0;
|
||
padding: .3rem 0;
|
||
border-top: 1px solid var(--border-soft);
|
||
border-bottom: 1px solid var(--border-soft);
|
||
}
|
||
|
||
.context-adapters > span {
|
||
display: block;
|
||
padding: .2rem .7rem;
|
||
color: var(--muted);
|
||
font-size: .78rem;
|
||
}
|
||
|
||
.context-adapters a {
|
||
display: block;
|
||
padding: .5rem .7rem;
|
||
color: var(--fg);
|
||
text-decoration: none;
|
||
}
|
||
|
||
.preview-frame {
|
||
width: 100%;
|
||
height: 70vh;
|
||
border: 1px solid var(--border-soft);
|
||
background: var(--bg);
|
||
}
|
||
|
||
|
||
.resize-handle {
|
||
background: var(--border-soft);
|
||
cursor: col-resize;
|
||
min-width: 6px;
|
||
}
|
||
|
||
.resize-handle:hover,
|
||
.resize-handle.dragging {
|
||
background: var(--accent);
|
||
}
|
||
|
||
.browser-layout.no-sidebar #sidebar-resizer,
|
||
.browser-layout.no-preview #preview-resizer {
|
||
display: none;
|
||
}
|
||
|
||
</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 id="browser-layout" class="browser-layout">
|
||
|
||
<aside id="browser-sidebar" class="browser-sidebar" ondragover="navigatorDragOver(event)" ondragleave="navigatorDragLeave(event)" ondrop="navigatorDrop(event)">
|
||
<button
|
||
type="button"
|
||
class="pane-close"
|
||
title="Hide sidebar"
|
||
onclick="toggleSidebar()"
|
||
>
|
||
‹
|
||
</button>
|
||
|
||
<h3>Navigator</h3>
|
||
<a class="sidebar-link" href="/v/browser/">Root</a>
|
||
<a class="sidebar-link" href="/v/tree">Tree View</a>
|
||
<a class="sidebar-link" href="/-/sys/config">Config</a>
|
||
<div id="navigator-links" class="navigator-links" data-editable="{{ .CanEditNavigator }}">
|
||
{{ range .NavigatorLinks }}
|
||
<a class="sidebar-link navigator-link" {{ if .IsDir }}href="/v/browser{{ .Path }}"{{ else }}href="{{ .Path }}"{{ end }} data-navigation-id="{{ .UUID }}" data-navigation-path="{{ .Path }}" data-is-dir="{{ .IsDir }}" oncontextmenu="openNavigatorMenu(event, this)">{{ .Label }}</a>
|
||
{{ end }}
|
||
</div>
|
||
{{ if .CanEditNavigator }}<p class="navigator-hint">Drag files or folders here to add shortcuts. Right-click a shortcut to rename or remove it.</p>{{ end }}
|
||
</aside>
|
||
|
||
<div
|
||
id="sidebar-resizer"
|
||
class="resize-handle"
|
||
onmousedown="startResize(event, 'sidebar')"
|
||
></div>
|
||
|
||
<section class="browser-main">
|
||
|
||
<div class="browser-toolbar">
|
||
|
||
<a
|
||
href="/v/upload?path={{ .Path }}{{ if ne .Path "/" }}/{{ end }}"
|
||
class="icon-button"
|
||
title="{{ T "upload.title" }}"
|
||
aria-label="{{ T "upload.title" }}"
|
||
>↑</a>
|
||
|
||
<button
|
||
type="button"
|
||
class="icon-button"
|
||
title="Toggle sidebar"
|
||
onclick="toggleSidebar()"
|
||
>
|
||
☰
|
||
</button>
|
||
|
||
<div class="segmented" role="group" aria-label="View mode">
|
||
|
||
<button
|
||
id="view-icons"
|
||
type="button"
|
||
title="Icon view"
|
||
onclick="setViewMode('icons')"
|
||
>
|
||
▦
|
||
</button>
|
||
|
||
<button
|
||
id="view-details"
|
||
type="button"
|
||
title="Detail view"
|
||
onclick="setViewMode('details')"
|
||
>
|
||
☷
|
||
</button>
|
||
|
||
</div>
|
||
|
||
<span id="browser-selection-status" class="browser-selection-status" aria-live="polite"></span>
|
||
|
||
<button
|
||
id="preview-toggle"
|
||
type="button"
|
||
class="icon-button"
|
||
title="Toggle preview"
|
||
onclick="togglePreview()"
|
||
>
|
||
◧
|
||
</button>
|
||
|
||
</div>
|
||
|
||
<div class="browser-path">
|
||
{{ .Path }}
|
||
</div>
|
||
|
||
<div id="browser-grid" class="browser-grid">
|
||
|
||
{{ range .Entries }}
|
||
|
||
<div
|
||
class="browser-row"
|
||
draggable="true"
|
||
data-path="{{ .Path }}"
|
||
data-name="{{ .Name }}"
|
||
data-is-dir="{{ .IsDir }}"
|
||
data-object-uuid="{{ .ObjectUUID }}"
|
||
aria-selected="false"
|
||
oncontextmenu="openContextMenu(event, this)"
|
||
onclick="selectEntry(this, event)"
|
||
ondblclick="openEntry(this)"
|
||
ondragstart="dragStart(event, this)"
|
||
ondragover="dragOver(event, this)"
|
||
ondrop="dropEntry(event, this)"
|
||
>
|
||
|
||
<div class="browser-cell browser-icon {{ if .IsDir }}dir{{ end }}">
|
||
{{ if .IsDir }}{{ else if .ThumbnailURL }}<span class="browser-thumbnail children-preview children-preview-pending"><img data-preview-kind="image" data-preview-src="{{ .ThumbnailURL }}" alt=""></span>{{ else }}{{ end }}
|
||
</div>
|
||
|
||
<div class="browser-cell browser-name">
|
||
{{ .Name }}
|
||
</div>
|
||
|
||
<div class="browser-cell browser-meta">
|
||
{{ if .IsDir }}
|
||
{{ .ChildCount }} items
|
||
{{ else }}
|
||
{{ formatBytes .Size }}
|
||
{{ end }}
|
||
</div>
|
||
|
||
<div class="browser-cell browser-meta">
|
||
{{ if not .IsDir }}
|
||
{{ formatUnix .UpdatedAt }}
|
||
{{ end }}
|
||
</div>
|
||
|
||
</div>
|
||
|
||
{{ end }}
|
||
|
||
</div>
|
||
|
||
</section>
|
||
|
||
<div
|
||
id="preview-resizer"
|
||
class="resize-handle"
|
||
onmousedown="startResize(event, 'preview')"
|
||
></div>
|
||
|
||
<aside id="browser-preview" class="browser-preview">
|
||
<button
|
||
type="button"
|
||
class="pane-close"
|
||
title="Hide preview"
|
||
onclick="togglePreview()"
|
||
>
|
||
›
|
||
</button>
|
||
|
||
<iframe
|
||
id="preview-frame"
|
||
class="preview-frame"
|
||
src="about:blank"
|
||
></iframe>
|
||
</aside>
|
||
|
||
</main>
|
||
|
||
<div id="context-menu" class="context-menu">
|
||
<button type="button" onclick="ctxOpen()">{{ T "children.open" }}</button>
|
||
<button type="button" onclick="ctxEdit()">{{ T "children.edit" }}</button>
|
||
<button type="button" onclick="ctxRename()">{{ T "children.rename" }}</button>
|
||
<button type="button" onclick="ctxCopy()">{{ T "children.copy" }}</button>
|
||
<button type="button" onclick="ctxPaste()">{{ T "children.paste" }}</button>
|
||
<button type="button" onclick="ctxCopyPath()">{{ T "children.copy_path" }}</button>
|
||
<button type="button" onclick="ctxLink()">{{ T "children.path_links" }}</button>
|
||
<button type="button" onclick="ctxMeta()">{{ T "children.metadata" }}</button>
|
||
<div class="context-adapters" id="context-adapters" hidden>
|
||
<span>{{ T "children.open_with" }}</span>
|
||
<div id="context-adapter-actions"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="navigator-menu" class="context-menu">
|
||
<button type="button" onclick="renameNavigatorLink()">Rename label</button>
|
||
<button type="button" onclick="deleteNavigatorLink()">Remove</button>
|
||
</div>
|
||
|
||
<div id="selection-marquee" class="selection-marquee" aria-hidden="true"></div>
|
||
<div id="browser-operation-stack" class="browser-operation-stack" aria-live="polite"></div>
|
||
|
||
<script>
|
||
let selectedEntry = null
|
||
let draggedPath = ""
|
||
|
||
function setViewMode(mode) {
|
||
const grid =
|
||
document.getElementById("browser-grid")
|
||
|
||
if (mode === "details") {
|
||
grid.classList.add("details")
|
||
} else {
|
||
grid.classList.remove("details")
|
||
}
|
||
|
||
const icons =
|
||
document.getElementById("view-icons")
|
||
|
||
const details =
|
||
document.getElementById("view-details")
|
||
|
||
if (icons && details) {
|
||
icons.classList.toggle("active", mode === "icons")
|
||
details.classList.toggle("active", mode === "details")
|
||
}
|
||
|
||
localStorage.setItem("browser.viewMode", mode)
|
||
}
|
||
|
||
function restoreViewMode() {
|
||
setViewMode(
|
||
localStorage.getItem("browser.viewMode") || "icons"
|
||
)
|
||
}
|
||
|
||
function toggleSidebar() {
|
||
const layout =
|
||
document.getElementById("browser-layout")
|
||
|
||
layout.classList.toggle("no-sidebar")
|
||
|
||
localStorage.setItem(
|
||
"browser.sidebar",
|
||
layout.classList.contains("no-sidebar") ? "hide" : "show"
|
||
)
|
||
}
|
||
|
||
function togglePreview() {
|
||
const layout =
|
||
document.getElementById("browser-layout")
|
||
|
||
layout.classList.toggle("no-preview")
|
||
|
||
localStorage.setItem(
|
||
"browser.preview",
|
||
layout.classList.contains("no-preview") ? "hide" : "show"
|
||
)
|
||
|
||
updatePaneButtons()
|
||
}
|
||
|
||
function updatePaneButtons() {
|
||
const layout =
|
||
document.getElementById("browser-layout")
|
||
|
||
const previewBtn =
|
||
document.getElementById("preview-toggle")
|
||
|
||
if (previewBtn) {
|
||
const hidden =
|
||
layout.classList.contains("no-preview")
|
||
|
||
previewBtn.textContent =
|
||
hidden ? "◨" : "◧"
|
||
|
||
previewBtn.title =
|
||
hidden ? "Show preview" : "Hide preview"
|
||
|
||
previewBtn.classList.toggle(
|
||
"active",
|
||
!hidden
|
||
)
|
||
}
|
||
}
|
||
|
||
function restorePanes() {
|
||
const layout =
|
||
document.getElementById("browser-layout")
|
||
|
||
const sidebarWidth =
|
||
localStorage.getItem("browser.sidebarWidth")
|
||
|
||
const previewWidth =
|
||
localStorage.getItem("browser.previewWidth")
|
||
|
||
if (sidebarWidth) {
|
||
layout.style.setProperty(
|
||
"--browser-sidebar-width",
|
||
sidebarWidth
|
||
)
|
||
}
|
||
|
||
if (previewWidth) {
|
||
layout.style.setProperty(
|
||
"--browser-preview-width",
|
||
previewWidth
|
||
)
|
||
}
|
||
|
||
if (localStorage.getItem("browser.sidebar") === "hide") {
|
||
layout.classList.add("no-sidebar")
|
||
}
|
||
|
||
if (localStorage.getItem("browser.preview") === "hide") {
|
||
layout.classList.add("no-preview")
|
||
}
|
||
|
||
updatePaneButtons()
|
||
}
|
||
|
||
function startResize(ev, pane) {
|
||
ev.preventDefault()
|
||
|
||
const layout =
|
||
document.getElementById("browser-layout")
|
||
|
||
const startX =
|
||
ev.clientX
|
||
|
||
const rect =
|
||
layout.getBoundingClientRect()
|
||
|
||
const sidebarStart =
|
||
parseFloat(
|
||
getComputedStyle(layout)
|
||
.getPropertyValue("--browser-sidebar-width")
|
||
) || 224
|
||
|
||
const previewStart =
|
||
parseFloat(
|
||
getComputedStyle(layout)
|
||
.getPropertyValue("--browser-preview-width")
|
||
) || 352
|
||
|
||
const handle =
|
||
ev.currentTarget
|
||
|
||
handle.classList.add("dragging")
|
||
|
||
function onMove(e) {
|
||
if (pane === "sidebar") {
|
||
const width =
|
||
Math.max(
|
||
120,
|
||
Math.min(
|
||
520,
|
||
sidebarStart + (e.clientX - startX)
|
||
)
|
||
)
|
||
|
||
layout.style.setProperty(
|
||
"--browser-sidebar-width",
|
||
width + "px"
|
||
)
|
||
}
|
||
|
||
if (pane === "preview") {
|
||
const width =
|
||
Math.max(
|
||
180,
|
||
Math.min(
|
||
rect.width - 260,
|
||
previewStart - (e.clientX - startX)
|
||
)
|
||
)
|
||
|
||
layout.style.setProperty(
|
||
"--browser-preview-width",
|
||
width + "px"
|
||
)
|
||
}
|
||
}
|
||
|
||
function onUp() {
|
||
handle.classList.remove("dragging")
|
||
|
||
localStorage.setItem(
|
||
"browser.sidebarWidth",
|
||
getComputedStyle(layout)
|
||
.getPropertyValue("--browser-sidebar-width")
|
||
.trim()
|
||
)
|
||
|
||
localStorage.setItem(
|
||
"browser.previewWidth",
|
||
getComputedStyle(layout)
|
||
.getPropertyValue("--browser-preview-width")
|
||
.trim()
|
||
)
|
||
|
||
document.removeEventListener("mousemove", onMove)
|
||
document.removeEventListener("mouseup", onUp)
|
||
}
|
||
|
||
document.addEventListener("mousemove", onMove)
|
||
document.addEventListener("mouseup", onUp)
|
||
}
|
||
|
||
function selectEntry(el) {
|
||
for (const row of document.querySelectorAll(".browser-row")) {
|
||
row.classList.remove("selected")
|
||
}
|
||
|
||
el.classList.add("selected")
|
||
selectedEntry = el
|
||
|
||
updatePreview(el)
|
||
}
|
||
|
||
function openEntry(el) {
|
||
const p = el.dataset.path
|
||
|
||
if (el.dataset.isDir === "true") {
|
||
location.href = "/v/browser" + p
|
||
return
|
||
}
|
||
|
||
location.href = p
|
||
}
|
||
|
||
function updatePreview(el) {
|
||
const p = el.dataset.path
|
||
const uuid = el.dataset.objectUuid
|
||
|
||
const frame =
|
||
document.getElementById("preview-frame")
|
||
|
||
frame.src = "/v/preview" + p
|
||
}
|
||
|
||
function openContextMenu(ev, el) {
|
||
ev.preventDefault()
|
||
selectEntry(el)
|
||
|
||
const menu =
|
||
document.getElementById("context-menu")
|
||
|
||
menu.style.left =
|
||
ev.clientX + "px"
|
||
|
||
menu.style.top =
|
||
ev.clientY + "px"
|
||
|
||
menu.style.display =
|
||
"block"
|
||
|
||
loadContextAdapters(el.dataset.path)
|
||
}
|
||
|
||
document.addEventListener(
|
||
"click",
|
||
() => {
|
||
document.getElementById("context-menu").style.display = "none"
|
||
}
|
||
)
|
||
|
||
function ctxOpen() {
|
||
if (selectedEntry) {
|
||
openEntry(selectedEntry)
|
||
}
|
||
}
|
||
|
||
function ctxEdit() {
|
||
if (!selectedEntry) {
|
||
return
|
||
}
|
||
|
||
location.href =
|
||
"/e" + selectedEntry.dataset.path
|
||
}
|
||
|
||
async function ctxRename() {
|
||
if (!selectedEntry) {
|
||
return
|
||
}
|
||
|
||
const oldPath =
|
||
selectedEntry.dataset.path
|
||
|
||
const newPath =
|
||
prompt("Rename path:", oldPath)
|
||
|
||
if (!newPath || newPath === oldPath) {
|
||
return
|
||
}
|
||
|
||
await renamePath(oldPath, newPath)
|
||
location.reload()
|
||
}
|
||
|
||
function ctxCopyPath() {
|
||
if (!selectedEntry) {
|
||
return
|
||
}
|
||
|
||
navigator.clipboard.writeText(
|
||
selectedEntry.dataset.path
|
||
)
|
||
}
|
||
|
||
function ctxCopy() {
|
||
if (!selectedEntry) return
|
||
localStorage.setItem("pageswiki.fileClipboard", JSON.stringify({
|
||
operation: "copy",
|
||
paths: [selectedEntry.dataset.path],
|
||
created_at: Date.now()
|
||
}))
|
||
}
|
||
|
||
async function ctxPaste() {
|
||
let clipboard
|
||
try {
|
||
clipboard = JSON.parse(localStorage.getItem("pageswiki.fileClipboard") || "null")
|
||
} catch (_) {
|
||
clipboard = null
|
||
}
|
||
if (!clipboard?.paths?.length) return
|
||
const directory = document.querySelector(".browser-path").textContent.trim() || "/"
|
||
for (const sourcePath of clipboard.paths) {
|
||
const basename = sourcePath.replace(/\/+$/, "").split("/").pop()
|
||
const sourceDirectory = sourcePath.slice(0, sourcePath.lastIndexOf("/")) || "/"
|
||
const dot = basename.lastIndexOf(".")
|
||
const name = sourceDirectory === directory
|
||
? (dot > 0
|
||
? basename.slice(0, dot) + " (copy)" + basename.slice(dot)
|
||
: basename + " (copy)")
|
||
: basename
|
||
const destination = (directory === "/" ? "" : directory) + "/" + name
|
||
const response = await fetch("/_/api/v1/path/copy", {
|
||
method: "POST",
|
||
headers: {"Content-Type": "application/json"},
|
||
body: JSON.stringify({
|
||
source_path: sourcePath,
|
||
destination_path: destination,
|
||
recursive: true
|
||
})
|
||
})
|
||
if (!response.ok) {
|
||
alert((await response.text()).trim())
|
||
return
|
||
}
|
||
}
|
||
location.reload()
|
||
}
|
||
|
||
function ctxLink() {
|
||
if (!selectedEntry) {
|
||
return
|
||
}
|
||
|
||
const uuid =
|
||
selectedEntry.dataset.objectUuid
|
||
|
||
if (!uuid) {
|
||
alert("directory has no object uuid")
|
||
return
|
||
}
|
||
|
||
location.href =
|
||
"/l/uuid:" + uuid
|
||
}
|
||
|
||
function ctxMeta() {
|
||
if (!selectedEntry) {
|
||
return
|
||
}
|
||
|
||
alert(
|
||
"Path: " + selectedEntry.dataset.path +
|
||
"\\nObject UUID: " + selectedEntry.dataset.objectUuid +
|
||
"\\nDirectory: " + selectedEntry.dataset.isDir
|
||
)
|
||
}
|
||
|
||
async function loadContextAdapters(path) {
|
||
const group = document.getElementById("context-adapters")
|
||
const target = document.getElementById("context-adapter-actions")
|
||
group.hidden = true
|
||
target.replaceChildren()
|
||
try {
|
||
const response = await fetch(
|
||
"/_/api/v1/adapter?path=" + encodeURIComponent(path),
|
||
{cache: "no-store"}
|
||
)
|
||
if (!response.ok) return
|
||
const data = await response.json()
|
||
for (const action of data.actions || []) {
|
||
const link = document.createElement("a")
|
||
link.href = action.open_url
|
||
link.textContent = action.name
|
||
if (action.new_tab) {
|
||
link.target = "_blank"
|
||
link.rel = "noopener"
|
||
}
|
||
if (action.mode === "native") link.rel = "external"
|
||
target.append(link)
|
||
}
|
||
group.hidden = !target.children.length
|
||
} catch (_) {
|
||
group.hidden = true
|
||
}
|
||
}
|
||
|
||
function dragStart(ev, el) {
|
||
draggedPath =
|
||
el.dataset.path
|
||
|
||
ev.dataTransfer.setData(
|
||
"text/plain",
|
||
draggedPath
|
||
)
|
||
}
|
||
|
||
function dragOver(ev, el) {
|
||
if (el.dataset.isDir === "true") {
|
||
ev.preventDefault()
|
||
}
|
||
}
|
||
|
||
async function dropEntry(ev, el) {
|
||
ev.preventDefault()
|
||
|
||
if (el.dataset.isDir !== "true") {
|
||
return
|
||
}
|
||
|
||
const targetDir =
|
||
el.dataset.path
|
||
|
||
const oldPath =
|
||
ev.dataTransfer.getData("text/plain") || draggedPath
|
||
|
||
if (!oldPath || oldPath === targetDir) {
|
||
return
|
||
}
|
||
|
||
const base =
|
||
oldPath.split("/").filter(Boolean).pop()
|
||
|
||
const newPath =
|
||
targetDir.replace(/\/$/, "") + "/" + base
|
||
|
||
if (!confirm(oldPath + "\\n↓\\n" + newPath)) {
|
||
return
|
||
}
|
||
|
||
await renamePath(oldPath, newPath)
|
||
location.reload()
|
||
}
|
||
|
||
async function renamePath(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) {
|
||
alert("rename failed")
|
||
throw new Error("rename failed")
|
||
}
|
||
}
|
||
|
||
restoreViewMode()
|
||
restorePanes()
|
||
</script>
|
||
<script src="/static/js/browser-interactions.js?v=1"></script>
|
||
|
||
</body>
|
||
</html>
|
||
{{ end }}
|