Wiki: drop the unused lookup, search and section routes
Nothing in the page or the link scanner called /api/wiki/lookup, /api/wiki/search or /api/wiki/section. Remove the routes and what existed only for them: readTitles and the POST allowance, WikiClient.search and SearchHit, TTL.search, snippet(), the mock's search/page answer, WikiClient.section and Section. WikiClient.lookup stays (the scanner uses it), as do suggest and article. Tests of the removed code go; input validation and off mode are now checked on remaining routes. The mock's Eukaryote fixture gets its own page id instead of sharing Hostile article's. README and docs/wikipedia.md list what exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
60d26908d6
commit
5c867b2eef
9 files changed
+24
-190
No files matched your search
@@ -169,28 +169,6 @@ function tidy(html: string) {
|
||||
return html.replace(/\n{3,}/g, "\n\n").trim();
|
||||
}
|
||||
|
||||
/** Search excerpts: keep the matches as <mark>, everything else as text. */
|
||||
export function snippet(excerpt: string): { text: string; html: string } {
|
||||
let text = "";
|
||||
let html = "";
|
||||
const walk = (nodes: Node[], inMatch: boolean) => {
|
||||
for (const n of nodes) {
|
||||
if (n.nodeName === "#text") {
|
||||
const v = (n as T.TextNode).value;
|
||||
text += v;
|
||||
html += escapeText(v);
|
||||
} else if (isEl(n)) {
|
||||
const m = !inMatch && classes(n).has("searchmatch");
|
||||
if (m) html += "<mark>";
|
||||
walk(n.childNodes, inMatch || m);
|
||||
if (m) html += "</mark>";
|
||||
}
|
||||
}
|
||||
};
|
||||
walk(parseFragment(excerpt).childNodes, false);
|
||||
return { text, html };
|
||||
}
|
||||
|
||||
function headingOf(n: Node): El | null {
|
||||
if (!isEl(n)) return null;
|
||||
if (/^h[2-6]$/.test(n.tagName)) return n;
|
||||
|
||||
Reference in new issue
Block a user