feat: overhaul UI styling, improve templates, enhance services and tests

This commit is contained in:
2026-06-06 00:38:56 +08:00
parent f7f1a4c0cb
commit 904eec392e
38 changed files with 1471 additions and 795 deletions
+161 -77
View File
@@ -1,8 +1,5 @@
{% extends "base.html" %}
{% block title %}管理日志 — HF Daily Papers{% endblock %}
{% block content %}
{% extends "base.html" %} {% block title %}管理日志 — HF Daily Papers{% endblock
%} {% block content %}
<div class="admin-logs-page">
<h1 class="page-heading">📋 管理日志</h1>
@@ -34,21 +31,31 @@
{% for log in crawl_logs %}
<tr>
<td>{{ log.id }}</td>
<td><span class="task-badge task-{{ log.task }}">{{ log.task }}</span></td>
<td>
<span class="task-badge task-{{ log.task }}">{{ log.task }}</span>
</td>
<td>
<span class="status-badge status-{{ log.status }}">
{% if log.status == 'success' %}✓ 成功
{% elif log.status == 'running' %}⟳ 运行中
{% elif log.status == 'failed' %}✗ 失败
{% else %}{{ log.status }}{% endif %}
{% if log.status == 'success' %}✓ 成功 {% elif log.status ==
'running' %}⟳ 运行中 {% elif log.status == 'failed' %}✗ 失败 {%
else %}{{ log.status }}{% endif %}
</span>
</td>
<td>{{ log.date or '-' }}</td>
<td>{{ log.papers_found or 0 }}</td>
<td>{{ log.papers_new or 0 }}</td>
<td class="time-cell">{{ log.started_at.strftime('%m-%d %H:%M') if log.started_at else '-' }}</td>
<td class="time-cell">{{ log.completed_at.strftime('%m-%d %H:%M') if log.completed_at else '-' }}</td>
<td class="error-cell" title="{{ log.error or '' }}">{{ log.error[:80] + '...' if log.error and log.error|length > 80 else (log.error or '-') }}</td>
<td class="time-cell">
{{ log.started_at.strftime('%m-%d %H:%M') if log.started_at else
'-' }}
</td>
<td class="time-cell">
{{ log.completed_at.strftime('%m-%d %H:%M') if log.completed_at
else '-' }}
</td>
<td class="error-cell" title="{{ log.error or '' }}">
{{ log.error[:80] + '...' if log.error and log.error|length > 80
else (log.error or '-') }}
</td>
</tr>
{% endfor %}
</tbody>
@@ -90,15 +97,23 @@
<td>{{ job.paper_count or 0 }}</td>
<td>
<span class="status-badge status-{{ job.status }}">
{% if job.status == 'success' %}✓ 成功
{% elif job.status == 'running' %}⟳ 运行中
{% elif job.status == 'failed' %}✗ 失败
{% else %}{{ job.status }}{% endif %}
{% if job.status == 'success' %}✓ 成功 {% elif job.status ==
'running' %}⟳ 运行中 {% elif job.status == 'failed' %}✗ 失败 {%
else %}{{ job.status }}{% endif %}
</span>
</td>
<td class="time-cell">{{ job.started_at.strftime('%m-%d %H:%M') if job.started_at else '-' }}</td>
<td class="time-cell">{{ job.completed_at.strftime('%m-%d %H:%M') if job.completed_at else '-' }}</td>
<td class="error-cell" title="{{ job.error or '' }}">{{ job.error[:80] + '...' if job.error and job.error|length > 80 else (job.error or '-') }}</td>
<td class="time-cell">
{{ job.started_at.strftime('%m-%d %H:%M') if job.started_at else
'-' }}
</td>
<td class="time-cell">
{{ job.completed_at.strftime('%m-%d %H:%M') if job.completed_at
else '-' }}
</td>
<td class="error-cell" title="{{ job.error or '' }}">
{{ job.error[:80] + '...' if job.error and job.error|length > 80
else (job.error or '-') }}
</td>
</tr>
{% endfor %}
</tbody>
@@ -116,16 +131,24 @@
<div class="admin-actions">
<h2 class="admin-actions-title">管理操作</h2>
<div class="admin-action-buttons">
<button class="admin-action-btn" onclick="adminAction('crawl')">🔄 抓取今天</button>
<button class="admin-action-btn" onclick="adminAction('summarize')">📝 批量总结</button>
<button class="admin-action-btn" onclick="adminAction('cleanup')">🧹 清理临时文件</button>
<button class="admin-action-btn" onclick="adminAction('crawl')">
🔄 抓取今天
</button>
<button class="admin-action-btn" onclick="adminAction('summarize')">
📝 批量总结
</button>
<button class="admin-action-btn" onclick="adminAction('cleanup')">
🧹 清理临时文件
</button>
</div>
</div>
</div>
<style>
/* ── Admin Logs ────────────────────────────────────────────────── */
.admin-logs-page { max-width: 100%; }
.admin-logs-page {
max-width: 100%;
}
.admin-tabs {
display: flex;
@@ -144,22 +167,32 @@
cursor: pointer;
border-bottom: 2px solid transparent;
margin-bottom: -2px;
transition: color 0.2s, border-color 0.2s;
transition:
color 0.2s,
border-color 0.2s;
font-family: var(--font-sans);
}
.admin-tab:hover { color: var(--accent); }
.admin-tab:hover {
color: var(--accent);
}
.admin-tab.active {
color: var(--accent);
border-bottom-color: var(--accent);
}
.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }
.admin-tab-content {
display: none;
}
.admin-tab-content.active {
display: block;
}
/* ── Table ─────────────────────────────────────────────────────── */
.admin-table-wrap { overflow-x: auto; }
.admin-table-wrap {
overflow-x: auto;
}
.admin-table {
width: 100%;
@@ -187,14 +220,29 @@
vertical-align: middle;
}
.admin-table tbody tr:hover { background: var(--bg); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover {
background: var(--bg);
}
.admin-table tbody tr:last-child td {
border-bottom: none;
}
.time-cell { white-space: nowrap; color: var(--ink-light); }
.error-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c62828; font-size: 0.8rem; }
.time-cell {
white-space: nowrap;
color: var(--ink-light);
}
.error-cell {
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #c62828;
font-size: 0.8rem;
}
/* ── Badges ────────────────────────────────────────────────────── */
.task-badge, .status-badge {
.task-badge,
.status-badge {
display: inline-block;
padding: 2px 8px;
border-radius: 3px;
@@ -202,15 +250,39 @@
font-weight: 500;
}
.task-crawl { background: #e3f2fd; color: #1565c0; }
.task-summarize { background: #f3e5f5; color: #7b1fa2; }
.task-cleanup { background: #e8f5e9; color: #2e7d32; }
.task-delete { background: #fce4ec; color: #c62828; }
.task-scheduler { background: #fff3e0; color: #e65100; }
.task-crawl {
background: #e3f2fd;
color: #1565c0;
}
.task-summarize {
background: #f3e5f5;
color: #7b1fa2;
}
.task-cleanup {
background: #e8f5e9;
color: #2e7d32;
}
.task-delete {
background: #fce4ec;
color: #c62828;
}
.task-scheduler {
background: #fff3e0;
color: #e65100;
}
.status-success { background: #e8f5e9; color: #388e3c; }
.status-running { background: #e3f2fd; color: #1976d2; }
.status-failed { background: #fce4ec; color: #c62828; }
.status-success {
background: #e8f5e9;
color: #388e3c;
}
.status-running {
background: #e3f2fd;
color: #1976d2;
}
.status-failed {
background: #fce4ec;
color: #c62828;
}
/* ── Admin Actions ─────────────────────────────────────────────── */
.admin-actions {
@@ -254,46 +326,58 @@
/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 640px) {
.admin-table { font-size: 0.8rem; }
.admin-table th, .admin-table td { padding: 6px 8px; }
.admin-action-buttons { flex-direction: column; }
.admin-action-btn { width: 100%; text-align: center; }
.admin-table {
font-size: 0.8rem;
}
.admin-table th,
.admin-table td {
padding: 6px 8px;
}
.admin-action-buttons {
flex-direction: column;
}
.admin-action-btn {
width: 100%;
text-align: center;
}
}
</style>
{% endblock %}
{% block scripts %}
{% endblock %} {% block scripts %}
<script>
function adminAction(action) {
const token = prompt('请输入 Admin Token:');
if (!token) return;
function adminAction(action) {
const token = prompt("请输入 Admin Token:");
if (!token) return;
const url = '/admin/' + action;
fetch(url, {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json',
},
})
.then(r => r.json())
.then(data => {
alert(JSON.stringify(data, null, 2));
location.reload();
})
.catch(err => {
alert('请求失败: ' + err.message);
});
}
const url = "/admin/" + action;
fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + token,
"Content-Type": "application/json",
},
})
.then((r) => r.json())
.then((data) => {
alert(JSON.stringify(data, null, 2));
location.reload();
})
.catch((err) => {
alert("请求失败: " + err.message);
});
}
// Tab 切换
document.querySelectorAll('.admin-tab').forEach(tab => {
tab.addEventListener('click', () => {
document.querySelectorAll('.admin-tab').forEach(t => t.classList.remove('active'));
document.querySelectorAll('.admin-tab-content').forEach(c => c.classList.remove('active'));
tab.classList.add('active');
document.getElementById(tab.dataset.tab).classList.add('active');
// Tab 切换
document.querySelectorAll(".admin-tab").forEach((tab) => {
tab.addEventListener("click", () => {
document
.querySelectorAll(".admin-tab")
.forEach((t) => t.classList.remove("active"));
document
.querySelectorAll(".admin-tab-content")
.forEach((c) => c.classList.remove("active"));
tab.classList.add("active");
document.getElementById(tab.dataset.tab).classList.add("active");
});
});
});
</script>
{% endblock %}
+39 -33
View File
@@ -1,38 +1,44 @@
<!DOCTYPE html>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}HF Daily Papers{% endblock %}</title>
<link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
<header class="site-header">
<nav class="nav-bar">
<a href="/" class="nav-brand">📚 HF Daily Papers</a>
<form class="nav-search" action="/search" method="get">
<input type="text" name="q" placeholder="搜索..." class="nav-search-input">
</form>
<div class="nav-links">
<a href="/day/{{ today if today else '' }}">今日</a>
<a href="/search">搜索</a>
<a href="/trends">趋势</a>
<a href="/reading-list">阅读列表</a>
<a href="/admin/logs">管理</a>
</div>
</nav>
</header>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{% block title %}HF Daily Papers{% endblock %}</title>
<link rel="stylesheet" href="/static/css/style.css" />
</head>
<body>
<header class="site-header">
<nav class="nav-bar">
<a href="/" class="nav-brand">📚 HF Daily Papers</a>
<form class="nav-search" action="/search" method="get">
<input
type="text"
name="q"
placeholder="搜索..."
class="nav-search-input"
/>
</form>
<div class="nav-links">
<a href="/day/{{ today if today else '' }}">今日</a>
<a href="/search">搜索</a>
<a href="/trends">趋势</a>
<a href="/reading-list">阅读列表</a>
<a href="/admin/logs">管理</a>
</div>
</nav>
</header>
<main class="container">
{% block content %}{% endblock %}
</main>
<main class="container">{% block content %}{% endblock %}</main>
<footer class="site-footer">
<p>HF Daily Papers — 中文论文导览站 · 数据来源于 <a href="https://huggingface.co/papers" target="_blank">HuggingFace</a></p>
</footer>
<footer class="site-footer">
<p>
HF Daily Papers — 中文论文导览站 · 数据来源于
<a href="https://huggingface.co/papers" target="_blank">HuggingFace</a>
</p>
</footer>
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
<script src="/static/js/app.js"></script>
{% block scripts %}{% endblock %}
</body>
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
<script src="/static/js/app.js"></script>
{% block scripts %}{% endblock %}
</body>
</html>
+18 -20
View File
@@ -1,16 +1,17 @@
{% extends "base.html" %}
{% block title %}{{ page_title }} — HF Daily Papers{% endblock %}
{% block content %}
{% extends "base.html" %} {% block title %}{{ page_title }} — HF Daily Papers{%
endblock %} {% block content %}
<section class="compare-page">
<h1>论文对比</h1>
{# ID 输入表单 #}
<form class="search-form" method="get" action="/compare">
<input type="text" name="ids" value="{{ ids_param }}"
placeholder="输入 arXiv ID,逗号分隔(最多 5 篇),如 2401.12345,2401.67890"
class="search-input">
<input
type="text"
name="ids"
value="{{ ids_param }}"
placeholder="输入 arXiv ID,逗号分隔(最多 5 篇),如 2401.12345,2401.67890"
class="search-input"
/>
<button type="submit" class="search-btn">对比</button>
</form>
@@ -18,9 +19,7 @@
<div class="empty-state">
<p>{{ error }}</p>
</div>
{% endif %}
{% if papers %}
{% endif %} {% if papers %}
<div class="compare-table-wrapper">
<table class="compare-table">
<thead>
@@ -29,8 +28,8 @@
{% for paper in papers %}
<th>
<a href="/paper/{{ paper.arxiv_id }}">{{ paper.arxiv_id }}</a>
<br>
<small style="color: var(--ink-light);">
<br />
<small style="color: var(--ink-light)">
{{ paper.upvotes }} 👍 · {{ paper.paper_date }}
</small>
</th>
@@ -42,7 +41,9 @@
<tr>
<td class="field-label">作者</td>
{% for paper in papers %}
<td class="paper-col">{{ paper.authors|map(attribute='name')|join(', ') }}</td>
<td class="paper-col">
{{ paper.authors|map(attribute='name')|join(', ') }}
</td>
{% endfor %}
</tr>
@@ -58,16 +59,13 @@
{% endfor %}
</tr>
{# 结构化对比字段 #}
{% for row in rows %}
{# 结构化对比字段 #} {% for row in rows %}
<tr>
<td class="field-label">{{ row.label }}</td>
{% for cell in row.cells %}
<td class="paper-col">
{% if cell %}
{{ cell }}
{% else %}
<span class="no-summary">暂无总结</span>
{% if cell %} {{ cell }} {% else %}
<span class="no-summary">暂无总结</span>
{% endif %}
</td>
{% endfor %}
+98 -95
View File
@@ -1,140 +1,141 @@
{% extends "base.html" %}
{% block title %}{{ page_title }} — HF Daily Papers{% endblock %}
{% block content %}
{% extends "base.html" %} {% block title %}{{ page_title }} — HF Daily Papers{%
endblock %} {% block content %}
<article class="paper-detail">
<a href="/day/{{ paper.paper_date.isoformat() }}" class="back-link">← 返回 {{ paper.paper_date.isoformat() }}</a>
<a href="/day/{{ paper.paper_date.isoformat() }}" class="back-link"
>← 返回 {{ paper.paper_date.isoformat() }}</a
>
{# 标题 #}
<h1 class="detail-title">
{{ paper.title_zh or paper.title_en }}
{% if paper.title_zh and paper.title_en != paper.title_zh %}
{{ paper.title_zh or paper.title_en }} {% if paper.title_zh and
paper.title_en != paper.title_zh %}
<small class="title-en">{{ paper.title_en }}</small>
{% endif %}
</h1>
{# 元信息 #}
<div class="detail-meta">
<span class="detail-authors">{{ paper.authors|map(attribute='name')|join(', ') }}</span>
<span class="detail-date">📅 {{ paper.published_at or paper.paper_date }}</span>
<span class="detail-authors"
>{{ paper.authors|map(attribute='name')|join(', ') }}</span
>
<span class="detail-date"
>📅 {{ paper.published_at or paper.paper_date }}</span
>
<span class="detail-upvotes">👍 {{ paper.upvotes }}</span>
</div>
{# 标签 #}
{% if paper.tags %}
{# 标签 #} {% if paper.tags %}
<div class="detail-tags">
{% for tag in paper.tags %}
<span class="tag">{{ tag.tag }}</span>
{% endfor %}
</div>
{% endif %}
{# 链接 #}
{% endif %} {# 链接 #}
<div class="detail-links">
{% if paper.arxiv_url %}<a href="{{ paper.arxiv_url }}" target="_blank" class="ext-link">arXiv</a>{% endif %}
{% if paper.hf_url %}<a href="{{ paper.hf_url }}" target="_blank" class="ext-link">HuggingFace</a>{% endif %}
{% if paper.pdf_url %}<a href="{{ paper.pdf_url }}" target="_blank" class="ext-link">PDF</a>{% endif %}
{% if paper.arxiv_url %}<a
href="{{ paper.arxiv_url }}"
target="_blank"
class="ext-link"
>arXiv</a
>{% endif %} {% if paper.hf_url %}<a
href="{{ paper.hf_url }}"
target="_blank"
class="ext-link"
>HuggingFace</a
>{% endif %} {% if paper.pdf_url %}<a
href="{{ paper.pdf_url }}"
target="_blank"
class="ext-link"
>PDF</a
>{% endif %}
</div>
{# 总结内容 — 按状态降级 #}
{% if summary_state == 'done' and paper.summary %}
{% if paper.summary_status and paper.summary_status.quality == 'low' %}
<div class="quality-warning">⚠️ AI 总结质量较低,仅供参考</div>
{% elif paper.summary_status and paper.summary_status.quality == 'degraded' %}
<div class="quality-warning">📝 总结部分字段不完整</div>
{% endif %}
{% if paper.summary.one_line %}
<section class="summary-section">
<h2>一句话摘要</h2>
<p class="one-line">{{ paper.summary.one_line }}</p>
</section>
{% endif %}
{% if paper.summary.difficulty %}
<section class="summary-section">
<h2>难度</h2>
<p>{{ paper.summary.difficulty }}</p>
</section>
{% endif %}
{# 总结内容 — 按状态降级 #} {% if summary_state == 'done' and paper.summary %}
{% if paper.summary_status and paper.summary_status.quality == 'low' %}
<div class="quality-warning">⚠️ AI 总结质量较低,仅供参考</div>
{% elif paper.summary_status and paper.summary_status.quality == 'degraded' %}
<div class="quality-warning">📝 总结部分字段不完整</div>
{% endif %} {% if paper.summary.one_line %}
<section class="summary-section">
<h2>一句话摘要</h2>
<p class="one-line">{{ paper.summary.one_line }}</p>
</section>
{% endif %} {% if paper.summary.difficulty %}
<section class="summary-section">
<h2>难度</h2>
<p>{{ paper.summary.difficulty }}</p>
</section>
{% endif %} {% if paper.summary.motivation_problem %}
<section class="summary-section">
<h2>研究动机</h2>
{% if paper.summary.motivation_problem %}
<section class="summary-section">
<h2>研究动机</h2>
{% if paper.summary.motivation_problem %}<p><strong>问题</strong>{{ paper.summary.motivation_problem }}</p>{% endif %}
{% if paper.summary.motivation_goal %}<p><strong>目标:</strong>{{ paper.summary.motivation_goal }}</p>{% endif %}
{% if paper.summary.motivation_gap %}<p><strong>差距:</strong>{{ paper.summary.motivation_gap }}</p>{% endif %}
</section>
<p><strong>问题:</strong>{{ paper.summary.motivation_problem }}</p>
{% endif %} {% if paper.summary.motivation_goal %}
<p><strong>目标</strong>{{ paper.summary.motivation_goal }}</p>
{% endif %} {% if paper.summary.motivation_gap %}
<p><strong>差距:</strong>{{ paper.summary.motivation_gap }}</p>
{% endif %}
{% if paper.summary.method_key_idea %}
<section class="summary-section">
<h2>核心方法</h2>
{% if paper.summary.method_overview %}<p>{{ paper.summary.method_overview }}</p>{% endif %}
<p><strong>关键思路:</strong>{{ paper.summary.method_key_idea }}</p>
{% if paper.summary.method_novelty %}<p><strong>新颖性:</strong>{{ paper.summary.method_novelty }}</p>{% endif %}
</section>
</section>
{% endif %} {% if paper.summary.method_key_idea %}
<section class="summary-section">
<h2>核心方法</h2>
{% if paper.summary.method_overview %}
<p>{{ paper.summary.method_overview }}</p>
{% endif %}
{% if paper.summary.results_main_json %}
<section class="summary-section">
<h2>实验结果</h2>
<p>{{ paper.summary.results_main_json }}</p>
</section>
<p><strong>关键思路:</strong>{{ paper.summary.method_key_idea }}</p>
{% if paper.summary.method_novelty %}
<p><strong>新颖性:</strong>{{ paper.summary.method_novelty }}</p>
{% endif %}
{% if paper.summary.limitations_json %}
<section class="summary-section">
<h2>局限与改进</h2>
<p>{{ paper.summary.limitations_json }}</p>
</section>
{% endif %}
{% elif summary_state == 'processing' %}
<div class="summary-placeholder processing">
<p>🔄 正在生成 AI 总结,请稍后刷新页面</p>
</div>
</section>
{% endif %} {% if paper.summary.results_main_json %}
<section class="summary-section">
<h2>实验结果</h2>
<p>{{ paper.summary.results_main_json }}</p>
</section>
{% endif %} {% if paper.summary.limitations_json %}
<section class="summary-section">
<h2>局限与改进</h2>
<p>{{ paper.summary.limitations_json }}</p>
</section>
{% endif %} {% elif summary_state == 'processing' %}
<div class="summary-placeholder processing">
<p>🔄 正在生成 AI 总结,请稍后刷新页面</p>
</div>
{% elif summary_state in ('failed', 'permanent_failure') %}
<div class="summary-placeholder failed">
<p>❌ 总结生成失败{% if paper.summary_status and paper.summary_status.error_type %}{{ paper.summary_status.error_type }}{% endif %}</p>
{% if paper.summary_status and paper.summary_status.error %}
<p class="error-detail">{{ paper.summary_status.error }}</p>
{% endif %}
</div>
<div class="summary-placeholder failed">
<p>
❌ 总结生成失败{% if paper.summary_status and
paper.summary_status.error_type %}{{ paper.summary_status.error_type
}}{% endif %}
</p>
{% if paper.summary_status and paper.summary_status.error %}
<p class="error-detail">{{ paper.summary_status.error }}</p>
{% endif %}
</div>
{% else %}
<div class="summary-placeholder none">
<p>📝 AI 总结尚未生成</p>
</div>
{% endif %}
{# 英文摘要 — 始终显示 #}
{% if paper.abstract %}
<div class="summary-placeholder none">
<p>📝 AI 总结尚未生成</p>
</div>
{% endif %} {# 英文摘要 — 始终显示 #} {% if paper.abstract %}
<section class="summary-section abstract-section">
<h2>Abstract</h2>
<p class="abstract-en">{{ paper.abstract }}</p>
</section>
{% endif %}
{# Phase 5: 图片画廊 #}
{% if paper_images %}
{% endif %} {# Phase 5: 图片画廊 #} {% if paper_images %}
<section class="image-gallery">
<h2>论文图片</h2>
<div class="gallery-grid">
{% for img in paper_images %}
<div class="gallery-item">
<img src="{{ img.url }}" alt="{{ img.name }}" loading="lazy">
<img src="{{ img.url }}" alt="{{ img.name }}" loading="lazy" />
<div class="gallery-caption">{{ img.name }}</div>
</div>
{% endfor %}
</div>
</section>
{% endif %}
{# Phase 5: 相似论文推荐 #}
{% if similar_papers %}
{% endif %} {# Phase 5: 相似论文推荐 #} {% if similar_papers %}
<section class="similar-papers">
<h2>相似论文推荐</h2>
{% for sp in similar_papers %}
@@ -142,7 +143,9 @@
<span class="similar-paper-title">
<a href="/paper/{{ sp.arxiv_id }}">{{ sp.title_zh }}</a>
</span>
<span class="similar-paper-dist">🎯 {{ "%.3f"|format(sp.distance) }}</span>
<span class="similar-paper-dist"
>🎯 {{ "%.3f"|format(sp.distance) }}</span
>
</div>
{% endfor %}
</section>
+9 -9
View File
@@ -1,8 +1,5 @@
{% extends "base.html" %}
{% block title %}{{ page_title }} — HF Daily Papers{% endblock %}
{% block content %}
{% extends "base.html" %} {% block title %}{{ page_title }} — HF Daily Papers{%
endblock %} {% block content %}
<div class="date-nav">
{% if prev_day %}
<a href="/day/{{ prev_day }}" class="date-nav-btn">← 前一天</a>
@@ -16,9 +13,8 @@
{% if papers %}
<div class="paper-list">
{% for paper in papers %}
{% include "partials/paper_card.html" %}
{% endfor %}
{% for paper in papers %} {% include "partials/paper_card.html" %} {% endfor
%}
</div>
{% else %}
<div class="empty-state">
@@ -30,7 +26,11 @@
<div class="date-quick-nav">
<span>有数据的日期:</span>
{% for d in available_dates[:10] %}
<a href="/day/{{ d }}" class="date-chip {% if d == current_date %}active{% endif %}">{{ d }}</a>
<a
href="/day/{{ d }}"
class="date-chip {% if d == current_date %}active{% endif %}"
>{{ d }}</a
>
{% endfor %}
</div>
{% endblock %}
+21 -20
View File
@@ -12,7 +12,9 @@
{% if paper.summary and paper.summary.one_line %}
<p class="paper-one-line">{{ paper.summary.one_line }}</p>
{% elif paper.abstract %}
<p class="paper-abstract-preview">{{ paper.abstract[:200] }}{% if paper.abstract|length > 200 %}…{% endif %}</p>
<p class="paper-abstract-preview">
{{ paper.abstract[:200] }}{% if paper.abstract|length > 200 %}…{% endif %}
</p>
{% endif %}
<div class="paper-meta">
@@ -29,32 +31,31 @@
<div class="paper-footer">
<div class="paper-footer-left">
<span class="summary-badge summary-{{ paper.summary_status.status if paper.summary_status else 'none' }}">
{% if not paper.summary_status or paper.summary_status.status == 'pending' %}
未总结
{% elif paper.summary_status.status == 'processing' %}
🔄 总结中
{% elif paper.summary_status.status == 'failed' or paper.summary_status.status == 'permanent_failure' %}
❌ 总结失败
{% elif paper.summary_status.status == 'done' %}
✅ 已总结
{% endif %}
<span
class="summary-badge summary-{{ paper.summary_status.status if paper.summary_status else 'none' }}"
>
{% if not paper.summary_status or paper.summary_status.status ==
'pending' %} 未总结 {% elif paper.summary_status.status == 'processing'
%} 🔄 总结中 {% elif paper.summary_status.status == 'failed' or
paper.summary_status.status == 'permanent_failure' %} ❌ 总结失败 {%
elif paper.summary_status.status == 'done' %} ✅ 已总结 {% endif %}
</span>
{% if paper.reading_status %}
<span class="reading-badge reading-{{ paper.reading_status.status }}">
{% if paper.reading_status.status == 'unread' %}未读
{% elif paper.reading_status.status == 'skimmed' %}已浏览
{% elif paper.reading_status.status == 'read_summary' %}已读摘要
{% elif paper.reading_status.status == 'read_full' %}已读原文
{% endif %}
{% if paper.reading_status.status == 'unread' %}未读 {% elif
paper.reading_status.status == 'skimmed' %}已浏览 {% elif
paper.reading_status.status == 'read_summary' %}已读摘要 {% elif
paper.reading_status.status == 'read_full' %}已读原文 {% endif %}
</span>
{% endif %}
</div>
<div class="paper-footer-right">
<button class="btn-bookmark {% if paper.bookmark %}active{% endif %}"
hx-post="/api/bookmark/{{ paper.arxiv_id }}"
hx-target="#user-data-{{ paper.arxiv_id }}"
hx-swap="outerHTML">
<button
class="btn-bookmark {% if paper.bookmark %}active{% endif %}"
hx-post="/api/bookmark/{{ paper.arxiv_id }}"
hx-target="#user-data-{{ paper.arxiv_id }}"
hx-swap="outerHTML"
>
{% if paper.bookmark %}★{% else %}☆{% endif %}
</button>
<a href="/paper/{{ paper.arxiv_id }}" class="btn-detail">详情 →</a>
+46 -29
View File
@@ -1,45 +1,62 @@
{% extends "base.html" %}
{% block title %}{{ page_title }} — HF Daily Papers{% endblock %}
{% block content %}
{% extends "base.html" %} {% block title %}{{ page_title }} — HF Daily Papers{%
endblock %} {% block content %}
<section class="reading-list-page">
<h1 class="page-heading">📖 阅读列表</h1>
{# 筛选标签栏 #}
<div class="reading-list-filters">
<a href="/reading-list"
class="filter-chip {% if current_filter == 'all' %}active{% endif %}">全部收藏</a>
<a href="/reading-list?filter=unread"
class="filter-chip {% if current_filter == 'unread' %}active{% endif %}">未读</a>
<a href="/reading-list?filter=skimmed"
class="filter-chip {% if current_filter == 'skimmed' %}active{% endif %}">已浏览</a>
<a href="/reading-list?filter=read_summary"
class="filter-chip {% if current_filter == 'read_summary' %}active{% endif %}">已读摘要</a>
<a href="/reading-list?filter=read_full"
class="filter-chip {% if current_filter == 'read_full' %}active{% endif %}">已读原文</a>
<a href="/reading-list?filter=has_note"
class="filter-chip {% if current_filter == 'has_note' %}active{% endif %}">有笔记</a>
<a
href="/reading-list"
class="filter-chip {% if current_filter == 'all' %}active{% endif %}"
>全部收藏</a
>
<a
href="/reading-list?filter=unread"
class="filter-chip {% if current_filter == 'unread' %}active{% endif %}"
>未读</a
>
<a
href="/reading-list?filter=skimmed"
class="filter-chip {% if current_filter == 'skimmed' %}active{% endif %}"
>已浏览</a
>
<a
href="/reading-list?filter=read_summary"
class="filter-chip {% if current_filter == 'read_summary' %}active{% endif %}"
>已读摘要</a
>
<a
href="/reading-list?filter=read_full"
class="filter-chip {% if current_filter == 'read_full' %}active{% endif %}"
>已读原文</a
>
<a
href="/reading-list?filter=has_note"
class="filter-chip {% if current_filter == 'has_note' %}active{% endif %}"
>有笔记</a
>
</div>
{# 标签筛选 #}
{% if all_tags %}
{# 标签筛选 #} {% if all_tags %}
<div class="tag-filter">
<span class="tag-filter-label">标签:</span>
<a href="/reading-list?filter={{ current_filter }}"
class="tag-chip {% if not current_tag %}active{% endif %}">全部</a>
<a
href="/reading-list?filter={{ current_filter }}"
class="tag-chip {% if not current_tag %}active{% endif %}"
>全部</a
>
{% for t in all_tags %}
<a href="/reading-list?filter={{ current_filter }}&tag={{ t }}"
class="tag-chip {% if t == current_tag %}active{% endif %}">{{ t }}</a>
<a
href="/reading-list?filter={{ current_filter }}&tag={{ t }}"
class="tag-chip {% if t == current_tag %}active{% endif %}"
>{{ t }}</a
>
{% endfor %}
</div>
{% endif %}
{% if papers %}
{% endif %} {% if papers %}
<div class="paper-list">
{% for paper in papers %}
{% include "partials/paper_card.html" %}
{% endfor %}
{% for paper in papers %} {% include "partials/paper_card.html" %} {% endfor
%}
</div>
{% else %}
<div class="empty-state">
+97 -58
View File
@@ -1,26 +1,53 @@
{% extends "base.html" %}
{% block title %}{{ page_title }} — HF Daily Papers{% endblock %}
{% block content %}
{% extends "base.html" %} {% block title %}{{ page_title }} — HF Daily Papers{%
endblock %} {% block content %}
<section class="search-page">
{# 搜索表单 #}
<form class="search-form" method="get" action="/search">
<input type="text" name="q" value="{{ query }}" placeholder="搜索标题、摘要、作者、标签..."
class="search-input" autofocus>
<input
type="text"
name="q"
value="{{ query }}"
placeholder="搜索标题、摘要、作者、标签..."
class="search-input"
autofocus
/>
{% if tag %}
<input type="hidden" name="tag" value="{{ tag }}">
{% endif %}
{# 模式切换 #}
{% if chroma_enabled %}
<input type="hidden" name="tag" value="{{ tag }}" />
{% endif %} {# 模式切换 #} {% if chroma_enabled %}
<div class="search-mode-toggle">
<label class="mode-option {% if mode == 'keyword' or not mode %}active{% endif %}">
<input type="radio" name="mode" value="keyword" {% if mode == 'keyword' or not mode %}checked{% endif %}>
<label
class="mode-option {% if mode == 'keyword' or not mode %}active{% endif %}"
>
<input
type="radio"
name="mode"
value="keyword"
{%
if
mode=""
="keyword"
or
not
mode
%}checked{%
endif
%}
/>
关键词
</label>
<label class="mode-option {% if mode == 'semantic' %}active{% endif %}">
<input type="radio" name="mode" value="semantic" {% if mode == 'semantic' %}checked{% endif %}>
<input
type="radio"
name="mode"
value="semantic"
{%
if
mode=""
="semantic"
%}checked{%
endif
%}
/>
语义搜索
</label>
</div>
@@ -29,29 +56,40 @@
<button type="submit" class="search-btn">搜索</button>
</form>
{# 标签筛选 #}
{% if all_tags %}
{# 标签筛选 #} {% if all_tags %}
<div class="tag-filter">
<span class="tag-filter-label">标签:</span>
<a href="/search?q={{ query }}&mode={{ mode }}{% if tag %}&tag={{ tag }}{% endif %}"
class="tag-chip {% if not tag %}active{% endif %}">全部</a>
<a
href="/search?q={{ query }}&mode={{ mode }}{% if tag %}&tag={{ tag }}{% endif %}"
class="tag-chip {% if not tag %}active{% endif %}"
>全部</a
>
{% for t in all_tags %}
<a href="/search?q={{ query }}&tag={{ t }}&mode={{ mode }}"
class="tag-chip {% if t == tag %}active{% endif %}">{{ t }}</a>
<a
href="/search?q={{ query }}&tag={{ t }}&mode={{ mode }}"
class="tag-chip {% if t == tag %}active{% endif %}"
>{{ t }}</a
>
{% endfor %}
</div>
{% endif %}
{% if query or tag %}
{# 搜索结果元信息 #}
{% endif %} {% if query or tag %} {# 搜索结果元信息 #}
<div class="search-meta">
<span>找到 {{ total }} 条结果{% if mode == 'semantic' %}(语义模式){% endif %}</span>
<span
>找到 {{ total }} 条结果{% if mode == 'semantic' %}(语义模式){% endif
%}</span
>
<div class="sort-toggle">
<a href="/search?q={{ query }}&tag={{ tag }}&mode={{ mode }}&sort=relevance"
class="{% if sort == 'relevance' %}active{% endif %}">相关性</a>
<a
href="/search?q={{ query }}&tag={{ tag }}&mode={{ mode }}&sort=relevance"
class="{% if sort == 'relevance' %}active{% endif %}"
>相关性</a
>
<span class="sort-divider">|</span>
<a href="/search?q={{ query }}&tag={{ tag }}&mode={{ mode }}&sort=date"
class="{% if sort == 'date' %}active{% endif %}">日期</a>
<a
href="/search?q={{ query }}&tag={{ tag }}&mode={{ mode }}&sort=date"
class="{% if sort == 'date' %}active{% endif %}"
>日期</a
>
</div>
</div>
@@ -62,14 +100,10 @@
<div class="paper-card-header">
<h2 class="paper-title">
<a href="/paper/{{ paper.arxiv_id }}">
{% set snippet = snippets.get(paper.id, {}) %}
{% if snippet and snippet.title_zh %}
{{ snippet.title_zh | safe }}
{% elif paper.title_zh %}
{{ paper.title_zh }}
{% else %}
{{ paper.title_en }}
{% endif %}
{% set snippet = snippets.get(paper.id, {}) %} {% if snippet and
snippet.title_zh %} {{ snippet.title_zh | safe }} {% elif
paper.title_zh %} {{ paper.title_zh }} {% else %} {{ paper.title_en
}} {% endif %}
</a>
</h2>
<span class="paper-upvotes">👍 {{ paper.upvotes }}</span>
@@ -85,7 +119,10 @@
{% elif paper.summary and paper.summary.one_line %}
<p class="paper-one-line">{{ paper.summary.one_line }}</p>
{% elif paper.abstract %}
<p class="paper-abstract-preview">{{ paper.abstract[:200] }}{% if paper.abstract|length > 200 %}…{% endif %}</p>
<p class="paper-abstract-preview">
{{ paper.abstract[:200] }}{% if paper.abstract|length > 200 %}…{% endif
%}
</p>
{% endif %}
<div class="paper-meta">
@@ -102,16 +139,14 @@
</div>
<div class="paper-footer">
<span class="summary-badge summary-{{ paper.summary_status.status if paper.summary_status else 'none' }}">
{% if not paper.summary_status or paper.summary_status.status == 'pending' %}
未总结
{% elif paper.summary_status.status == 'processing' %}
🔄 总结中
{% elif paper.summary_status.status in ('failed', 'permanent_failure') %}
❌ 总结失败
{% elif paper.summary_status.status == 'done' %}
✅ 已总结
{% endif %}
<span
class="summary-badge summary-{{ paper.summary_status.status if paper.summary_status else 'none' }}"
>
{% if not paper.summary_status or paper.summary_status.status ==
'pending' %} 未总结 {% elif paper.summary_status.status ==
'processing' %} 🔄 总结中 {% elif paper.summary_status.status in
('failed', 'permanent_failure') %} ❌ 总结失败 {% elif
paper.summary_status.status == 'done' %} ✅ 已总结 {% endif %}
</span>
<a href="/paper/{{ paper.arxiv_id }}" class="btn-detail">详情 →</a>
</div>
@@ -119,25 +154,29 @@
{% endfor %}
</div>
{# 分页 #}
{% if total_pages > 1 %}
{# 分页 #} {% if total_pages > 1 %}
<nav class="pagination">
{% if page > 1 %}
<a href="/search?q={{ query }}&tag={{ tag }}&sort={{ sort }}&mode={{ mode }}&page={{ page - 1 }}" class="page-btn">← 上一页</a>
<a
href="/search?q={{ query }}&tag={{ tag }}&sort={{ sort }}&mode={{ mode }}&page={{ page - 1 }}"
class="page-btn"
>← 上一页</a
>
{% endif %}
<span class="page-info">{{ page }} / {{ total_pages }}</span>
{% if page < total_pages %}
<a href="/search?q={{ query }}&tag={{ tag }}&sort={{ sort }}&mode={{ mode }}&page={{ page + 1 }}" class="page-btn">下一页 →</a>
<a
href="/search?q={{ query }}&tag={{ tag }}&sort={{ sort }}&mode={{ mode }}&page={{ page + 1 }}"
class="page-btn"
>下一页 →</a
>
{% endif %}
</nav>
{% endif %}
{% else %}
{% endif %} {% else %}
<div class="empty-state">
<p>没有找到匹配的论文</p>
<p class="hint">试试其他关键词或标签</p>
</div>
{% endif %}
{% endif %}
{% endif %} {% endif %}
</section>
{% endblock %}
+145 -150
View File
@@ -1,8 +1,5 @@
{% extends "base.html" %}
{% block title %}{{ page_title }} — HF Daily Papers{% endblock %}
{% block content %}
{% extends "base.html" %} {% block title %}{{ page_title }} — HF Daily Papers{%
endblock %} {% block content %}
<section class="trends-page">
<h1>趋势看板</h1>
@@ -32,154 +29,152 @@
</div>
</div>
</section>
{% endblock %}
{% block scripts %}
{% endblock %} {% block scripts %}
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js"></script>
<script>
// 颜色配置(kami 风格墨蓝色系)
const COLORS = {
primary: '#2d5f8a',
primaryLight: 'rgba(45, 95, 138, 0.2)',
accent: '#5a9bc7',
success: '#388e3c',
warning: '#f57f17',
danger: '#c62828',
muted: '#4a4a6a',
palette: [
'#2d5f8a', '#5a9bc7', '#388e3c', '#f57f17', '#c62828',
'#7b1fa2', '#00838f', '#ef6c00', '#455a64', '#827717',
'#1565c0', '#ad1457', '#00695c', '#e65100', '#283593',
'#9e9d24', '#6a1b9a', '#00838f', '#4e342e', '#37474f',
],
};
const statsData = {{ stats | tojson }};
// 每日论文数量折线图
(function() {
const ctx = document.getElementById('dailyChart').getContext('2d');
const labels = statsData.daily_counts.map(d => d.date);
const data = statsData.daily_counts.map(d => d.count);
new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: '论文数',
data: data,
borderColor: COLORS.primary,
backgroundColor: COLORS.primaryLight,
fill: true,
tension: 0.3,
pointRadius: 3,
pointHoverRadius: 6,
}]
},
options: {
responsive: true,
plugins: { legend: { display: false } },
scales: {
x: { ticks: { maxTicksLimit: 10, font: { size: 11 } } },
y: { beginAtZero: true, ticks: { stepSize: 1 } },
}
}
});
})();
// 热门标签柱状图
(function() {
const ctx = document.getElementById('tagsChart').getContext('2d');
const labels = statsData.top_tags.map(d => d.tag);
const data = statsData.top_tags.map(d => d.count);
new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: '论文数',
data: data,
backgroundColor: COLORS.palette.slice(0, data.length),
borderRadius: 4,
}]
},
options: {
responsive: true,
indexAxis: 'y',
plugins: { legend: { display: false } },
scales: {
x: { beginAtZero: true, ticks: { stepSize: 1 } },
}
}
});
})();
// Upvotes 分布
(function() {
const ctx = document.getElementById('upvotesChart').getContext('2d');
const labels = statsData.upvotes_dist.map(d => d.range);
const data = statsData.upvotes_dist.map(d => d.count);
new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: '论文数',
data: data,
backgroundColor: COLORS.accent,
borderRadius: 4,
}]
},
options: {
responsive: true,
plugins: { legend: { display: false } },
scales: {
y: { beginAtZero: true, ticks: { stepSize: 1 } },
}
}
});
})();
// 总结完成率环形图
(function() {
const ctx = document.getElementById('summaryChart').getContext('2d');
const statusLabels = {
'done': '已完成',
'pending': '待总结',
'processing': '总结中',
'failed': '失败',
'permanent_failure': '永久失败',
'none': '未开始',
// 颜色配置(kami 风格墨蓝色系)
const COLORS = {
primary: '#2d5f8a',
primaryLight: 'rgba(45, 95, 138, 0.2)',
accent: '#5a9bc7',
success: '#388e3c',
warning: '#f57f17',
danger: '#c62828',
muted: '#4a4a6a',
palette: [
'#2d5f8a', '#5a9bc7', '#388e3c', '#f57f17', '#c62828',
'#7b1fa2', '#00838f', '#ef6c00', '#455a64', '#827717',
'#1565c0', '#ad1457', '#00695c', '#e65100', '#283593',
'#9e9d24', '#6a1b9a', '#00838f', '#4e342e', '#37474f',
],
};
const statusColors = {
'done': COLORS.success,
'pending': COLORS.warning,
'processing': COLORS.primary,
'failed': COLORS.danger,
'permanent_failure': '#b71c1c',
'none': '#bdbdbd',
};
const labels = statsData.summary_completion.map(d => statusLabels[d.status] || d.status);
const data = statsData.summary_completion.map(d => d.count);
const colors = statsData.summary_completion.map(d => statusColors[d.status] || COLORS.muted);
new Chart(ctx, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
data: data,
backgroundColor: colors,
borderWidth: 2,
borderColor: '#fff',
}]
},
options: {
responsive: true,
plugins: {
legend: { position: 'bottom', labels: { padding: 12 } },
const statsData = {{ stats | tojson }};
// 每日论文数量折线图
(function() {
const ctx = document.getElementById('dailyChart').getContext('2d');
const labels = statsData.daily_counts.map(d => d.date);
const data = statsData.daily_counts.map(d => d.count);
new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: '论文数',
data: data,
borderColor: COLORS.primary,
backgroundColor: COLORS.primaryLight,
fill: true,
tension: 0.3,
pointRadius: 3,
pointHoverRadius: 6,
}]
},
options: {
responsive: true,
plugins: { legend: { display: false } },
scales: {
x: { ticks: { maxTicksLimit: 10, font: { size: 11 } } },
y: { beginAtZero: true, ticks: { stepSize: 1 } },
}
}
}
});
})();
});
})();
// 热门标签柱状图
(function() {
const ctx = document.getElementById('tagsChart').getContext('2d');
const labels = statsData.top_tags.map(d => d.tag);
const data = statsData.top_tags.map(d => d.count);
new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: '论文数',
data: data,
backgroundColor: COLORS.palette.slice(0, data.length),
borderRadius: 4,
}]
},
options: {
responsive: true,
indexAxis: 'y',
plugins: { legend: { display: false } },
scales: {
x: { beginAtZero: true, ticks: { stepSize: 1 } },
}
}
});
})();
// Upvotes 分布
(function() {
const ctx = document.getElementById('upvotesChart').getContext('2d');
const labels = statsData.upvotes_dist.map(d => d.range);
const data = statsData.upvotes_dist.map(d => d.count);
new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: '论文数',
data: data,
backgroundColor: COLORS.accent,
borderRadius: 4,
}]
},
options: {
responsive: true,
plugins: { legend: { display: false } },
scales: {
y: { beginAtZero: true, ticks: { stepSize: 1 } },
}
}
});
})();
// 总结完成率环形图
(function() {
const ctx = document.getElementById('summaryChart').getContext('2d');
const statusLabels = {
'done': '已完成',
'pending': '待总结',
'processing': '总结中',
'failed': '失败',
'permanent_failure': '永久失败',
'none': '未开始',
};
const statusColors = {
'done': COLORS.success,
'pending': COLORS.warning,
'processing': COLORS.primary,
'failed': COLORS.danger,
'permanent_failure': '#b71c1c',
'none': '#bdbdbd',
};
const labels = statsData.summary_completion.map(d => statusLabels[d.status] || d.status);
const data = statsData.summary_completion.map(d => d.count);
const colors = statsData.summary_completion.map(d => statusColors[d.status] || COLORS.muted);
new Chart(ctx, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
data: data,
backgroundColor: colors,
borderWidth: 2,
borderColor: '#fff',
}]
},
options: {
responsive: true,
plugins: {
legend: { position: 'bottom', labels: { padding: 12 } },
}
}
});
})();
</script>
{% endblock %}