Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(ui): 资料页按 beeg 改移动端布局,并给链接加可达性门槛

longmeidao344b21eebe64
diff --git a/scripts/install_entity_links.py b/scripts/install_entity_links.py
index d06762dc9..21911ee7b 100644
--- a/scripts/install_entity_links.py
+++ b/scripts/install_entity_links.py
@@ -15,14 +15,19 @@ import argparse
import json
import sqlite3
import sys
+import time
from datetime import datetime, timezone
from pathlib import Path
from urllib.parse import urlsplit
+import httpx
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
from peach.review_csv import read_rows # noqa: E402
+USER_AGENT = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
+ "(KHTML, like Gecko) Chrome/128.0 Safari/537.36")
LINK_KINDS = {"official", "social", "catalog", "source_reference"}
FIELDS = ("entity_id", "kind", "name", "link_kind", "label", "url", "evidence")
@@ -95,6 +100,68 @@ def plan(connection: sqlite3.Connection, rows: list[dict]) -> list[dict]:
return planned
+def resolves(url: str, timeout: float = 12.0) -> tuple[bool, str]:
+ """这个地址现在还能打开吗。返回(能不能, 说明)。
+
+ 每个请求新建 client 并立刻关掉:这批地址分布在上百个互不相同的主机上,其中不少
+ 连不上,而失败的连接会在共享池里漏掉槽位,几十个请求之后一切都变成 PoolTimeout。
+ """
+ try:
+ with httpx.Client(follow_redirects=True, timeout=timeout,
+ limits=httpx.Limits(max_connections=4,
+ max_keepalive_connections=0)) as client:
+ response = client.get(url, headers={"User-Agent": USER_AGENT})
+ except Exception as exc:
+ return False, f"取不到:{type(exc).__name__}"
+ if response.status_code != 200:
+ return False, f"HTTP {response.status_code}"
+ return True, "可打开"
+
+
+def check_links(planned: list[dict], interval: float = 0.4, probe=None) -> None:
+ """把打不开的地址从写入计划里剔除,就地改写 `planned`。
+
+ 这一步是补上一次真实事故的:首批 703 条链接一条都没验就装进了账本,事后逐条测
+ 发现 289 条 official 里有 107 条打不开(84 个 404、18 个 502),37% 是死的。
+ 上游给什么就存什么,等于把 minnano-av 几年前的快照当成现在的事实——T-POWERS 改过
+ 站,`/official/talent/X` 早已 404,而资料页上它看起来和好链接一模一样。
+
+ 门槛放在安装器而不是各个采集器里:这里是所有来源进入账本的唯一入口,一道门管住
+ 全部,好过给每个采集器各打一个补丁、再漏掉下一个。社媒同样验——实测 X 对真 handle
+ 回 200、对不存在的回 404,livedoor 上也确实有已经删掉的博客。
+ """
+ probe = probe or resolves
+ for item in planned:
+ if item["action"] != "insert":
+ continue
+ ok, note = probe(item["url"])
+ if not ok:
+ item.update(action="skip", reason=f"打不开,不写入({note})")
+ if probe is resolves:
+ time.sleep(interval)
+
+
+def dead_links(connection: sqlite3.Connection, interval: float = 0.4, probe=None) -> list[dict]:
+ """已经在库里、但现在打不开的链接。
+
+ 可达性门槛只挡住新写入;库里那 703 条是在门槛存在之前进去的,得单独清一遍。
+ 链接还会随时间烂掉——事务所改版、艺人解约、博客注销——所以这条路要留着复用,
+ 不是一次性的清理脚本。
+ """
+ probe = probe or resolves
+ out = []
+ for link_id, entity, kind, label, url in connection.execute(
+ "SELECT l.id, e.canonical_name, l.link_kind, l.label, l.url "
+ "FROM entity_link l JOIN entity e ON e.id=l.entity_id ORDER BY l.id"):
+ ok, note = probe(url)
+ if not ok:
+ out.append({"id": link_id, "entity": entity, "link_kind": kind,
+ "label": label, "url": url, "note": note})
+ if probe is resolves:
+ time.sleep(interval)
+ return out
+
+
def install(connection: sqlite3.Connection, planned: list[dict], source: str) -> int:
now = datetime.now(timezone.utc).isoformat()
written = 0
@@ -118,25 +185,77 @@ def install(connection: sqlite3.Connection, planned: list[dict], source: str) ->
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--database", type=Path, required=True)
- parser.add_argument("--input", type=Path, required=True,
+ parser.add_argument("--input", type=Path,
help=f"复核表,列:{','.join(FIELDS)}")
+ parser.add_argument("--prune-dead", action="store_true",
+ help="改为清理库里已经打不开的链接,不读 --input")
parser.add_argument("--apply", action="store_true", help="真正写入;必须同时给 --backup")
+ parser.add_argument("--no-check", action="store_true",
+ help="跳过「地址能不能打开」的检查。只在离线复核时用——"
+ "首批 703 条就是没验直接装的,事后发现 37%% 是死链")
parser.add_argument("--backup", type=Path, help="写入前的 SQLite 备份落点")
return parser
+def prune(connection: sqlite3.Connection, args) -> int:
+ """列出并(在 --apply 时)删除库里打不开的链接。"""
+ before = connection.execute("SELECT count(*) FROM entity_link").fetchone()[0]
+ dead = dead_links(connection)
+ for item in dead:
+ print(f" - {item['entity'][:14]:<14} {item['link_kind']:<8} "
+ f"{item['label'][:18]:<18} {item['note']:<14} {item['url'][:52]}")
+ print({"库内链接": before, "打不开": len(dead)})
+ if not args.apply:
+ print("dry-run;确认无误后加 --apply --backup <路径>")
+ return 0
+
+ args.backup.parent.mkdir(parents=True, exist_ok=True)
+ destination = sqlite3.connect(args.backup)
+ with destination:
+ connection.backup(destination)
+ destination.close()
+ print(f"已备份:{args.backup}")
+
+ with connection:
+ connection.executemany("DELETE FROM entity_link WHERE id=?",
+ [(item["id"],) for item in dead])
+ after = connection.execute("SELECT count(*) FROM entity_link").fetchone()[0]
+ integrity = connection.execute("PRAGMA integrity_check").fetchone()[0]
+ orphans = len(connection.execute("PRAGMA foreign_key_check").fetchall())
+ print({"删除前": before, "删除后": after, "差值": before - after,
+ "integrity_check": integrity, "foreign_key_check": orphans})
+ if before - after != len(dead) or integrity != "ok" or orphans:
+ print("[warn] 前后差值、完整性或外键与预期不符,请人工核对")
+ return 1
+ return 0
+
+
def main(argv: list[str] | None = None) -> int:
args = build_parser().parse_args(argv)
if args.apply and not args.backup:
print("[stop] --apply 是真实账本写入,必须同时给 --backup")
return 2
- rows = read_rows(args.input)
+ if not args.prune_dead and not args.input:
+ print("[stop] 需要 --input(写入复核表)或 --prune-dead(清理死链)")
+ return 2
+
connection = sqlite3.connect(args.database)
connection.execute("PRAGMA foreign_keys=ON")
+ if args.prune_dead:
+ try:
+ return prune(connection, args)
+ finally:
+ connection.close()
+
+ rows = read_rows(args.input)
try:
before = connection.execute("SELECT count(*) FROM entity_link").fetchone()[0]
planned = plan(connection, rows)
+ if args.no_check:
+ print("[warn] 已跳过可达性检查:打不开的地址会照样写进账本")
+ else:
+ check_links(planned)
for item in planned:
mark = "+" if item["action"] == "insert" else " "
print(f" {mark} {str(item['studio'])[:18]:<18} {item['link_kind']:<8} "
diff --git a/tests/test_entity_link_install.py b/tests/test_entity_link_install.py
index 728aec8e9..7a8682a39 100644
--- a/tests/test_entity_link_install.py
+++ b/tests/test_entity_link_install.py
@@ -140,10 +140,65 @@ class InstallTests(unittest.TestCase):
"entity_id,kind,name,link_kind,label,url,evidence\n"
",studio,MOODYZ,official,官方网站,https://moodyz.com/,标题自述\n",
encoding="utf-8-sig")
- self.assertEqual(self.module.main(["--database", str(self.db), "--input", str(source)]), 0)
+ # `--no-check` 不只是提速:测试不许发网络请求,否则一次断网就变成红灯。
+ self.assertEqual(self.module.main(
+ ["--database", str(self.db), "--input", str(source), "--no-check"]), 0)
self.assertEqual(
self.connection.execute("SELECT count(*) FROM entity_link").fetchone()[0], 0)
+ def test_a_link_that_does_not_open_never_reaches_the_ledger(self):
+ """这条守的是一次真实事故。
+
+ 首批 703 条链接一条都没验就装进了账本,事后逐条测发现 289 条 official 里有
+ 107 条打不开(84 个 404、18 个 502),37% 是死的。上游给什么就存什么,等于把
+ minnano-av 几年前的快照当成现在的事实——T-POWERS 改过站,`/official/talent/X`
+ 早已 404,而资料页上它看起来和好链接一模一样。
+
+ 门槛放在安装器而不是各个采集器里:这里是所有来源进入账本的唯一入口。
+ """
+ planned = self.module.plan(self.connection, [
+ self.row(url="https://dead.example/gone"),
+ self.row(name="Prestige", url="https://alive.example/"),
+ ])
+ self.assertEqual([p["action"] for p in planned], ["insert", "insert"])
+ self.module.check_links(
+ planned, probe=lambda url: (url == "https://alive.example/", "HTTP 404"))
+ self.assertEqual([p["action"] for p in planned], ["skip", "insert"])
+ self.assertIn("打不开", planned[0]["reason"])
+ self.assertIn("404", planned[0]["reason"])
+ self.assertEqual(self.module.install(self.connection, planned, "review.csv"), 1)
+
+ def test_dead_links_already_in_the_ledger_are_found_for_pruning(self):
+ """可达性门槛只挡新写入;库里那 703 条是在门槛存在之前进去的。
+
+ 链接还会随时间烂掉——事务所改版、艺人解约、博客注销——所以这条路要留着复用,
+ 不是一次性的清理脚本。
+ """
+ for url in ("https://alive.example/", "https://dead.example/gone"):
+ planned = self.module.plan(self.connection, [self.row(url=url)])
+ self.module.install(self.connection, planned, "seed.csv")
+ self.assertEqual(
+ self.connection.execute("SELECT count(*) FROM entity_link").fetchone()[0], 2)
+
+ dead = self.module.dead_links(
+ self.connection, probe=lambda url: (url == "https://alive.example/", "HTTP 404"))
+ self.assertEqual([d["url"] for d in dead], ["https://dead.example/gone"])
+ self.assertEqual(dead[0]["entity"], "MOODYZ")
+ self.assertEqual(dead[0]["note"], "HTTP 404")
+
+ def test_the_reachability_gate_does_not_re_probe_rows_already_skipped(self):
+ """已经因为别的原因跳过的行不必再请求一次——那是白费一次往返。"""
+ planned = self.module.plan(self.connection, [self.row(name="不存在的厂牌")])
+ self.assertEqual(planned[0]["action"], "skip")
+ probed = []
+
+ def probe(url):
+ probed.append(url)
+ return True, ""
+
+ self.module.check_links(planned, probe=probe)
+ self.assertEqual(probed, [])
+
if __name__ == "__main__":
unittest.main()
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 2cb46511c..a69424ae7 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -254,6 +254,43 @@ class WebUiSourceTests(unittest.TestCase):
self.app_js[anchor:anchor + 260],
"资料页外链 favicon 必须带 no-referrer")
+ def test_social_links_show_only_the_platform_mark_not_the_handle(self):
+ # handle 是网址的一部分,写出来只是把 URL 抄一遍:`X @remu19971203` 里真正有
+ # 信息量的只有那个 X。图标本身就说明了去哪,名字留给官网那种「点之前看不出是谁」
+ # 的链接。纯图标没有可读文字,所以标签必须留给辅助技术,不能整个丢掉。
+ self.assertPageContains("x.link_kind==='social'\n ? `<span class=\"sr-only\">${esc(x.label)}</span>`")
+ self.assertPageContains('.entitylinks a.iconlink{padding:4px;gap:0;border-radius:50%}')
+
+ def test_entity_links_have_no_external_arrow(self):
+ # `target="_blank"` 已经是外链,箭头只是重复;一排链接里它还会挤掉本就不多的
+ # 横向空间。整条 CSS 一并删掉,别留下没人用的类名。
+ self.assertPageLacks('entitylinkarrow', "外链箭头应当已删除")
+ self.assertPageLacks('↗', "外链箭头字符应当已删除")
+
+ def test_x_links_use_an_inline_brand_mark_instead_of_a_fetched_favicon(self):
+ # favicon 是别人服务器上的一张小位图:X 直接挡掉爬取(资料页上那个空白白圆就是
+ # 它),取到的也多是 16×16,放进 32px 的圆里必然糊。416 条社媒链接里 372 条是
+ # x.com/twitter.com,只给它一个内联标记就覆盖了 89%,还省一次跨站请求。
+ self.assertPageContains("const BRAND_ICONS=[[['x.com','twitter.com'],'brand-x']];")
+ self.assertPageContains('<symbol id="i-brand-x"')
+ # 填充字形不吃通用的 stroke:currentColor;fill:none。
+ self.assertPageContains('.entitylinkicon.brand svg{width:15px;height:15px;fill:currentColor;stroke:none}')
+
+ def test_the_entity_hero_is_a_centred_single_column_on_phones(self):
+ # 左像右文那套是给宽屏的:手机上 92px 头像旁边只剩两百多像素,别名和链接被挤成
+ # 两三行,头像下面又空着一大片。按 beeg 的资料页改成单列居中。
+ self.assertPageContains(
+ ".entityhero{grid-template-columns:minmax(0,1fr);gap:12px;padding:8px 0 18px;"
+ "justify-items:center;text-align:center}")
+ self.assertPageContains(".entityhero .entitylinks{justify-content:center")
+
+ def test_the_jav_layout_switch_cannot_be_squeezed_flat_in_the_sort_row(self):
+ # `.sorts` 是不换行的横向滚动条,里面的项默认可收缩,而 `.javlayout` 自己带着
+ # `min-width:0`(fieldset 需要它才不撑破容器)。两条合起来允许它被压到内容宽度
+ # 以下:窄屏上三个 34px 的版式按钮会叠在一起,还压住旁边的「发行时间」。
+ # `.sorts button` 早有 `flex:0 0 auto`,但 fieldset 不是 button,选不到它。
+ self.assertPageContains(".sorts .javlayout{display:inline-flex;gap:2px;margin:0 6px;flex:none}")
+
def test_detail_identity_groups_by_kind_with_the_label_on_top(self):
# 逐行一个名字在共演作品上会把整个侧栏撑满,左侧还重复一列标签。
self.assertPageContains("const idGroup=(label,kind,list,extra='')=>list.length")
diff --git a/web/app.css b/web/app.css
index 277faab88..ba9515317 100644
--- a/web/app.css
+++ b/web/app.css
@@ -370,8 +370,16 @@ body.entity-open .index{overflow-x:visible}
.entitylinks .private{color:var(--muted);border-style:dashed}
.entitylinkicon{width:32px;height:32px;border-radius:50%;background:var(--sunk);display:grid;place-items:center;
overflow:hidden;position:relative;flex:none}.entitylinkicon svg{width:16px;height:16px;stroke:currentColor;fill:none;
- stroke-width:1.8}.entitylinkicon img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;background:#fff}
-.entitylinklabel{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.entitylinkarrow{color:var(--muted);flex:none}
+ stroke-width:1.8}
+/* favicon 是别人服务器上的位图,取不到时 `onerror` 会把 img 摘掉、露出下面的地球。
+ 但白底会让「取到了一张空图」看起来和「圆盘坏了」一模一样——X 的 favicon 正是这种。
+ 现在 X 走内联品牌标记不再发请求,其余主机也不再垫白底。 */
+.entitylinkicon img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;background:var(--sunk)}
+/* 品牌标记是填充字形,不吃上面那套描边。 */
+.entitylinkicon.brand svg{width:15px;height:15px;fill:currentColor;stroke:none}
+/* 纯图标的社媒链接:收成圆形,没有文字就不给文字留位置。 */
+.entitylinks a.iconlink{padding:4px;gap:0;border-radius:50%}
+.entitylinklabel{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.entityterms{margin-top:13px;color:var(--muted);font-size:var(--fs-xs)}.entityterms code{color:var(--ink-2);margin-right:8px}
.entitymeta{display:grid;gap:22px;margin:0 0 6px;min-width:0}.entitymeta section{min-width:0}.entitysection h3{font-size:var(--fs-sm);letter-spacing:.08em;color:var(--muted);margin:0 0 12px}
.entitytagbar{position:sticky;top:var(--topH);z-index:61;display:flex;align-items:center;
@@ -1709,8 +1717,16 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
了流,没有东西再撑开中间,按钮会全部挤在品牌名右侧、右半条留空。
动作组的第一个按钮吃掉剩余空间,整组回到右边。 */
#immerseBtn{margin-left:auto}
- .entityhero{grid-template-columns:92px minmax(0,1fr);gap:14px;padding:8px 0 18px}
- .entityportrait{width:92px}.entityhero h2{font-size:var(--fs-xl)}
+ /* 窄屏改成单列居中,头像在名字上方——参考 beeg 的资料页。
+ 左像右文那套是给宽屏的:手机上 92 px 头像旁边只剩两百多像素,别名和链接被挤成
+ 两三行,头像下面又空着一大片。居中之后名字和链接都拿到整行宽度。 */
+ .entityhero{grid-template-columns:minmax(0,1fr);gap:12px;padding:8px 0 18px;justify-items:center;text-align:center}
+ .entityportrait{width:112px}.entityhero h2{font-size:var(--fs-xl)}
+ .entityhero>div:last-child{width:100%}
+ .entityhero .alias{margin-bottom:10px}
+ .entitysummary{margin-inline:auto}
+ .entityhero .entitylinks{justify-content:center;margin-top:13px}
+ .entityhero .entityterms{text-align:center}
.stats h2{font-size:var(--fs-xl)}.stats .insightcopy h2{font-size:var(--fs-3xl)}
/* 窄屏下标题也得一起缩。`/follow` 渲染在 `#stats` 里,上面那条 `.stats h2`
会只把它打到 23px,而 `#manageTitle` 在 `#stats` 外面,手机上又变成两种大小。 */
@@ -1753,7 +1769,12 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
/* 版式按钮嵌在排序行里,必须比 `.sorts button` 更具体,否则那条规则的内边距和
行高会把图标顶偏。图标按钮不设左右内边距,靠 grid 居中。 */
-.sorts .javlayout{display:inline-flex;gap:2px;margin:0 6px}.sorts .javlayout label{line-height:0}.sorts .javlayout svg{display:block}
+/* `flex:none` 是必须的,不是保险。`.sorts` 是不换行的横向滚动条,里面的项默认可收缩,
+ 而 `.javlayout` 自己带着 `min-width:0`(fieldset 需要它才不撑破容器)——两条合起来
+ 允许它被压到内容宽度以下。窄屏上排序按钮一多,三个 34 px 的版式按钮就会叠在一起,
+ 还压住旁边的「发行时间」。`.sorts button` 早就有 `flex:0 0 auto`,但 fieldset 不是
+ button,那条规则选不到它。 */
+.sorts .javlayout{display:inline-flex;gap:2px;margin:0 6px;flex:none}.sorts .javlayout label{line-height:0}.sorts .javlayout svg{display:block}
/* ── 脱盘模式 ────────────────────────────────────────────────────────────────
来源盘不在时只置灰该来源的筛选,其余来源照常。数量仍然显示:账本是本机真相,
diff --git a/web/app.js b/web/app.js
index cdb12c971..a49cdd42d 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1,4 +1,4 @@
-import {$, ENTITY_ROUTES, LOC, ROUTE_ENTITIES, ROUTE_STATES, SITE_FAVICONS, STATE_LABELS, STATE_ROUTES, api, entityPath, esc, faviconFallbackUrl, faviconUrl, fmtClock, fmtDur, fmtSize, foldName, icon, isCatalogPath, pageTitle, realDuration} from './js/core.js';
+import {$, ENTITY_ROUTES, LOC, ROUTE_ENTITIES, ROUTE_STATES, SITE_FAVICONS, STATE_LABELS, STATE_ROUTES, api, brandIcon, entityPath, esc, faviconFallbackUrl, faviconUrl, fmtClock, fmtDur, fmtSize, foldName, icon, isCatalogPath, pageTitle, realDuration} from './js/core.js';
import { initMiddleTruncate } from './js/middle-truncate.js';
import {
emptyStateHtml, loadingDotsHtml, mediaViewButtonsHtml, noteHtml, progressHtml, scrollerHtml,
@@ -4502,9 +4502,25 @@ async function openEntity(kind,name,push=true,requestedTag){
垫底永远回不来。`onerror=null` 只是不再重试,不等于这一环走完了。 */
: `<img src="/entity-image?kind=${kind}&id=${d.id}" alt="${esc(d.canonical_name)}"${facePos(d.avatar_focus)}
onerror="this.removeAttribute('style');${d.representative_asset_id?`if(!this.dataset.f){this.dataset.f='1';this.src='/avatar?id=${d.representative_asset_id}'}else{this.remove()}`:`this.remove()`}">`):'';
- const links=(d.links||[]).map(x=>x.clickable&&/^https?:\/\//i.test(x.url||'')
- ? `<a href="${esc(x.url)}" target="_blank" rel="noreferrer"><span class="entitylinkicon">${icon('globe')}<img class="entityfavicon" src="${esc(faviconUrl(x.url))}" data-studio="${kind==='studio'?esc(d.canonical_name):''}" alt="" loading="lazy" referrerpolicy="no-referrer"></span><span class="entitylinklabel">${esc(x.label)}</span><span class="entitylinkarrow" aria-hidden="true">↗</span></a>`
- : `<span class="private" title="私人馆藏来源记录,不直接打开下载页"><span class="entitylinkicon">${icon('globe')}</span><span class="entitylinklabel">来源 · ${esc(x.label||x.hostname||'已记录')}</span></span>`).join('');
+ /* 链接按 beeg 的资料页形态:社媒收成纯图标,官网/事务所保留名字。
+
+ 社媒的 handle 是网址的一部分,写出来只是把 URL 抄一遍——`X @remu19971203` 里
+ 真正有信息量的只有那个 X。图标本身就说明了去哪,名字留给官网那种「点之前看不出
+ 是谁」的链接。外链箭头一并去掉:`target="_blank"` 已经是外链,箭头只是重复,
+ 一排链接里还会挤掉本来就不多的横向空间。 */
+ const links=(d.links||[]).map(x=>{
+ if(!(x.clickable&&/^https?:\/\//i.test(x.url||'')))
+ return `<span class="private" title="私人馆藏来源记录,不直接打开下载页"><span class="entitylinkicon">${icon('globe')}</span><span class="entitylinklabel">来源 · ${esc(x.label||x.hostname||'已记录')}</span></span>`;
+ const brand=brandIcon(x.url);
+ const mark=brand
+ ? `<span class="entitylinkicon brand">${icon(brand)}</span>`
+ : `<span class="entitylinkicon">${icon('globe')}<img class="entityfavicon" src="${esc(faviconUrl(x.url))}" data-studio="${kind==='studio'?esc(d.canonical_name):''}" alt="" loading="lazy" referrerpolicy="no-referrer"></span>`;
+ // 纯图标的链接自己不带可读文字,得把标签留给辅助技术。
+ const body=x.link_kind==='social'
+ ? `<span class="sr-only">${esc(x.label)}</span>`
+ : `<span class="entitylinklabel">${esc(x.label)}</span>`;
+ return `<a class="${x.link_kind==='social'?'iconlink':''}" href="${esc(x.url)}" target="_blank" rel="noreferrer" title="${esc(x.label)}">${mark}${body}</a>`;
+ }).join('');
const terms=(d.search_terms||[]).map(x=>`<code>${esc(x.term)}</code>`).join('');
const tags=(d.tags||[]).map(x=>`<button class="pill" data-entity-tag="${esc(x.k)}" aria-pressed="${entityTag===x.k}">${esc(tagLabel(x.k))}<small>${x.n.toLocaleString()}</small></button>`).join('');
const related=(d.related_performers||[]).map(x=>`<button class="relatedperson" data-related-performer="${esc(x.k)}">
diff --git a/web/index.html b/web/index.html
index 4ad1acf3d..3d99bfdf2 100644
--- a/web/index.html
+++ b/web/index.html
@@ -90,6 +90,11 @@
<symbol id="i-clock" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" /><path d="M12 6v6l4 2" /></symbol>
<symbol id="i-calendar" viewBox="0 0 24 24"><path d="M8 2v3" /><path d="M16 2v3" /><rect x="3" y="3" width="18" height="18" rx="2" /><path d="M3 9h18" /></symbol>
<symbol id="i-external-link" viewBox="0 0 24 24"><path d="M15 3h6v6" /><path d="M10 14 21 3" /><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /></symbol>
+ <!-- 品牌标记。这些不是 Lucide 描边图标,而是填充字形,所以自带 fill/stroke,
+ 不吃通用的 `stroke:currentColor;fill:none`。
+ 只做 X 一个:416 条社媒链接里 372 条(89%)是 x.com/twitter.com,而 X 恰好
+ 会挡掉 favicon 请求——资料页上那个空白白圆就是它。其余主机继续走 favicon。 -->
+ <symbol id="i-brand-x" viewBox="0 0 24 24"><path fill="currentColor" stroke="none" d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></symbol>
<symbol id="i-bookmark-plus" viewBox="0 0 24 24"><path d="M12 7v6" /><path d="M15 10H9" /><path d="M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z" /></symbol>
<symbol id="i-sperm" viewBox="0 0 24 24"><path d="M18.2574 3.04039C16.6079 3.3153 15.3153 4.60785 15.0404 6.25731C14.9261 6.94343 15.1179 7.59015 15.5007 8.08229L15.1947 8.49031C14.8361 8.96852 14.2732 9.24995 13.6754 9.24995H12.8524C10.9372 9.24995 9.58486 11.1262 10.1905 12.9431L10.3037 13.2827C10.5666 14.0715 9.88821 14.8537 9.07014 14.705C7.36157 14.3943 5.83623 15.8176 6.02801 17.5435L6.05171 17.7569C6.12353 18.4033 5.68919 18.9973 5.05144 19.1248L4.35291 19.2645C3.94674 19.3458 3.68333 19.7409 3.76456 20.147C3.8458 20.5532 4.24092 20.8166 4.64709 20.7354L5.34562 20.5957C6.74631 20.3155 7.70028 19.0109 7.54253 17.5912L7.51883 17.3779C7.43795 16.65 8.08124 16.0497 8.80181 16.1808C10.7416 16.5334 12.3502 14.6787 11.7267 12.8083L11.6135 12.4688C11.3317 11.6232 11.9611 10.75 12.8524 10.75H13.6754C14.7453 10.75 15.7528 10.2462 16.3947 9.39031L16.7517 8.9143C17.0623 8.99708 17.3975 9.01704 17.7426 8.95951C19.3921 8.6846 20.6847 7.39205 20.9596 5.7426C21.2244 4.15334 19.8466 2.77552 18.2574 3.04039Z" fill="currentColor"/><path d="M11.0548 3.32416C10.1507 3.47484 9.41308 4.15197 9.17192 5.03625C9.06125 5.44203 9.13468 5.83765 9.32677 6.15771L8.8594 6.85877C8.69647 7.10316 8.42219 7.24995 8.12847 7.24995H7.75C6.64543 7.24995 5.75 8.14538 5.75 9.24995C5.75 9.52609 5.52614 9.74995 5.25 9.74995C4.14543 9.74995 3.25 10.6454 3.25 11.75V12C3.25 12.4142 3.58579 12.75 4 12.75C4.41421 12.75 4.75 12.4142 4.75 12V11.75C4.75 11.4738 4.97386 11.25 5.25 11.25C6.35457 11.25 7.25 10.3545 7.25 9.24995C7.25 8.97381 7.47386 8.74995 7.75 8.74995H8.12847C8.92372 8.74995 9.66635 8.35251 10.1075 7.69082L10.6492 6.87823C10.7526 6.87326 10.8578 6.85692 10.9637 6.82804C11.848 6.58687 12.5251 5.84929 12.6758 4.94518C12.8347 3.9918 12.0081 3.16526 11.0548 3.32416Z" fill="currentColor"/><path d="M18.1471 11.3088C17.2045 11.4659 16.4659 12.2045 16.3088 13.147C16.2724 13.3658 16.2904 13.5775 16.3514 13.7709L15.0321 15.31C14.7928 15.5892 14.4434 15.75 14.0756 15.75C13.1529 15.75 12.2912 16.2111 11.7793 16.9789L11.7373 17.0419C11.4196 17.5185 11.25 18.0785 11.25 18.6513V19C11.25 19.4142 11.5858 19.75 12 19.75C12.4142 19.75 12.75 19.4142 12.75 19V18.6513C12.75 18.3747 12.8319 18.1042 12.9854 17.874L13.0274 17.8109C13.261 17.4605 13.6544 17.25 14.0756 17.25C14.8813 17.25 15.6467 16.8979 16.171 16.2862L17.5255 14.706C17.6318 14.7141 17.7415 14.7097 17.8529 14.6911C18.7955 14.534 19.5341 13.7954 19.6912 12.8529C19.8425 11.9447 19.0552 11.1574 18.1471 11.3088Z" fill="currentColor"/></symbol>
</svg>
diff --git a/web/js/core.js b/web/js/core.js
index 32082d117..386f160dd 100644
--- a/web/js/core.js
+++ b/web/js/core.js
@@ -42,6 +42,17 @@ const SITE_FAVICONS={
const faviconUrl=url=>{try{const parsed=new URL(url),host=parsed.hostname.replace(/^www\./,'');
return SITE_FAVICONS[host]||new URL('/favicon.ico',parsed).href}catch{return ''}};
const faviconFallbackUrl=domain=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(domain)}&sz=64`;
+/* 有品牌标记的主机不取 favicon。
+
+ favicon 是别人服务器上的一张小位图:X 直接挡掉爬取(资料页那个空白白圆就是它),
+ 取到的也多是 16×16,放进 32 px 的圆里必然糊。内联 SVG 没有这两个问题,还省一次
+ 跨站请求。只覆盖真正占量的主机——416 条社媒链接里 372 条是 x.com/twitter.com;
+ 其余继续走 favicon,不为个位数的链接各配一个图标。 */
+const BRAND_ICONS=[[['x.com','twitter.com'],'brand-x']];
+const brandIcon=url=>{try{
+ const host=new URL(url).hostname.replace(/^www\./,'').toLowerCase();
+ return BRAND_ICONS.find(([hosts])=>hosts.some(d=>host===d||host.endsWith('.'+d)))?.[1]||'';
+}catch{return ''}};
const foldName=s=>String(s??'').normalize('NFKC').trim().toLocaleLowerCase();
/* 什么才算一个真时长——只有这一处说了算。
@@ -75,6 +86,7 @@ export {
entityPath,
esc,
SITE_FAVICONS,
+ brandIcon,
faviconUrl,
faviconFallbackUrl,
foldName,