Add obscure.lst manifest filter for folder selection
This commit is contained in:
+1
-1
@@ -22,7 +22,7 @@ if _sys_path_root not in sys.path:
|
||||
sys.path.insert(0, _sys_path_root)
|
||||
|
||||
# Версия приложения (меняется при изменениях)
|
||||
VERSION = "1.0.5"
|
||||
VERSION = "1.1.0"
|
||||
|
||||
|
||||
def setup_logging():
|
||||
|
||||
Vendored
+215
-3
@@ -727,6 +727,209 @@ function onFilesChange(state, cfg, elements) {
|
||||
};
|
||||
}
|
||||
|
||||
// upload/frontend/table/lst_filter.js
|
||||
var MANIFEST_NAME = "obscure.lst";
|
||||
function extensionAllowed2(name, allowedExt) {
|
||||
const lowerName = String(name || "").toLowerCase();
|
||||
return allowedExt.some((extension) => lowerName.endsWith(String(extension).toLowerCase()));
|
||||
}
|
||||
function relativePathOf(file) {
|
||||
const raw = String(file.webkitRelativePath || file.name || "").replace(/\\/g, "/");
|
||||
const parts = raw.split("/");
|
||||
return parts.length > 1 ? parts.slice(1).join("/") : parts[0] || "";
|
||||
}
|
||||
function findManifest(files) {
|
||||
return files.find((file) => {
|
||||
const raw = String(file.webkitRelativePath || file.name || "").replace(/\\/g, "/");
|
||||
const parts = raw.split("/");
|
||||
return parts.length === 2 && parts[1].toLowerCase() === MANIFEST_NAME;
|
||||
}) || null;
|
||||
}
|
||||
function escapeRegExp(text) {
|
||||
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
function findClosingBracket(glob, openIndex) {
|
||||
let index = openIndex + 1;
|
||||
if (glob[index] === "!" || glob[index] === "^") index += 1;
|
||||
if (glob[index] === "]") index += 1;
|
||||
for (; index < glob.length; index += 1) {
|
||||
if (glob[index] === "]") return index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function compileGlob(glob) {
|
||||
let pattern = "^";
|
||||
let index = 0;
|
||||
while (index < glob.length) {
|
||||
const character = glob[index];
|
||||
if (character === "*") {
|
||||
const isDouble = glob[index + 1] === "*";
|
||||
if (!isDouble) {
|
||||
pattern += "[^/]*";
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
const atSegmentStart = index === 0 || glob[index - 1] === "/";
|
||||
const atSegmentEnd = index + 2 === glob.length || glob[index + 2] === "/";
|
||||
if (atSegmentStart && atSegmentEnd) {
|
||||
if (glob[index + 2] === "/") {
|
||||
pattern += "(?:[^/]+/)*";
|
||||
index += 3;
|
||||
} else {
|
||||
pattern += ".*";
|
||||
index += 2;
|
||||
}
|
||||
} else {
|
||||
pattern += "[^/]*";
|
||||
index += 2;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (character === "?") {
|
||||
pattern += "[^/]";
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
if (character === "[") {
|
||||
const close = findClosingBracket(glob, index);
|
||||
if (close === -1) return null;
|
||||
let body = glob.slice(index + 1, close);
|
||||
if (body.startsWith("!")) body = `^${body.slice(1)}`;
|
||||
pattern += `[${body.replace(/[\\\]]/g, (symbol) => `\\${symbol}`)}]`;
|
||||
index = close + 1;
|
||||
continue;
|
||||
}
|
||||
pattern += escapeRegExp(character);
|
||||
index += 1;
|
||||
}
|
||||
pattern += "$";
|
||||
try {
|
||||
return new RegExp(pattern, "i");
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function normalizeRule(line) {
|
||||
let text = line.trim();
|
||||
if (!text || text.startsWith("#")) return null;
|
||||
let negative = false;
|
||||
if (text.startsWith("!")) {
|
||||
negative = true;
|
||||
text = text.slice(1).trim();
|
||||
if (!text) return { error: '\u043F\u0443\u0441\u0442\u043E\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u043E \u043F\u043E\u0441\u043B\u0435 "!"' };
|
||||
}
|
||||
text = text.replace(/\\/g, "/");
|
||||
text = text.replace(/\/{2,}/g, "/");
|
||||
text = text.replace(/^(?:\.\/)+/, "");
|
||||
if (text.startsWith("/") || /^[a-zA-Z]:\//.test(text)) {
|
||||
return { error: "\u0430\u0431\u0441\u043E\u043B\u044E\u0442\u043D\u044B\u0439 \u043F\u0443\u0442\u044C \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442\u0441\u044F" };
|
||||
}
|
||||
if (text.split("/").some((segment) => segment === "..")) {
|
||||
return { error: '\u0441\u0435\u0433\u043C\u0435\u043D\u0442 ".." \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442\u0441\u044F' };
|
||||
}
|
||||
if (!text) return { error: "\u043F\u0443\u0441\u0442\u043E\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u043E" };
|
||||
if (text.endsWith("/")) text += "**";
|
||||
return { path: text, negative };
|
||||
}
|
||||
function parseRules(text, diagnostics) {
|
||||
const lines = text.split(/\r\n|\r|\n/);
|
||||
const rules = [];
|
||||
lines.forEach((line, index) => {
|
||||
const lineNumber = index + 1;
|
||||
const normalized = normalizeRule(line);
|
||||
if (normalized === null) return;
|
||||
if (normalized.error) {
|
||||
diagnostics.push({
|
||||
level: "error",
|
||||
line: lineNumber,
|
||||
message: `${normalized.error}: "${line.trim()}"`
|
||||
});
|
||||
return;
|
||||
}
|
||||
const regex = compileGlob(normalized.path);
|
||||
if (!regex) {
|
||||
diagnostics.push({
|
||||
level: "error",
|
||||
line: lineNumber,
|
||||
message: `\u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 glob: "${line.trim()}"`
|
||||
});
|
||||
return;
|
||||
}
|
||||
rules.push({
|
||||
line: lineNumber,
|
||||
source: line.trim(),
|
||||
negative: normalized.negative,
|
||||
regex
|
||||
});
|
||||
});
|
||||
return rules;
|
||||
}
|
||||
async function lstFilter(files, allowedExt) {
|
||||
const list = Array.from(files || []);
|
||||
const manifest = findManifest(list);
|
||||
if (!manifest) {
|
||||
return { manifest: null, files: list, diagnostics: [] };
|
||||
}
|
||||
const diagnostics = [];
|
||||
let text;
|
||||
try {
|
||||
const buffer = await manifest.arrayBuffer();
|
||||
text = new TextDecoder("utf-8", { fatal: true }).decode(buffer);
|
||||
} catch (error) {
|
||||
diagnostics.push({
|
||||
level: "error",
|
||||
line: 0,
|
||||
message: `\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C ${MANIFEST_NAME}: ${error.message}`
|
||||
});
|
||||
return { manifest, files: [], diagnostics };
|
||||
}
|
||||
if (text.charCodeAt(0) === 65279) text = text.slice(1);
|
||||
const rules = parseRules(text, diagnostics);
|
||||
const positives = rules.filter((rule) => !rule.negative);
|
||||
const negatives = rules.filter((rule) => rule.negative);
|
||||
if (positives.length === 0) {
|
||||
diagnostics.push({
|
||||
level: "warning",
|
||||
line: 0,
|
||||
message: `\u0432 ${MANIFEST_NAME} \u043D\u0435\u0442 \u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0445 \u0432\u043A\u043B\u044E\u0447\u0430\u044E\u0449\u0438\u0445 \u043F\u0440\u0430\u0432\u0438\u043B`
|
||||
});
|
||||
return { manifest, files: [], diagnostics };
|
||||
}
|
||||
const candidates = list.filter((file) => file !== manifest && extensionAllowed2(file.name, allowedExt));
|
||||
const matched = /* @__PURE__ */ new Set();
|
||||
const selected = [];
|
||||
for (const file of candidates) {
|
||||
const path = relativePathOf(file);
|
||||
let included = false;
|
||||
for (const rule of positives) {
|
||||
if (rule.regex.test(path)) {
|
||||
matched.add(rule);
|
||||
included = true;
|
||||
}
|
||||
}
|
||||
if (!included) continue;
|
||||
const excluded = negatives.some((rule) => rule.regex.test(path));
|
||||
if (!excluded) selected.push(file);
|
||||
}
|
||||
for (const rule of positives) {
|
||||
if (!matched.has(rule)) {
|
||||
diagnostics.push({
|
||||
level: "warning",
|
||||
line: rule.line,
|
||||
message: `\u043F\u0440\u0430\u0432\u0438\u043B\u043E \u043D\u0435 \u0441\u043E\u0432\u043F\u0430\u043B\u043E \u043D\u0438 \u0441 \u043E\u0434\u043D\u0438\u043C \u0444\u0430\u0439\u043B\u043E\u043C: "${rule.source}"`
|
||||
});
|
||||
}
|
||||
}
|
||||
if (selected.length === 0) {
|
||||
diagnostics.push({
|
||||
level: "warning",
|
||||
line: 0,
|
||||
message: "manifest \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043B \u043D\u0438 \u043E\u0434\u043D\u043E\u0433\u043E \u0444\u0430\u0439\u043B\u0430"
|
||||
});
|
||||
}
|
||||
return { manifest, files: selected, diagnostics };
|
||||
}
|
||||
|
||||
// upload/frontend/table/on_folder_change.js
|
||||
function onFolderChange(state, cfg, elements) {
|
||||
return async () => {
|
||||
@@ -735,7 +938,14 @@ function onFolderChange(state, cfg, elements) {
|
||||
if (elements.statusEl) elements.statusEl.textContent = "";
|
||||
try {
|
||||
const roots = /* @__PURE__ */ new Map();
|
||||
for (const file of Array.from(elements.folderInputEl.files)) {
|
||||
const filtered = await lstFilter(elements.folderInputEl.files, [...cfg.allowedExt, ".zip"]);
|
||||
if (filtered.manifest) {
|
||||
const messages = filtered.diagnostics.map((item) => item.line ? `\u0441\u0442\u0440\u043E\u043A\u0430 ${item.line}: ${item.message}` : item.message);
|
||||
if (messages.length && elements.statusEl) {
|
||||
elements.statusEl.textContent = messages.join("; ");
|
||||
}
|
||||
}
|
||||
for (const file of filtered.files) {
|
||||
const parts = (file.webkitRelativePath || file.name).split("/");
|
||||
const relativePath = parts.slice(1).join("/") || file.name;
|
||||
const lowerPath = relativePath.toLowerCase();
|
||||
@@ -1073,11 +1283,13 @@ function buildMarkup(root, cfg) {
|
||||
const control = (name, id, label, className = "") => controls.includes(name) ? `<button id="${id}" type="button" class="${className}">${esc(label)}</button>` : "";
|
||||
const columns = cfg.layout.columns?.length ? cfg.layout.columns : Object.keys(cfg.labels.columns);
|
||||
const headings = columns.map((column) => `<th>${esc(cfg.labels.columns[column] || column)}</th>`).join("");
|
||||
const fileAccept = esc([.../* @__PURE__ */ new Set([...cfg.allowedExt, ".zip"])].join(","));
|
||||
const folderAccept = esc([.../* @__PURE__ */ new Set([...cfg.allowedExt, ".zip", ".lst"])].join(","));
|
||||
root.innerHTML = `
|
||||
<div class="file-picker${cfg.layout.theme ? ` ${esc(cfg.layout.theme)}` : ""}">
|
||||
<div class="fp-toolbar" aria-label="${esc(cfg.labels.pickFiles)}">
|
||||
<input class="fp-file-input" type="file" accept="${esc([...cfg.allowedExt, ".zip"].join(","))}" multiple hidden>
|
||||
<input class="fp-folder-input" type="file" accept="${esc([...cfg.allowedExt, ".zip"].join(","))}" webkitdirectory directory multiple hidden>
|
||||
<input class="fp-file-input" type="file" accept="${fileAccept}" multiple hidden>
|
||||
<input class="fp-folder-input" type="file" accept="${folderAccept}" webkitdirectory directory multiple hidden>
|
||||
${control("files", "fp-files-btn", cfg.labels.pickFiles)}
|
||||
${control("folder", "fp-folder-btn", cfg.labels.pickFolder, "secondary")}
|
||||
${control("clear", "fp-clear-btn", cfg.labels.clear, "quiet")}
|
||||
|
||||
Vendored
+215
-3
@@ -755,6 +755,209 @@ var FilePicker = (() => {
|
||||
};
|
||||
}
|
||||
|
||||
// upload/frontend/table/lst_filter.js
|
||||
var MANIFEST_NAME = "obscure.lst";
|
||||
function extensionAllowed2(name, allowedExt) {
|
||||
const lowerName = String(name || "").toLowerCase();
|
||||
return allowedExt.some((extension) => lowerName.endsWith(String(extension).toLowerCase()));
|
||||
}
|
||||
function relativePathOf(file) {
|
||||
const raw = String(file.webkitRelativePath || file.name || "").replace(/\\/g, "/");
|
||||
const parts = raw.split("/");
|
||||
return parts.length > 1 ? parts.slice(1).join("/") : parts[0] || "";
|
||||
}
|
||||
function findManifest(files) {
|
||||
return files.find((file) => {
|
||||
const raw = String(file.webkitRelativePath || file.name || "").replace(/\\/g, "/");
|
||||
const parts = raw.split("/");
|
||||
return parts.length === 2 && parts[1].toLowerCase() === MANIFEST_NAME;
|
||||
}) || null;
|
||||
}
|
||||
function escapeRegExp(text) {
|
||||
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
function findClosingBracket(glob, openIndex) {
|
||||
let index = openIndex + 1;
|
||||
if (glob[index] === "!" || glob[index] === "^") index += 1;
|
||||
if (glob[index] === "]") index += 1;
|
||||
for (; index < glob.length; index += 1) {
|
||||
if (glob[index] === "]") return index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function compileGlob(glob) {
|
||||
let pattern = "^";
|
||||
let index = 0;
|
||||
while (index < glob.length) {
|
||||
const character = glob[index];
|
||||
if (character === "*") {
|
||||
const isDouble = glob[index + 1] === "*";
|
||||
if (!isDouble) {
|
||||
pattern += "[^/]*";
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
const atSegmentStart = index === 0 || glob[index - 1] === "/";
|
||||
const atSegmentEnd = index + 2 === glob.length || glob[index + 2] === "/";
|
||||
if (atSegmentStart && atSegmentEnd) {
|
||||
if (glob[index + 2] === "/") {
|
||||
pattern += "(?:[^/]+/)*";
|
||||
index += 3;
|
||||
} else {
|
||||
pattern += ".*";
|
||||
index += 2;
|
||||
}
|
||||
} else {
|
||||
pattern += "[^/]*";
|
||||
index += 2;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (character === "?") {
|
||||
pattern += "[^/]";
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
if (character === "[") {
|
||||
const close = findClosingBracket(glob, index);
|
||||
if (close === -1) return null;
|
||||
let body = glob.slice(index + 1, close);
|
||||
if (body.startsWith("!")) body = `^${body.slice(1)}`;
|
||||
pattern += `[${body.replace(/[\\\]]/g, (symbol) => `\\${symbol}`)}]`;
|
||||
index = close + 1;
|
||||
continue;
|
||||
}
|
||||
pattern += escapeRegExp(character);
|
||||
index += 1;
|
||||
}
|
||||
pattern += "$";
|
||||
try {
|
||||
return new RegExp(pattern, "i");
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function normalizeRule(line) {
|
||||
let text = line.trim();
|
||||
if (!text || text.startsWith("#")) return null;
|
||||
let negative = false;
|
||||
if (text.startsWith("!")) {
|
||||
negative = true;
|
||||
text = text.slice(1).trim();
|
||||
if (!text) return { error: '\u043F\u0443\u0441\u0442\u043E\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u043E \u043F\u043E\u0441\u043B\u0435 "!"' };
|
||||
}
|
||||
text = text.replace(/\\/g, "/");
|
||||
text = text.replace(/\/{2,}/g, "/");
|
||||
text = text.replace(/^(?:\.\/)+/, "");
|
||||
if (text.startsWith("/") || /^[a-zA-Z]:\//.test(text)) {
|
||||
return { error: "\u0430\u0431\u0441\u043E\u043B\u044E\u0442\u043D\u044B\u0439 \u043F\u0443\u0442\u044C \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442\u0441\u044F" };
|
||||
}
|
||||
if (text.split("/").some((segment) => segment === "..")) {
|
||||
return { error: '\u0441\u0435\u0433\u043C\u0435\u043D\u0442 ".." \u043D\u0435 \u0434\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442\u0441\u044F' };
|
||||
}
|
||||
if (!text) return { error: "\u043F\u0443\u0441\u0442\u043E\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u043E" };
|
||||
if (text.endsWith("/")) text += "**";
|
||||
return { path: text, negative };
|
||||
}
|
||||
function parseRules(text, diagnostics) {
|
||||
const lines = text.split(/\r\n|\r|\n/);
|
||||
const rules = [];
|
||||
lines.forEach((line, index) => {
|
||||
const lineNumber = index + 1;
|
||||
const normalized = normalizeRule(line);
|
||||
if (normalized === null) return;
|
||||
if (normalized.error) {
|
||||
diagnostics.push({
|
||||
level: "error",
|
||||
line: lineNumber,
|
||||
message: `${normalized.error}: "${line.trim()}"`
|
||||
});
|
||||
return;
|
||||
}
|
||||
const regex = compileGlob(normalized.path);
|
||||
if (!regex) {
|
||||
diagnostics.push({
|
||||
level: "error",
|
||||
line: lineNumber,
|
||||
message: `\u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 glob: "${line.trim()}"`
|
||||
});
|
||||
return;
|
||||
}
|
||||
rules.push({
|
||||
line: lineNumber,
|
||||
source: line.trim(),
|
||||
negative: normalized.negative,
|
||||
regex
|
||||
});
|
||||
});
|
||||
return rules;
|
||||
}
|
||||
async function lstFilter(files, allowedExt) {
|
||||
const list = Array.from(files || []);
|
||||
const manifest = findManifest(list);
|
||||
if (!manifest) {
|
||||
return { manifest: null, files: list, diagnostics: [] };
|
||||
}
|
||||
const diagnostics = [];
|
||||
let text;
|
||||
try {
|
||||
const buffer = await manifest.arrayBuffer();
|
||||
text = new TextDecoder("utf-8", { fatal: true }).decode(buffer);
|
||||
} catch (error) {
|
||||
diagnostics.push({
|
||||
level: "error",
|
||||
line: 0,
|
||||
message: `\u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C ${MANIFEST_NAME}: ${error.message}`
|
||||
});
|
||||
return { manifest, files: [], diagnostics };
|
||||
}
|
||||
if (text.charCodeAt(0) === 65279) text = text.slice(1);
|
||||
const rules = parseRules(text, diagnostics);
|
||||
const positives = rules.filter((rule) => !rule.negative);
|
||||
const negatives = rules.filter((rule) => rule.negative);
|
||||
if (positives.length === 0) {
|
||||
diagnostics.push({
|
||||
level: "warning",
|
||||
line: 0,
|
||||
message: `\u0432 ${MANIFEST_NAME} \u043D\u0435\u0442 \u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0445 \u0432\u043A\u043B\u044E\u0447\u0430\u044E\u0449\u0438\u0445 \u043F\u0440\u0430\u0432\u0438\u043B`
|
||||
});
|
||||
return { manifest, files: [], diagnostics };
|
||||
}
|
||||
const candidates = list.filter((file) => file !== manifest && extensionAllowed2(file.name, allowedExt));
|
||||
const matched = /* @__PURE__ */ new Set();
|
||||
const selected = [];
|
||||
for (const file of candidates) {
|
||||
const path = relativePathOf(file);
|
||||
let included = false;
|
||||
for (const rule of positives) {
|
||||
if (rule.regex.test(path)) {
|
||||
matched.add(rule);
|
||||
included = true;
|
||||
}
|
||||
}
|
||||
if (!included) continue;
|
||||
const excluded = negatives.some((rule) => rule.regex.test(path));
|
||||
if (!excluded) selected.push(file);
|
||||
}
|
||||
for (const rule of positives) {
|
||||
if (!matched.has(rule)) {
|
||||
diagnostics.push({
|
||||
level: "warning",
|
||||
line: rule.line,
|
||||
message: `\u043F\u0440\u0430\u0432\u0438\u043B\u043E \u043D\u0435 \u0441\u043E\u0432\u043F\u0430\u043B\u043E \u043D\u0438 \u0441 \u043E\u0434\u043D\u0438\u043C \u0444\u0430\u0439\u043B\u043E\u043C: "${rule.source}"`
|
||||
});
|
||||
}
|
||||
}
|
||||
if (selected.length === 0) {
|
||||
diagnostics.push({
|
||||
level: "warning",
|
||||
line: 0,
|
||||
message: "manifest \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043B \u043D\u0438 \u043E\u0434\u043D\u043E\u0433\u043E \u0444\u0430\u0439\u043B\u0430"
|
||||
});
|
||||
}
|
||||
return { manifest, files: selected, diagnostics };
|
||||
}
|
||||
|
||||
// upload/frontend/table/on_folder_change.js
|
||||
function onFolderChange(state, cfg, elements) {
|
||||
return async () => {
|
||||
@@ -763,7 +966,14 @@ var FilePicker = (() => {
|
||||
if (elements.statusEl) elements.statusEl.textContent = "";
|
||||
try {
|
||||
const roots = /* @__PURE__ */ new Map();
|
||||
for (const file of Array.from(elements.folderInputEl.files)) {
|
||||
const filtered = await lstFilter(elements.folderInputEl.files, [...cfg.allowedExt, ".zip"]);
|
||||
if (filtered.manifest) {
|
||||
const messages = filtered.diagnostics.map((item) => item.line ? `\u0441\u0442\u0440\u043E\u043A\u0430 ${item.line}: ${item.message}` : item.message);
|
||||
if (messages.length && elements.statusEl) {
|
||||
elements.statusEl.textContent = messages.join("; ");
|
||||
}
|
||||
}
|
||||
for (const file of filtered.files) {
|
||||
const parts = (file.webkitRelativePath || file.name).split("/");
|
||||
const relativePath = parts.slice(1).join("/") || file.name;
|
||||
const lowerPath = relativePath.toLowerCase();
|
||||
@@ -1101,11 +1311,13 @@ var FilePicker = (() => {
|
||||
const control = (name, id, label, className = "") => controls.includes(name) ? `<button id="${id}" type="button" class="${className}">${esc(label)}</button>` : "";
|
||||
const columns = cfg.layout.columns?.length ? cfg.layout.columns : Object.keys(cfg.labels.columns);
|
||||
const headings = columns.map((column) => `<th>${esc(cfg.labels.columns[column] || column)}</th>`).join("");
|
||||
const fileAccept = esc([.../* @__PURE__ */ new Set([...cfg.allowedExt, ".zip"])].join(","));
|
||||
const folderAccept = esc([.../* @__PURE__ */ new Set([...cfg.allowedExt, ".zip", ".lst"])].join(","));
|
||||
root.innerHTML = `
|
||||
<div class="file-picker${cfg.layout.theme ? ` ${esc(cfg.layout.theme)}` : ""}">
|
||||
<div class="fp-toolbar" aria-label="${esc(cfg.labels.pickFiles)}">
|
||||
<input class="fp-file-input" type="file" accept="${esc([...cfg.allowedExt, ".zip"].join(","))}" multiple hidden>
|
||||
<input class="fp-folder-input" type="file" accept="${esc([...cfg.allowedExt, ".zip"].join(","))}" webkitdirectory directory multiple hidden>
|
||||
<input class="fp-file-input" type="file" accept="${fileAccept}" multiple hidden>
|
||||
<input class="fp-folder-input" type="file" accept="${folderAccept}" webkitdirectory directory multiple hidden>
|
||||
${control("files", "fp-files-btn", cfg.labels.pickFiles)}
|
||||
${control("folder", "fp-folder-btn", cfg.labels.pickFolder, "secondary")}
|
||||
${control("clear", "fp-clear-btn", cfg.labels.clear, "quiet")}
|
||||
|
||||
@@ -466,6 +466,9 @@
|
||||
</p>
|
||||
|
||||
<div id="filePicker"></div>
|
||||
<p class="sub" style="margin-top:6px;font-size:12px;">
|
||||
Фильтр по маскам: положите в корень папки файл <code>obscure.lst</code>. Подробнее — кнопка HELP.
|
||||
</p>
|
||||
|
||||
<div class="footer-bar">
|
||||
<span id="fileCount">0 файлов</span>
|
||||
@@ -938,15 +941,98 @@
|
||||
style="display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.5);z-index:999;justify-content:center;align-items:center"
|
||||
onclick="this.style.display='none'">
|
||||
<div
|
||||
style="background:var(--card);border-radius:12px;padding:24px;max-width:420px;box-shadow:0 4px 24px rgba(0,0,0,.15)"
|
||||
style="background:var(--card);border-radius:12px;padding:24px;max-width:640px;max-height:85vh;overflow-y:auto;box-shadow:0 4px 24px rgba(0,0,0,.15);text-align:left"
|
||||
onclick="event.stopPropagation()">
|
||||
<h3 style="margin-bottom:12px">Obfuscator — обфускация документов</h3>
|
||||
<p style="font-size:13px;color:var(--muted);line-height:1.6">
|
||||
Загрузите документы (.docx, .doc, .pdf, .txt, .md, .zip) — получите ZIP-архив с обезличенными копиями.
|
||||
Персональные данные, реквизиты компаний, телефоны, email и другие приватные сведения заменяются на обезличенные
|
||||
коды.
|
||||
CSV-файл с таблицей соответствия оригинал→замена скачивается отдельно.
|
||||
коды. CSV-файл с таблицей соответствия оригинал→замена скачивается отдельно.
|
||||
</p>
|
||||
|
||||
<h4 style="margin:18px 0 8px;font-size:14px">Выбор файлов через obscure.lst</h4>
|
||||
<p style="font-size:13px;color:var(--muted);line-height:1.6">
|
||||
Чтобы обработать не всю папку, а только нужные файлы, положите в <b>корень</b> выбранной папки файл
|
||||
<code>obscure.lst</code> со списком масок. Тогда загружаются только файлы, подходящие под правила.
|
||||
</p>
|
||||
<ul style="font-size:13px;color:var(--muted);line-height:1.7;padding-left:20px;margin:8px 0">
|
||||
<li>Файл ищется только в корне папки; имя без учёта регистра: <code>obscure.lst</code>,
|
||||
<code>OBSCURE.LST</code>.</li>
|
||||
<li>Если файла нет — обрабатываются все поддерживаемые документы (как раньше).</li>
|
||||
<li>Сам <code>obscure.lst</code> не загружается и не обфусцируется.</li>
|
||||
<li>Другие <code>.lst</code> игнорируются; вложенный <code>subdir/obscure.lst</code> фильтр не включает.</li>
|
||||
<li>Пустой файл или только комментарии — не загрузится ничего; причина появится в строке статуса.</li>
|
||||
</ul>
|
||||
|
||||
<h4 style="margin:18px 0 8px;font-size:14px">Синтаксис правил</h4>
|
||||
<ul style="font-size:13px;color:var(--muted);line-height:1.7;padding-left:20px;margin:8px 0">
|
||||
<li>Одна строка — одно правило; пустые строки игнорируются.</li>
|
||||
<li><code>#</code> в начале строки — комментарий.</li>
|
||||
<li><code>!</code> в начале строки — исключение (удаляет совпадения).</li>
|
||||
<li>Пути задаются относительно выбранной папки; регистр не важен.</li>
|
||||
<li>Включающие правила собирают файлы, исключения применяются после них.</li>
|
||||
</ul>
|
||||
|
||||
<table style="width:100%;font-size:12px;border-collapse:collapse;margin:8px 0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);white-space:nowrap"><code>*</code></td>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);color:var(--muted)">любые символы в
|
||||
одном сегменте (не <code>/</code>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);white-space:nowrap"><code>?</code></td>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);color:var(--muted)">ровно один символ,
|
||||
кроме <code>/</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);white-space:nowrap"><code>**</code>
|
||||
</td>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);color:var(--muted)">целый сегмент:
|
||||
любые подпапки, включая текущую</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);white-space:nowrap"><code>[a-z]</code>,
|
||||
<code>[abc]</code></td>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);color:var(--muted)">класс или диапазон
|
||||
символов</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);white-space:nowrap"><code>[!a]</code>,
|
||||
<code>[^a]</code></td>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);color:var(--muted)">любой символ, кроме
|
||||
указанных</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);white-space:nowrap">
|
||||
<code>reports/</code></td>
|
||||
<td style="padding:4px 8px;border-bottom:1px solid var(--brand-gray);color:var(--muted)">то же, что
|
||||
<code>reports/**</code> — всё поддерево</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p style="font-size:12px;color:var(--muted);line-height:1.6;margin:6px 0">
|
||||
<code>*.pdf</code> — только PDF в корне, <code>**/*.pdf</code> — PDF в корне и во всех подпапках.
|
||||
<code>a**b</code> внутри сегмента работает как <code>a*b</code>.
|
||||
ZIP фильтруется по имени архива и затем раскрывается целиком.
|
||||
</p>
|
||||
|
||||
<h4 style="margin:18px 0 8px;font-size:14px">Пример obscure.lst</h4>
|
||||
<pre
|
||||
style="font-size:12px;background:var(--brand-grey-light);border:1px solid var(--brand-gray);border-radius:8px;padding:10px 12px;overflow-x:auto;margin:8px 0"># Все PDF в корне и во вложенных папках
|
||||
**/*.pdf
|
||||
|
||||
# Договоры в reports, начинающиеся с name
|
||||
reports/name*.docx
|
||||
|
||||
# Исключить черновики и старые архивы
|
||||
!**/*draft*.*
|
||||
!archive/**</pre>
|
||||
<p style="font-size:12px;color:#9a3412;line-height:1.6;margin:6px 0">
|
||||
Если правило написано с ошибкой (абсолютный путь, <code>..</code>, незакрытый <code>[</code>),
|
||||
оно пропускается, а номер строки с причиной показывается в строке статуса под таблицей.
|
||||
</p>
|
||||
|
||||
<button class="btn" style="margin-top:12px;width:100%"
|
||||
onclick="document.getElementById('helpModal').style.display='none'">Закрыть</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user