feat(server): add box file listing and download routes

Introduce `/box/:id` to render a box page with file metadata, plus
endpoints to download individual files and a “download all” ZIP. Add
helpers to safely list box contents, stream files into a ZIP response,
and infer MIME types/icons for better UI and correct downloads.feat(server): add box file listing and download routes

Introduce `/box/:id` to render a box page with file metadata, plus
endpoints to download individual files and a “download all” ZIP. Add
helpers to safely list box contents, stream files into a ZIP response,
and infer MIME types/icons for better UI and correct downloads.
This commit is contained in:
2026-04-27 17:20:57 +03:00
parent b5f39d714a
commit 6a0b3dbe2f
6 changed files with 526 additions and 1 deletions

66
templates/box.html Normal file
View File

@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WarpBox - {{ .BoxID }}</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/static/css/app.css">
<link rel="stylesheet" href="/static/css/window.css">
<link rel="stylesheet" href="/static/css/box.css">
</head>
<body>
<main>
<section class="win98-window box-window" aria-labelledby="box-window-title">
<header class="win98-titlebar box-titlebar">
<h1 id="box-window-title">WarpBox Explorer - {{ .BoxID }}</h1>
<div class="win98-window-controls" aria-hidden="true">
<span class="win98-control">_</span>
<span class="win98-control"></span>
<span class="win98-control">×</span>
</div>
</header>
<div class="win98-menu box-menu" aria-hidden="true">
<span class="win98-menu-option">File</span>
<span class="win98-menu-option">Edit</span>
<span class="win98-menu-option">View</span>
<span class="win98-menu-option">Tools</span>
<span class="win98-menu-option">Help</span>
</div>
<div class="box-toolbar">
<a class="win98-button box-toolbar-button" href="/">Upload</a>
<a class="win98-button box-toolbar-button" href="{{ .DownloadAll }}">Download Zip</a>
</div>
<div class="box-address">
<span>Address</span>
<code>/box/{{ .BoxID }}</code>
</div>
<div class="win98-panel box-panel">
{{ if .Files }}
<div class="box-file-grid" aria-label="Uploaded files">
{{ range .Files }}
<a class="box-file" href="{{ .DownloadPath }}" download>
<img class="box-file-icon" src="{{ .IconPath }}" alt="" aria-hidden="true">
<span class="box-file-name">{{ .Name }}</span>
<span class="box-file-meta">{{ .SizeLabel }} · {{ .MimeType }}</span>
</a>
{{ end }}
</div>
{{ else }}
<p class="box-empty">This box is empty.</p>
{{ end }}
</div>
<div class="win98-statusbar box-statusbar" aria-live="polite">
<span>{{ .FileCount }} item(s)</span>
<span>WarpBox</span>
</div>
</section>
</main>
</body>
</html>

View File

@@ -47,6 +47,12 @@
<div class="upload-file-list" aria-live="polite" aria-label="Selected files">
<p class="upload-empty-state">No files selected</p>
</div>
<div class="upload-result" aria-live="polite">
<span class="upload-result-label">Folder link</span>
<a id="upload-box-link" class="upload-result-link is-empty" href="#" aria-disabled="true">Waiting for upload</a>
<button id="upload-share-button" class="win98-button upload-share-button" type="button" disabled>Share</button>
</div>
</div>
<footer class="upload-actions">