Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 外链摊平的豁免只认资料页那枚圆盘

longmeidaoa9dd9b3d6f08
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 178eea6fa..ea10e4289 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -2059,22 +2059,24 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains(
'.entitylinkicon.brand svg{width:100%;height:100%;stroke:none;filter:none}')
- def test_an_icon_link_keeps_its_pill_whether_the_mark_is_an_img_or_an_svg(self):
- """一句话那种外链才是无边无底的蓝字;带图标的外链是一圈药丸。
+ def test_only_the_profile_link_row_is_exempt_from_the_flat_external_link(self):
+ """一句话那种外链是无边无底的蓝字;资料页那排外链是一圈药丸。
- 判据写成「这条链接里有没有那枚圆盘」,不是「有没有 `<img>`」:社媒标记是内联
- `<svg>`,按后一个判据会被当成文字外链,药丸的边和底被抹平,同一排里只有它们
- 几个没有圈。判据缺席时连带图标的那几枚也会被抹平,所以两条都要钉。
+ 豁免判的是那枚圆盘 `.entitylinkicon`,不是「这条链接里有没有 `<img>`」。社媒标记
+ 是内联 `<svg>`,按后一个判据会被当成文字外链,药丸的边和底被抹平,同一排里只有
+ 它们几个没有圈;而按 `<img>` 豁免又会把别处任何包着图的外链一起放走,那些本来
+ 就该是平的。判据一并消失时整排药丸都被抹平,所以三种写法都要钉。
"""
board = (Path(__file__).resolve().parents[1] / "web/board.css").read_text(encoding="utf-8")
for rule in (
"body a:is(.externallink,[target=_blank])"
- ":not(:has(img,.entitylinkicon)):not(.cardlink){",
+ ":not(:has(.entitylinkicon)):not(.cardlink){",
"body a:is(.externallink,[target=_blank])"
- ":not(:has(img,.entitylinkicon)):not(.cardlink):hover{",
+ ":not(:has(.entitylinkicon)):not(.cardlink):hover{",
):
self.assertIn(rule, board)
for weaker in (":not(:has(img)):not(.cardlink){", ":not(:has(img)):hover{",
+ ":not(:has(img,.entitylinkicon))",
"body a:is(.externallink,[target=_blank]):not(.cardlink){"):
self.assertNotIn(weaker, board)
diff --git a/web/board.css b/web/board.css
index 428fdfa39..4dd54c675 100644
--- a/web/board.css
+++ b/web/board.css
@@ -974,12 +974,13 @@ body :is(.popmenu,.gselectmenu,.cardmenupanel){box-sizing:border-box;padding:10p
body :is(.popmenu,.gselectmenu,.cardmenupanel)>:is(button,[role=option],[role=menuitem]){min-height:36px;padding:8px;gap:8px;border:0;border-radius:10px;background:transparent;color:var(--color-text-secondary);font:var(--board-body);box-shadow:none}
body :is(.popmenu,.gselectmenu,.cardmenupanel)>:is(button,[role=option],[role=menuitem]):is(:hover,:focus-visible,[aria-selected=true]){background:var(--color-background-primary-hover);color:var(--color-text-primary)}
/* 这一条只管「一句话就是一个链接」的那种外链:一行蓝字,没有边、没有底、不占按钮的位置。
- 带图标的外链不在此列——资料页那排社媒标是一圈药丸,边、底和 4px 内边距都是它自己的。
- 排除条件判的是那枚圆盘本身,不是「有没有 `<img>`」:常见社媒的标记是内联 `<svg>`(它们
- 的 favicon 被站点挡着取不到),一枚 `<img>` 都没有,按后一个判据会漏进这条规则里——
- `padding:0` 和 `border:0` 把那圈药丸抹平,同一排社媒标里只有它们几个没有圈。 */
-body a:is(.externallink,[target=_blank]):not(:has(img,.entitylinkicon)):not(.cardlink){display:inline-flex;align-items:center;gap:4px;min-height:20px;padding:0;border:0;border-radius:4px;background:transparent;box-shadow:none;color:var(--tungsten);font-weight:500;text-decoration:none;text-underline-offset:3px}
-body a:is(.externallink,[target=_blank]):not(:has(img,.entitylinkicon)):not(.cardlink):hover{background:transparent;text-decoration:underline;box-shadow:none}.externallink .externalmark{width:18px;height:18px;flex:none}
+ 资料页那排外链不在此列——它是一圈药丸,边、底和 4px 内边距都是它自己的,被这里的
+ `padding:0` 和 `border:0` 抹平之后那一排就只剩十个光秃秃的图标。
+ 排除条件写的是那枚圆盘 `.entitylinkicon` 本身,不写「有没有 `<img>`」:常见社媒的标记
+ 是内联 `<svg>`,一枚 `<img>` 都没有,按后一个判据照样漏进来。只认圆盘还把这条豁免收在
+ 资料页那一排上,别处的外链——包括包着图的——继续按这条走,不因为多一张图就长出个框。 */
+body a:is(.externallink,[target=_blank]):not(:has(.entitylinkicon)):not(.cardlink){display:inline-flex;align-items:center;gap:4px;min-height:20px;padding:0;border:0;border-radius:4px;background:transparent;box-shadow:none;color:var(--tungsten);font-weight:500;text-decoration:none;text-underline-offset:3px}
+body a:is(.externallink,[target=_blank]):not(:has(.entitylinkicon)):not(.cardlink):hover{background:transparent;text-decoration:underline;box-shadow:none}.externallink .externalmark{width:18px;height:18px;flex:none}
.board-link-button{display:inline-flex;align-items:center;justify-content:center;justify-self:start;gap:4px;max-width:100%;padding:0;border:0;border-radius:4px;background:transparent;box-shadow:none;color:var(--tungsten);font:inherit;font-weight:500;text-decoration:none;text-underline-offset:3px;transition:color .15s ease}
.board-link-button:hover{background:transparent;text-decoration:underline;box-shadow:none}
.board-link-button:focus-visible{outline:2px solid var(--tungsten);outline-offset:3px}