Store embed titles and search them

This commit is contained in:
Fisto
2026-09-17 13:10:16 +02:00
parent c6caa168be
commit 557ba5ca7e
13 changed files with 200 additions and 10 deletions
+37 -1
View File
@@ -291,6 +291,11 @@
if (value === "" || !Number.isFinite(number) || number < 0) return "";
return String(Math.round(number * (unit ? sizeUnit(unit) : 1)));
};
const title = state.filters.title.trim()
? `title=${encodeURIComponent(state.filters.title.trim())}&${
state.filters.titleExact ? "titleExact=1&" : ""
}`
: "";
const sizeLt = state.filters.sizeLt !== "" ? `sizeLt=${amount(state.filters.sizeLt, state.filters.sizeLtUnit)}&` : "";
const sizeGt = state.filters.sizeGt !== "" ? `sizeGt=${amount(state.filters.sizeGt, state.filters.sizeGtUnit)}&` : "";
const lenLt = state.filters.lenLt !== "" ? `lenLt=${amount(state.filters.lenLt)}&` : "";
@@ -301,7 +306,7 @@
const before = state.filters.before ? `before=${state.filters.before}T23:59:59.999Z&` : "";
return (
`${kind}${source}${channel}${authors}${origin}${cached}${exts}${excludeHosts}` +
`${sort}${excludeProviders}${excludeSources}${excludeExts}` +
`${sort}${title}${excludeProviders}${excludeSources}${excludeExts}` +
`${includeProviders}${includeSources}${sizeLt}${sizeGt}${lenLt}${lenGt}` +
`${aspect}${resolution}${after}${before}`
);
@@ -1044,6 +1049,7 @@
function renderCard(item) {
const figure = el("figure", "vk-media-figure");
if (item.title) figure.title = item.title;
const media = el("div", "vk-media-media");
const imageSource = item.localUrl || item.thumbUrl;
const fallbackSource = item.source !== "embed" ? item.url : null;
@@ -1174,6 +1180,8 @@
exts: [],
excludeHosts: ["4chan.org", "i.4cdn.org"],
sort: "newest",
title: "",
titleExact: false,
excludeProviders: [],
excludeSources: [],
includeProviders: [],
@@ -1204,6 +1212,8 @@
excludeSources: [...state.filters.excludeSources],
includeProviders: [...state.filters.includeProviders],
includeSources: [...state.filters.includeSources],
title: state.filters.title,
titleExact: state.filters.titleExact,
excludeExts: [...state.filters.excludeExts]
};
}
@@ -1224,6 +1234,8 @@
excludeSources: [...state.draft.excludeSources],
includeProviders: [...state.draft.includeProviders],
includeSources: [...state.draft.includeSources],
title: state.draft.title,
titleExact: state.draft.titleExact,
excludeExts: [...state.draft.excludeExts],
sizeLt: state.draft.sizeLt,
sizeGt: state.draft.sizeGt,
@@ -1382,6 +1394,30 @@
draft.sort = value;
}
),
(() => {
const row = el("div", "vk-media-toolbar");
const input = document.createElement("input");
input.type = "text";
input.className = "vk-media-input";
input.placeholder = "Video title (Ma Ca Ju finds Man ... car jumps)";
input.value = draft.title;
input.addEventListener("input", () => {
draft.title = input.value;
});
row.append(input);
const exact = el("label", "vk-media-check");
const box = document.createElement("input");
box.type = "checkbox";
box.checked = draft.titleExact;
box.title = "Match the whole phrase instead of per-word prefixes";
box.addEventListener("change", () => {
draft.titleExact = box.checked;
});
exact.append(box, document.createTextNode(" Exact match (quotes)"));
row.append(exact);
return row;
})(),
filterSelect(
[
["", "Any ratio"],