Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix: keep entity tag filters in context

Peach local maintenancedf814d710373
diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md
index fbc9e4cef..584c73239 100644
--- a/docs/HANDOFF.md
+++ b/docs/HANDOFF.md
@@ -120,10 +120,10 @@ Claude 的 `.claude/settings.json` 已配置 Stop、StopFailure、SessionEnd hoo
- Stash 调用统一经过 `StashClient`;外部 Scene ID 和来源进入 `media_binding`。
- 规范女优/厂牌/标签/创作者进入 `entity`、`entity_external_ref`、`asset_entity`;扁平 `asset_tag` 和 creator/studio 字段只是兼容投影。
- 详情、筛选、搜索、facets、索引、统计、榜单和相关推荐使用规范关系。
-- 女优、厂牌、创作者、系列名称进入资料页;只有内容标签直接筛选首页。`source_reference` 是私有来源,不开放为下载链接。
+- 女优、厂牌、创作者、系列名称进入资料页;首页内容标签直接筛选首页,实体资料页的标签只筛选当前实体作品,并保留在 `/performers/{name}?tag=...` 等当前资料页 URL。`source_reference` 是私有来源,不开放为下载链接。
- “稍后看”写 `watch_queue`;“喜欢/为什么喜欢”写 profile 级 `asset_preference`。AI 只能把口味说明转成带来源/置信度/复核状态的候选,不能改写用户原文。
- Web 公共路由使用 `/performers/{name}`、`/studios/{name}`、`/creators/{name}`、`/series/{name}`;删除 `/entity/{kind}/{name}`。收起详情或导航离开时必须 pause、清空 `src`、调用 `load()` 并移除 video,不能只隐藏 DOM。
-- “换一批”、统计、沉浸、全部女优、全部标签是动作/目的地,不显示为持续筛选状态。`看过`/`没看过` 只保留为紧凑状态 chip。
+- “换一批”、统计、沉浸、全部女优、全部标签是动作/目的地,不显示为持续筛选状态。顶部只保留“没看过、稍后看、已标记”等需要主动进入的紧凑状态;“看过”和“疑似广告”不占首页快捷位。
- 长卡连续 hover 5 秒才放大并显示 seek;短卡立即提供“稍后看”。实体文字链接必须消费点击,不能冒泡为展开视频。
- 卡片身份女优优先:先使用 `performer_entities` 头像和链接,再回退到创作者/厂牌代表图。
- 喜欢与原因属于同一 profile 偏好;非空原因隐含喜欢,但原文不能直接冒充推荐特征。
diff --git a/docs/STATUS.md b/docs/STATUS.md
index b2ede2a23..ebfec7cf6 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -43,8 +43,9 @@
- 详情身份按名称去重,标签可逐项隐藏或手动添加;隐藏只写 profile 覆盖,不破坏原始来源断言。高潮按钮使用 Health Icons 的 CC0 领域图标和独立暖粉强调色。
- 已完成首轮界面文案审计:删除标题复述、实现状态说明、随机示例占位符和模型自我声明;删除保护、隐私边界、流量成本及陌生状态说明继续保留。
- 侧栏、抽屉和粘性栏使用 Beeg 当前源码实测的透明层与 blur 数值;页面背景不再是纯黑,侧栏不再是纯灰。本轮没有为了装饰引入动画库,后续动效必须先复用审计并只表达状态/连续性。
-- 详情中的本地来源图标已补齐 `stroke: currentColor` 和 `fill: none`,不再因 SVG 默认黑色而不可见。标签添加使用弹窗完成搜索、最近使用、全部标签、已选状态和键盘操作;侧栏入口简化为“艺人”“标签”,并删除多余分隔线。
+- 详情中的本地来源图标已补齐 `stroke: currentColor` 和 `fill: none`,不再因 SVG 默认黑色而不可见。标签添加使用弹窗完成搜索、最近使用、全部标签、已选状态和键盘操作;侧栏入口简化为“艺人”“标签”,并删除装饰性分隔线。
- 首页创作者头像已移除常驻黑框,只在 hover/选中时显示状态描边。女优/厂牌/创作者/系列资料页打开后隐藏首页人物、厂牌和筛选栏;资料区取消巨型外框,桌面头像为 160 px,并在资料下展示真实标签与关联艺人。厂牌资料优先使用 Logo,只有缺失时才使用实体图,不再用代表作品截图冒充厂牌头像。
+- 实体资料页标签只筛选当前实体作品,不再跳回首页做全局筛选;当前标签写入资料页查询参数,便于返回和分享。首页状态标签已精简为“全部、没看过、稍后看、已标记”,与右侧内容标签之间恢复语义分隔线。搜索框显示随机推荐关键词,不加“试试:”;空输入聚焦后按 Enter 会直接搜索当前推荐词。
## 数据与批处理
diff --git a/src/peach/__init__.py b/src/peach/__init__.py
index 1c803b89e..6ae9265fb 100644
--- a/src/peach/__init__.py
+++ b/src/peach/__init__.py
@@ -1,3 +1,3 @@
"""Peach application package."""
-__version__ = "0.5.1"
+__version__ = "0.5.2"
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index e5cb9ee61..b488d1dd0 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -80,6 +80,27 @@ class WebUiSourceTests(unittest.TestCase):
self.assertIn('class="relatedpeople"', self.page)
self.assertIn("data-related-performer", self.page)
+ def test_entity_tags_filter_inside_the_current_entity_page(self):
+ self.assertIn("if(entityTag)p.set('tag',entityTag)", self.page)
+ self.assertIn("openEntity(kind,name,true,next)", self.page)
+ self.assertIn("wireCards($('#index'),undefined,tag=>openEntity(kind,name,true", self.page)
+ self.assertNotIn(
+ "document.body.classList.remove('entity-open');$('#index').hidden=true;state.tag=b.dataset.entityTag",
+ self.page,
+ )
+
+ def test_status_tags_are_separated_and_nonessential_states_are_hidden(self):
+ self.assertIn(".sep{flex:none;width:1px;height:19px", self.page)
+ self.assertIn("{k:'later',label:'稍后看'},{k:'flagged',label:'已标记'}", self.page)
+ self.assertNotIn("{k:'played',label:'看过'}", self.page)
+ self.assertNotIn("{k:'ads',label:'疑似广告'}", self.page)
+
+ def test_search_placeholder_is_an_actionable_recommendation(self):
+ self.assertIn("const SEARCH_HINTS=['Prestige','FC2','Sakura Misaki','丝袜','足交','ABW 番号']", self.page)
+ self.assertIn("$('#q').dataset.suggestion=searchSuggestion", self.page)
+ self.assertIn("runSearch(true)", self.page)
+ self.assertNotIn("试试:", self.page)
+
def test_tags_page_has_cloud_and_alphabet_modes(self):
self.assertIn('data-tag-view="cloud"', self.page)
self.assertIn('data-tag-view="alphabet"', self.page)
diff --git a/web/index.html b/web/index.html
index 8fd05bb3a..b0da53029 100644
--- a/web/index.html
+++ b/web/index.html
@@ -145,7 +145,7 @@ button,input,textarea{font:inherit;color:inherit}
.pill:hover{border-color:color-mix(in srgb,var(--ink) 28%,transparent);color:var(--ink);background:var(--overlay-5)}
.pill[aria-pressed="true"]{background:var(--ink-2);color:var(--ground);border-color:var(--ink-2)}
.pill.act{border-color:var(--tungsten);color:var(--tungsten)}
-.sep{display:none}
+.sep{flex:none;width:1px;height:19px;background:var(--line);margin:0 3px}
/* 向下滚时把标签条收起来,别和顶栏一起压住内容;向上滚立刻带回来 */
.tagbar.tuck{transform:translateY(-140%);opacity:0;pointer-events:none}
@@ -230,7 +230,7 @@ button,input,textarea{font:inherit;color:inherit}
.entitymeta{display:grid;gap:22px;margin:0 0 28px}.entitymeta h3,.entitysection h3{font-size:13px;letter-spacing:.08em;color:var(--muted);margin:0 0 12px}
.entitytags{display:flex;flex-wrap:wrap;gap:7px}.entitytags button{height:34px;padding:0 14px;border-radius:999px;
border:1px solid var(--border-15);background:transparent;color:var(--ink-2);cursor:pointer}
-.entitytags button:hover{background:var(--overlay-5);color:var(--ink)}.entitytags small{color:var(--muted);margin-left:4px}
+.entitytags button:hover{background:var(--overlay-5);color:var(--ink)}.entitytags button[aria-pressed="true"]{background:var(--ink-2);border-color:var(--ink-2);color:var(--ground)}.entitytags small{color:var(--muted);margin-left:4px}
.relatedpeople{display:flex;gap:14px;overflow-x:auto;padding-bottom:4px;scrollbar-width:none}
.relatedpeople::-webkit-scrollbar{display:none}.relatedperson{flex:0 0 78px;border:0;background:transparent;color:inherit;
padding:0;cursor:pointer;text-align:center}.relatedperson .ring{display:grid;place-items:center;width:64px;height:64px;
@@ -663,7 +663,7 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
<button class="ib" id="filterBtn" title="筛选"><svg viewBox="0 0 24 24"><use href="#i-sliders-horizontal"/></svg></button>
<a class="brand" href="#" id="brandHome"><svg class="mark" viewBox="0 0 32 32" aria-hidden="true"><defs><linearGradient id="pg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#FF9A76"/><stop offset="1" stop-color="#F2557B"/></linearGradient></defs><path d="M16 29c-6.1 0-10.4-3.9-10.4-9.2 0-4.6 3-8.2 7-8.2 1.5 0 2.6.5 3.4 1.2.8-.7 1.9-1.2 3.4-1.2 4 0 7 3.6 7 8.2C26.4 25.1 22.1 29 16 29z" fill="url(#pg)"/><path d="M16 13.2V28" stroke="#0B0B0D" stroke-width="1.1" opacity=".28" stroke-linecap="round"/><path d="M17.2 11.4c.6-3 3-4.9 6-5.1-.2 3-2.4 5-6 5.1z" fill="#5FB95F"/><path d="M16 11.6c0-2 .5-3.6 1.6-4.8" stroke="#8A5A3B" stroke-width="1.5" stroke-linecap="round" fill="none"/></svg><h1 class="disp">Peach</h1><span class="sub mono">蜜桃</span></a>
<div class="search"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-search"/></svg>
- <input id="q" type="search" placeholder="搜索名字、创作者或番号…" autocomplete="off"></div>
+ <input id="q" type="search" placeholder="FC2" autocomplete="off"></div>
<button class="ib" id="immerseBtn" title="沉浸模式 · 随机连播"><svg viewBox="0 0 24 24"><use href="#i-play"/></svg></button>
<button class="ib" id="searchBtn" title="搜索"><svg viewBox="0 0 24 24"><use href="#i-search"/></svg></button>
@@ -885,7 +885,7 @@ function cardHtml(it,cls){
<span class="flags">${fl}</span></div>
${(perf||tgs)?`<div class="ctags">${perf}${tgs}</div>`:''}</div></div></article>`;
}
-function wireCards(root,onClick){
+function wireCards(root,onClick,onTag){
root.querySelectorAll('[data-id]').forEach(el=>{
if(el.dataset.wired)return; el.dataset.wired='1';
const it=CACHE[el.dataset.id];
@@ -902,7 +902,8 @@ function wireCards(root,onClick){
const ent=e.target.closest('[data-entity-kind]');
if(ent){e.stopPropagation();openEntity(ent.dataset.entityKind,ent.dataset.entityName);return}
const tg=e.target.closest('.tg');
- if(tg){e.stopPropagation();state.tag=tg.dataset.tag;buildBars();load(true);
+ if(tg){e.stopPropagation();if(onTag){onTag(tg.dataset.tag);return}
+ state.tag=tg.dataset.tag;buildBars();load(true);
window.scrollTo({top:0,behavior:'smooth'});return}
if(e.shiftKey||e.ctrlKey||e.metaKey||selectMode){e.preventDefault();toggleSelection(it.id,e.shiftKey);return}
(onClick||openItem)(+el.dataset.id);
@@ -945,8 +946,8 @@ async function buildBars(){
img.addEventListener('load',()=>{if(img.naturalWidth<32)fallback()},{once:true});
});
- const views=[{k:'',label:'全部'},{k:'fresh',label:'没看过'},{k:'played',label:'看过'},
- {k:'later',label:'稍后看'},{k:'flagged',label:'已标记'},{k:'ads',label:'疑似广告'}];
+ const views=[{k:'',label:'全部'},{k:'fresh',label:'没看过'},
+ {k:'later',label:'稍后看'},{k:'flagged',label:'已标记'}];
$('#tagbar').innerHTML=
views.map(v=>`<button class="pill" data-state="${v.k}" aria-pressed="${state.state===v.k}">${v.label}</button>`).join('')
+`<span class="sep"></span>`
@@ -1176,12 +1177,16 @@ async function openIndex(kind,q,push=true){
$('#index').hidden=true;state.tag=b.dataset.k;route('/?tag='+encodeURIComponent(state.tag));buildBars();load(true)});
}
-async function openEntity(kind,name,push=true){
- if(push)route(entityPath(kind,name));
+async function openEntity(kind,name,push=true,requestedTag){
+ const entityTag=requestedTag===undefined
+ ? (push?'':new URLSearchParams(location.search).get('tag')||'')
+ : requestedTag;
+ if(push)route(entityPath(kind,name)+(entityTag?'?tag='+encodeURIComponent(entityTag):''));
disposeStage(false);
const d=await api(`/api/entity?kind=${encodeURIComponent(kind)}&name=${encodeURIComponent(name)}`);
if(d.error)return;
const p=new URLSearchParams();p.set(kind,name);p.set('limit','120');p.set('sort','new');
+ if(entityTag)p.set('tag',entityTag);
const items=await api('/api/items?'+p);cache(items.items);
document.body.classList.add('entity-open');
$('#index').hidden=false;$('#grid').innerHTML='';$('#count').textContent='';
@@ -1196,7 +1201,7 @@ async function openEntity(kind,name,push=true){
? `<a href="${esc(x.url)}" target="_blank" rel="noreferrer">${esc(x.label)} ↗</a>`
: `<span class="private" title="私人馆藏来源记录,不直接打开下载页">来源 · ${esc(x.label||x.hostname||'已记录')}</span>`).join('');
const terms=(d.search_terms||[]).map(x=>`<code>${esc(x.term)}</code>`).join('');
- const tags=(d.tags||[]).map(x=>`<button data-entity-tag="${esc(x.k)}">${esc(x.k)}<small>${x.n.toLocaleString()}</small></button>`).join('');
+ const tags=(d.tags||[]).map(x=>`<button data-entity-tag="${esc(x.k)}" aria-pressed="${entityTag===x.k}">${esc(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)}">
<span class="ring"><span>${esc(x.k.slice(0,1))}</span><img src="/entity-image?kind=performer&id=${x.id}" alt="" loading="lazy"
onerror="${x.rep?`this.onerror=null;this.src='/avatar?id=${x.rep}'`:`this.remove()`}"></span>
@@ -1213,15 +1218,15 @@ async function openEntity(kind,name,push=true){
${tags?`<section><h3>相关标签</h3><div class="entitytags">${tags}</div></section>`:''}
${related?`<section><h3>关联艺人</h3><div class="relatedpeople">${related}</div></section>`:''}
</div>`:''}
- <div class="entitysection"><h3>${labels[kind]||kind}的馆藏作品 · ${items.total.toLocaleString()}</h3>
+ <div class="entitysection"><h3>${labels[kind]||kind}的馆藏作品 · ${items.total.toLocaleString()}${entityTag?` · ${esc(entityTag)}`:''}</h3>
<div class="grid">${items.items.map(it=>cardHtml(it)).join('')}</div></div>`;
$('#iClose').onclick=()=>{route('/');document.body.classList.remove('entity-open');$('#index').hidden=true;load(true)};
$('#index').querySelectorAll('[data-entity-tag]').forEach(b=>b.onclick=()=>{
- document.body.classList.remove('entity-open');$('#index').hidden=true;state.tag=b.dataset.entityTag;
- route('/?tag='+encodeURIComponent(state.tag));buildBars();load(true)});
+ const next=b.dataset.entityTag===entityTag?'':b.dataset.entityTag;
+ openEntity(kind,name,true,next)});
$('#index').querySelectorAll('[data-related-performer]').forEach(b=>b.onclick=()=>
openEntity('performer',b.dataset.relatedPerformer));
- wireCards($('#index'));
+ wireCards($('#index'),undefined,tag=>openEntity(kind,name,true,tag===entityTag?'':tag));
window.scrollTo({top:0,behavior:'smooth'});
}
@@ -1328,9 +1333,14 @@ const loadObserver=new IntersectionObserver(entries=>{
offset+=60;load(false)}
},{rootMargin:'320px'});
loadObserver.observe($('#loadSentinel'));
-const runSearch=()=>{state.q=$('#q').value.trim();route(state.q?'/?q='+encodeURIComponent(state.q):'/',true);load(true)};
+const SEARCH_HINTS=['Prestige','FC2','Sakura Misaki','丝袜','足交','ABW 番号'];
+const searchSuggestion=SEARCH_HINTS[Math.floor(Math.random()*SEARCH_HINTS.length)];
+$('#q').dataset.suggestion=searchSuggestion;$('#q').placeholder=searchSuggestion;
+const runSearch=(useSuggestion=false)=>{let query=$('#q').value.trim();
+ if(useSuggestion&&!query){query=$('#q').dataset.suggestion||'';$('#q').value=query}
+ state.q=query;route(state.q?'/?q='+encodeURIComponent(state.q):'/',true);load(true)};
let qt;$('#q').oninput=()=>{clearTimeout(qt);qt=setTimeout(runSearch,320)};
-$('#q').onkeydown=e=>{if(e.key==='Enter'){e.preventDefault();clearTimeout(qt);runSearch();$('#q').blur()}};
+$('#q').onkeydown=e=>{if(e.key==='Enter'){e.preventDefault();clearTimeout(qt);runSearch(true);$('#q').blur()}};
async function loadShorts(){
if(state.orient==='竖屏'||state.state==='ads'){$('#shortsSec').hidden=true;return}