List unlinked places and unmapped words under Sources, fix them in code with the unmapped skill

Settings > Sources > Unmapped shows the place texts no place resolves, with
their roles' countries and companies, and the host words no table maps, and
copies both as text. Prep fingerprints places.seed(), so a town or spelling
added to the code is seeded and every open role is mapped again at the next
prep. app prep unlinked lists the places on the command line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 13:06:22 +02:00
1 parent ae978594b4
commit 06ff9f549b
13 files changed
+313 -43

No files matched your search

+12
View File
@@ -1331,6 +1331,8 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
gap: .4rem; font-size: .8rem; color: var(--dim);
}
.srow[data-muted="true"], .crow[data-hidden="true"] { opacity: .6; }
/* A count beside a row's name, as the Unmapped rows show their roles. */
.srow > .count { margin: 0; white-space: nowrap; }
/* A company row's Set board / Change editor: its own line under `.sub`,
wrapping like `.sub` does, the boxes styled as `.source-form`'s. */
.crow .board-edit {
@@ -1360,6 +1362,16 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
.prune > summary { cursor: pointer; color: var(--dim); font-weight: 600; }
.prune[open] > summary { margin-bottom: .75rem; }
/* Where the Unmapped list goes when the clipboard is refused, as news's
`.share-url`: outside a secure context (the server at a LAN address) there
is none, and text has to be on the page to be selectable. */
.copy-out {
margin: .5rem 0 1rem; padding: .5rem .7rem; max-height: 16rem; overflow: auto;
font-family: var(--mono); font-size: .78rem; white-space: pre-wrap;
overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line);
border-radius: .3rem;
}
/* applications and companies */
table.list { width: 100%; border-collapse: collapse; background: var(--panel); }
+109 -29
View File
@@ -19,9 +19,14 @@
* Under the Follow form of Company boards, a fold lists what each reader
* declares (`/api/readers`): how its list arrives, where the text is, what
* it filters at the source, how it states places, and the robots.txt
* decision taken when it was built. A second fold lists the host words no
* table in `app/prep/hosts` maps (`/api/prep/unmapped`), per field and
* host, most roles first; it is left out when there are none.
* decision taken when it was built.
*
* The Unmapped section lists what prep could not place, most roles first:
* the place texts no place resolves (`/api/prep/unlinked`), with the
* countries and companies of their roles, and the host words no table in
* `app/prep/hosts` maps (`/api/prep/unmapped`), per field and host. Copy
* puts both on the clipboard as text for Claude, or, where there is no
* clipboard, on the page selected.
*/
(function () {
"use strict";
@@ -322,36 +327,108 @@
$("#board-form").after(fold);
}
/** The host words prep could not map, one row per field and host. */
function renderUnmapped(words) {
if (!words.length) return;
// ------------------------------------------------------------ unmapped
/** Rows shown before Show all; the copy always holds every one. */
const UNLINKED_SHOWN = 40;
/** @type {{places: object[], words: object[]}} */
const unmapped = { places: [], words: [] };
/** "DE 5 · EU 5 · none 1", the three biggest. */
function where(place) {
const shown = place.countries.slice(0, 3).map(([code, n]) => `${code || "none"} ${n}`);
if (place.countries.length > 3) shown.push("…");
return shown.join(" · ");
}
function srow(name, right, sub) {
const row = document.createElement("div");
row.className = "srow";
const label = document.createElement("span");
label.className = "name";
label.textContent = name;
const n = document.createElement("span");
n.className = "count";
n.textContent = right;
const line = document.createElement("span");
line.className = "sub";
line.textContent = sub;
row.append(label, n, line);
return row;
}
function renderUnlinked(all) {
const list = $("#unlinked-list");
const shown = all ? unmapped.places : unmapped.places.slice(0, UNLINKED_SHOWN);
list.replaceChildren(...shown.map((p) => srow(p.text, count(p.roles, "role"),
[where(p), p.companies.join(", ")].filter(Boolean).join(" · "))));
$("#unlinked-count").textContent = unmapped.places.length
? `${count(unmapped.places.length, "place text")} on open roles no place resolves.`
: "Every place text of an open role resolves.";
if (shown.length < unmapped.places.length) {
const more = document.createElement("button");
more.type = "button";
more.className = "linky";
more.textContent = `Show all ${unmapped.places.length}`;
more.addEventListener("click", () => renderUnlinked(true));
list.appendChild(more);
}
}
function renderWords() {
const groups = new Map();
for (const w of words) {
for (const w of unmapped.words) {
const key = `${w.field} · ${w.host || "no host"}`;
if (!groups.has(key)) groups.set(key, []);
groups.get(key).push(w);
}
const fold = document.createElement("details");
fold.className = "prune";
fold.id = "unmapped";
const summary = document.createElement("summary");
summary.textContent = `Host words no table maps (${words.length})`;
const list = document.createElement("div");
list.className = "srows";
for (const [key, found] of groups) {
const row = document.createElement("div");
row.className = "srow";
const name = document.createElement("span");
name.className = "name";
name.textContent = key;
const sub = document.createElement("span");
sub.className = "sub";
sub.textContent = found.map((w) => `${w.word} ${w.roles}`).join(" · ");
row.append(name, sub);
list.appendChild(row);
$("#words-list").replaceChildren(...[...groups].map(([key, found]) =>
srow(key, count(found.reduce((n, w) => n + w.roles, 0), "role"),
found.map((w) => `${w.word} ${w.roles}`).join(" · "))));
$("#words-count").textContent = unmapped.words.length
? `${count(unmapped.words.length, "host word")} no table maps.`
: "Every host word is mapped.";
}
/** Both lists as text, one line an entry, for pasting to Claude. */
function unmappedText() {
const lines = ["Unlinked places (roles, their countries, companies):"];
for (const p of unmapped.places) {
lines.push(`${p.roles} ${p.text} [${where(p)}] ${p.companies.join(", ")}`);
}
fold.append(summary, list);
($("#readers") || $("#board-form")).after(fold);
lines.push("", "Unmapped host words (field, host, roles, word):");
for (const w of unmapped.words) {
lines.push(`${w.field} ${w.host || "-"} ${w.roles} ${w.word}`);
}
return lines.join("\n");
}
// The clipboard needs a secure context; the server reached at a LAN
// address is not one. As news's copyLink, the text is then put on the
// page and selected, for the device's own Copy.
async function copyUnmapped() {
const text = unmappedText();
try {
await navigator.clipboard.writeText(text);
window.toast.good("Copied the unmapped list.");
return;
} catch { /* no clipboard here: show the text instead */ }
const holder = $("#unmapped-text");
holder.textContent = text;
holder.hidden = false;
const range = document.createRange();
range.selectNodeContents(holder);
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
window.toast.info("The list is selected: use your device's Copy.");
}
async function loadUnmapped() {
[unmapped.places, unmapped.words] = await Promise.all(
[api("/api/prep/unlinked"), api("/api/prep/unmapped")]);
renderUnlinked(false);
renderWords();
}
// ------------------------------------------------------ one section shown
@@ -395,8 +472,11 @@
document.addEventListener("DOMContentLoaded", async () => {
if (!$("#searches-list")) return;
if ($("#board-form")) {
api("/api/readers").then(renderReaders, () => {})
.then(() => api("/api/prep/unmapped")).then(renderUnmapped, () => {});
api("/api/readers").then(renderReaders, () => {});
}
if ($("#unlinked-list")) {
loadUnmapped().catch(() => {});
$("#unmapped-copy").addEventListener("click", copyUnmapped);
}
try {
await load();