118 lines
6.1 KiB
HTML
118 lines
6.1 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Daily 25 · {{ day }}</title>
|
|
<link rel="icon" href="/favicon.ico">
|
|
<link rel="shortcut icon" href="/favicon.ico">
|
|
<style>
|
|
:root { --bg:#0f0f10; --card:#1a1a1d; --muted:#9a9aa3; --text:#ececf1; --accent:#ff4d4d; --ok:#3ecf8e; }
|
|
* { box-sizing: border-box; }
|
|
body { margin:0; font:15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; background:var(--bg); color:var(--text); }
|
|
header { display:flex; flex-wrap:wrap; gap:12px; align-items:center; justify-content:space-between;
|
|
padding:16px 24px; border-bottom:1px solid #2a2a2f; position:sticky; top:0; background:var(--bg); z-index:2; }
|
|
h1 { font-size:20px; margin:0; } h1 span { color:var(--accent); }
|
|
.meta { color:var(--muted); font-size:13px; }
|
|
.controls { display:flex; gap:8px; align-items:center; }
|
|
select, button { background:#26262b; color:var(--text); border:1px solid #34343a; border-radius:8px; padding:7px 12px; font:inherit; cursor:pointer; }
|
|
button:hover { border-color:#55555e; }
|
|
main { display:grid; grid-template-columns:repeat(auto-fill, minmax(300px, 1fr)); gap:18px; padding:24px; }
|
|
.card { background:var(--card); border-radius:12px; overflow:hidden; display:flex; flex-direction:column; transition:opacity .2s; }
|
|
.card.down { opacity:.35; } .card.watched { opacity:.6; }
|
|
.thumb { position:relative; display:block; aspect-ratio:16/9; background:#000; }
|
|
.thumb img { width:100%; height:100%; object-fit:cover; display:block; }
|
|
.rank { position:absolute; top:8px; left:8px; background:rgba(0,0,0,.75); padding:2px 8px; border-radius:6px; font-weight:600; }
|
|
.dur { position:absolute; bottom:8px; right:8px; background:rgba(0,0,0,.8); padding:1px 6px; border-radius:4px; font-size:12px; }
|
|
.body { padding:12px 14px; flex:1; display:flex; flex-direction:column; gap:6px; }
|
|
.title { font-weight:600; color:var(--text); text-decoration:none; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
|
|
.chan { color:var(--muted); font-size:13px; }
|
|
.reason { font-size:12px; color:#c9b2ff; }
|
|
.actions { display:flex; gap:6px; padding:0 14px 14px; }
|
|
.actions button { flex:1; padding:6px 0; }
|
|
.actions button.on[data-kind=up] { background:#1f3b2f; border-color:var(--ok); }
|
|
.actions button.on[data-kind=down] { background:#3b1f1f; border-color:var(--accent); }
|
|
.actions button.on[data-kind=watched] { background:#1f2a3b; border-color:#5b8cff; }
|
|
.empty { padding:60px 24px; text-align:center; color:var(--muted); grid-column:1/-1; }
|
|
.err { color:var(--accent); }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div>
|
|
<h1>Daily <span>25</span> · {{ day }}</h1>
|
|
<div class="meta">
|
|
{{ n_ratings }} ratings so far · refreshes daily at {{ run_time }}
|
|
{% if running %} · <strong>building list…</strong>{% endif %}
|
|
{% if last_run and last_run.status == 'error' %} · <span class="err">last run failed: {{ last_run.message[:160] }}</span>{% endif %}
|
|
</div>
|
|
</div>
|
|
<div class="controls">
|
|
<select onchange="location.href='/?day='+this.value">
|
|
{% for d in days %}<option value="{{ d }}" {% if d == day %}selected{% endif %}>{{ d }}</option>{% endfor %}
|
|
</select>
|
|
<button onclick="runNow(true)" title="Re-rank using your latest 👍/👎 (fast)">Re-rank</button>
|
|
<button onclick="runNow(false)" title="Fetch from YouTube and rebuild (slow)">Refresh from YouTube</button>
|
|
</div>
|
|
</header>
|
|
|
|
<main>
|
|
{% for v in videos %}
|
|
<div class="card {% if v.down %}down{% endif %} {% if v.watched %}watched{% endif %}" id="c-{{ v.id }}">
|
|
<a class="thumb" href="https://www.youtube.com/watch?v={{ v.id }}" target="_blank" rel="noopener" onclick="send('{{ v.id }}','opened',true)">
|
|
<img loading="lazy" src="https://i.ytimg.com/vi/{{ v.id }}/mqdefault.jpg" alt="">
|
|
<span class="rank">#{{ v.rank }}</span>
|
|
{% if v.duration_str %}<span class="dur">{{ v.duration_str }}</span>{% endif %}
|
|
</a>
|
|
<div class="body">
|
|
<a class="title" href="https://www.youtube.com/watch?v={{ v.id }}" target="_blank" rel="noopener" onclick="send('{{ v.id }}','opened',true)">{{ v.title }}</a>
|
|
<div class="chan">{{ v.channel or '' }}{% if v.age %} · {{ v.age }}{% endif %}</div>
|
|
<div class="reason">{{ v.reason }}</div>
|
|
</div>
|
|
<div class="actions">
|
|
<button data-kind="up" class="{% if v.up %}on{% endif %}" onclick="toggle(this,'{{ v.id }}')" title="More like this">👍</button>
|
|
<button data-kind="down" class="{% if v.down %}on{% endif %}" onclick="toggle(this,'{{ v.id }}')" title="Less like this">👎</button>
|
|
<button data-kind="watched" class="{% if v.watched %}on{% endif %}" onclick="toggle(this,'{{ v.id }}')" title="Mark as watched">✓ Watched</button>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<div class="empty">
|
|
{% if running %}Building your first list. This page will refresh by itself.
|
|
{% else %}No list yet. Click <b>Refresh from YouTube</b>.{% endif %}
|
|
</div>
|
|
{% endfor %}
|
|
</main>
|
|
|
|
<script>
|
|
async function send(id, kind, on) {
|
|
try {
|
|
await fetch('/api/feedback', {method:'POST', headers:{'Content-Type':'application/json'},
|
|
body: JSON.stringify({video_id:id, kind:kind, on:on})});
|
|
} catch (e) { console.error(e); }
|
|
}
|
|
function toggle(btn, id) {
|
|
const kind = btn.dataset.kind, on = !btn.classList.contains('on');
|
|
const card = document.getElementById('c-' + id);
|
|
if (on && (kind === 'up' || kind === 'down')) {
|
|
card.querySelectorAll('button[data-kind=up],button[data-kind=down]').forEach(b => b.classList.remove('on'));
|
|
card.classList.remove('down');
|
|
}
|
|
btn.classList.toggle('on', on);
|
|
if (kind === 'down') card.classList.toggle('down', on);
|
|
if (kind === 'watched') card.classList.toggle('watched', on);
|
|
send(id, kind, on);
|
|
}
|
|
async function runNow(rerank) {
|
|
await fetch('/api/run?rerank_only=' + rerank, {method:'POST'});
|
|
setTimeout(() => location.href = '/', 800);
|
|
}
|
|
{% if running %}
|
|
(async function poll() {
|
|
const s = await (await fetch('/api/status')).json();
|
|
if (!s.running) location.href = '/'; else setTimeout(poll, 5000);
|
|
})();
|
|
{% endif %}
|
|
</script>
|
|
</body>
|
|
</html>
|