Add site-wide media grid with combined filters and shared path bar
DC CMS qualification / qualify (push) Successful in 1m46s

This commit is contained in:
DCCONSTRUCTIONS
2026-11-13 18:11:18 +03:00
parent 5d56f5fe21
commit 9f4b74a6d3
15 changed files with 254 additions and 174 deletions
+11 -34
View File
@@ -1,5 +1,5 @@
import { createReadStream, statSync } from "node:fs";
import { appendFile, copyFile, cp, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
import { appendFile, copyFile, cp, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { extname, join, normalize, relative, resolve } from "node:path";
import { fileURLToPath } from "node:url";
@@ -64,36 +64,7 @@ const trashStores = [
displayPrefix: "assets/uploads/.trash",
},
];
const mediaRoots = [
{
id: "uploads",
label: "Uploads",
rootPath: uploadRoot,
urlPrefix: "./assets/uploads",
writable: true,
},
{
id: "media",
label: "Legacy media",
rootPath: join(repoRoot, "assets", "media"),
urlPrefix: "./assets/media",
writable: true,
},
{
id: "site-images",
label: "Site images",
rootPath: join(repoRoot, "assets", "site", "images"),
urlPrefix: "./assets/site/images",
writable: true,
},
{
id: "custom-assets",
label: "Custom assets",
rootPath: join(repoRoot, "assets", "custom"),
urlPrefix: "./assets/custom",
writable: true,
},
];
const mediaRoots = [{ id: "assets", label: "Файлы сайта", rootPath: join(repoRoot, "assets"), urlPrefix: "./assets", writable: true }];
const MEDIA_EXTENSIONS = new Set([
".avif",
".gif",
@@ -1364,16 +1335,19 @@ async function scanMediaRoot(root) {
let entries = [];
try {
const directoryStat = await lstat(directory);
if (!directoryStat.isDirectory() || directoryStat.isSymbolicLink()) return;
entries = await readdir(directory, { withFileTypes: true });
} catch {
return;
} catch (error) {
if (error.code === "ENOENT") return;
throw error;
}
for (const entry of entries) {
const filePath = join(directory, entry.name);
const relativePath = relative(root.rootPath, filePath).replace(/\\/g, "/");
if (!relativePath || relativePath.split("/").includes(".trash")) continue;
if (!relativePath || relativePath.split("/").some(part => part.startsWith(".") || BROWSER_EXCLUDED_DIRS.has(part))) continue;
if (entry.isDirectory()) {
await walk(filePath);
@@ -1391,6 +1365,9 @@ async function scanMediaRoot(root) {
files.push({
id: `${root.id}:${relativePath}`,
type: "file",
path: relative(repoRoot, filePath).replace(/\\/g, "/"),
selectable: true,
rootId: root.id,
rootLabel: root.label,
writable: root.writable,