304 lines
15 KiB
HTML
304 lines
15 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="cs">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Co se děje na Mastodonu | Mamutovo</title>
|
|
<style>
|
|
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;700;800&display=swap');
|
|
:root {
|
|
--bg: #0d0d0d;
|
|
--surface: #1a1a1a;
|
|
--surface2: #222;
|
|
--border: #2a2a2a;
|
|
--text: #f0f0f0;
|
|
--muted: #888;
|
|
--accent: #00c896;
|
|
--accent2: #ff6b6b;
|
|
}
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
body { background: var(--bg); color: var(--text); font-family: 'Syne', sans-serif; min-height: 100vh; }
|
|
|
|
/* NAV */
|
|
nav { display: flex; align-items: center; justify-content: space-between; padding: .9rem 2rem; border-bottom: 1px solid var(--border); background: rgba(13,13,13,0.95); position: sticky; top: 0; z-index: 100; }
|
|
.nav-logo { font-family: 'Space Mono', monospace; font-size: .85rem; color: var(--accent); text-decoration: none; font-weight: 700; }
|
|
.nav-links { display: flex; gap: 1.5rem; }
|
|
.nav-links a { font-family: 'Space Mono', monospace; font-size: .75rem; color: var(--muted); text-decoration: none; transition: color .15s; }
|
|
.nav-links a:hover { color: var(--text); }
|
|
|
|
/* HERO */
|
|
.hero { text-align: center; padding: 3rem 2rem 1.5rem; }
|
|
.hero h1 { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 800; line-height: 1.1; margin-bottom: .75rem; }
|
|
.hero h1 span { color: var(--accent); }
|
|
.hero p { color: var(--muted); font-size: 1rem; max-width: 480px; margin: 0 auto 1.5rem; }
|
|
.cta-bar { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: 2rem; }
|
|
.btn-primary { background: var(--accent); color: #000; padding: .65rem 1.3rem; border-radius: 8px; font-family: 'Space Mono', monospace; font-size: .8rem; font-weight: 700; text-decoration: none; }
|
|
.btn-secondary { background: transparent; color: var(--text); padding: .65rem 1.3rem; border-radius: 8px; border: 1px solid var(--border); font-family: 'Space Mono', monospace; font-size: .8rem; text-decoration: none; }
|
|
.btn-primary:hover { opacity: .85; }
|
|
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
|
|
|
|
/* TOP LINKS */
|
|
.top-links-wrap { padding: 0 1.5rem 1.5rem; max-width: 900px; margin: 0 auto; }
|
|
.section-label { font-family: 'Space Mono', monospace; font-size: .7rem; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 1rem; }
|
|
.top-links-scroll { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
|
|
.link-card { flex-shrink: 0; width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; text-decoration: none; color: var(--text); transition: border-color .15s; }
|
|
.link-card:hover { border-color: var(--accent); }
|
|
.link-card-img { width: 100%; height: 120px; object-fit: cover; background: var(--surface2); display: block; }
|
|
.link-card-img-placeholder { width: 100%; height: 120px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
|
|
.link-card-body { padding: .75rem; }
|
|
.link-domain { font-family: 'Space Mono', monospace; font-size: .65rem; color: var(--muted); margin-bottom: .25rem; }
|
|
.link-title { font-size: .85rem; font-weight: 700; line-height: 1.3; margin-bottom: .5rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
|
.link-shared { display: flex; align-items: center; gap: .4rem; font-family: 'Space Mono', monospace; font-size: .65rem; color: var(--muted); }
|
|
.link-shared img { width: 18px; height: 18px; border-radius: 4px; }
|
|
|
|
/* FILTERS */
|
|
.filters-wrap { max-width: 900px; margin: 0 auto; padding: 0 1.5rem 1rem; }
|
|
.filter-tabs { display: flex; gap: .5rem; flex-wrap: wrap; }
|
|
.filter-tab { font-family: 'Space Mono', monospace; font-size: .75rem; padding: .4rem .9rem; border-radius: 20px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; transition: all .15s; }
|
|
.filter-tab:hover { border-color: var(--accent); color: var(--accent); }
|
|
.filter-tab.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }
|
|
.filter-count { opacity: .7; }
|
|
|
|
/* AUTHORS */
|
|
.authors-wrap { max-width: 900px; margin: 0 auto; padding: 0 1.5rem .75rem; }
|
|
.authors-scroll { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
|
|
.author-chip { display: flex; flex-direction: column; align-items: center; gap: .3rem; flex-shrink: 0; }
|
|
.author-chip img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
|
|
.author-chip-fallback { width: 48px; height: 48px; border-radius: 50%; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
|
|
.author-chip-name { font-size: .65rem; color: var(--muted); text-align: center; max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
|
|
/* FEED */
|
|
.feed-wrap { max-width: 900px; margin: 0 auto; padding: 0 1.5rem 4rem; }
|
|
.feed { display: flex; flex-direction: column; }
|
|
.post { display: flex; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); cursor: default; transition: background .1s; }
|
|
.post:hover { background: rgba(255,255,255,.02); }
|
|
.post-avatar { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; object-fit: cover; }
|
|
.post-avatar-fallback { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: .85rem; color: var(--text); }
|
|
.post-main { flex: 1; min-width: 0; }
|
|
.post-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .2rem; }
|
|
.post-author { font-weight: 700; font-size: .85rem; }
|
|
.post-time { font-family: 'Space Mono', monospace; font-size: .65rem; color: var(--muted); flex-shrink: 0; margin-left: .5rem; }
|
|
.post-handle { font-family: 'Space Mono', monospace; font-size: .65rem; color: var(--muted); margin-bottom: .35rem; }
|
|
.post-text { font-size: .82rem; line-height: 1.55; color: var(--text); word-break: break-word; }
|
|
.post-text a { color: var(--accent); text-decoration: none; }
|
|
.post-media { float: right; margin: 0 0 .25rem .75rem; width: 120px; border-radius: 8px; overflow: hidden; }
|
|
.post-media img { width: 120px; height: 120px; aspect-ratio: 1/1; object-fit: cover; display: block; }
|
|
.post-boost { font-family: 'Space Mono', monospace; font-size: .7rem; color: var(--muted); margin-bottom: .3rem; }
|
|
.post-boost span { color: var(--accent); }
|
|
|
|
.loading { text-align: center; color: var(--muted); font-family: 'Space Mono', monospace; font-size: .8rem; padding: 3rem; }
|
|
|
|
/* STARTER */
|
|
.starter-wrap { max-width: 900px; margin: 0 auto; padding: 0 1.5rem 4rem; }
|
|
.starter { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; text-align: center; }
|
|
.starter h2 { font-size: 1.3rem; margin-bottom: .5rem; }
|
|
.starter p { color: var(--muted); margin-bottom: 1.5rem; font-size: .95rem; }
|
|
.starter-btns { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<nav>
|
|
<a class="nav-logo" href="/">🦣 Mamutovo</a>
|
|
<div class="nav-links">
|
|
<a href="start.html">Průvodce</a>
|
|
<a href="accounts.html">CZ účty</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="hero">
|
|
<h1>Co se teď děje<br>na <span>Mamutovu</span>?</h1>
|
|
<p>Živý přehled příspěvků z české Mastodon komunity. Bez registrace.</p>
|
|
<div class="cta-bar">
|
|
<a href="start.html" class="btn-primary">Začni tady →</a>
|
|
<a href="accounts.html" class="btn-secondary">Procházet účty</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="top-links-wrap">
|
|
<div class="section-label">🔗 Top odkazy</div>
|
|
<div class="top-links-scroll" id="top-links">
|
|
<div class="loading">Načítám…</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="filters-wrap">
|
|
<div class="filter-tabs" style="margin-bottom:.75rem">
|
|
<button class="filter-tab active" data-scope="local" onclick="setScope('local')">🦣 Mamutovo</button>
|
|
<button class="filter-tab" data-scope="federated" onclick="setScope('federated')">🌍 Celá fediverse</button>
|
|
</div>
|
|
<div class="filter-tabs">
|
|
<button class="filter-tab active" data-filter="all">Vše <span class="filter-count" id="count-all"></span></button>
|
|
<button class="filter-tab" data-filter="original">Originální <span class="filter-count" id="count-original"></span></button>
|
|
<button class="filter-tab" data-filter="replies">Odpovědi <span class="filter-count" id="count-replies"></span></button>
|
|
<button class="filter-tab" data-filter="boosts">Boosty <span class="filter-count" id="count-boosts"></span></button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="authors-wrap">
|
|
<div class="authors-scroll" id="authors-scroll"></div>
|
|
</div>
|
|
|
|
<div class="feed-wrap">
|
|
<div class="feed" id="feed">
|
|
<div class="loading">Načítám příspěvky…</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="starter-wrap">
|
|
<div class="starter">
|
|
<h2>Líbí se ti to?</h2>
|
|
<p>Začni sledovat českou komunitu — stáhni starter pack a importuj ho do Mastodonu.</p>
|
|
<div class="starter-btns">
|
|
<a href="starter-general.csv" class="btn-primary" download>⬇ Stáhnout CSV</a>
|
|
<a href="accounts.html" class="btn-secondary">Procházet účty</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let allPosts = [];
|
|
let currentFilter = 'all';
|
|
let currentScope = 'local';
|
|
|
|
function setScope(scope) {
|
|
currentScope = scope;
|
|
currentFilter = 'all';
|
|
document.querySelectorAll('[data-scope]').forEach(b => b.classList.toggle('active', b.dataset.scope === scope));
|
|
document.querySelectorAll('.filter-tab[data-filter]').forEach(b => b.classList.toggle('active', b.dataset.filter === 'all'));
|
|
loadFeed();
|
|
}
|
|
|
|
function timeAgo(dateStr) {
|
|
const diff = Math.floor((Date.now() - new Date(dateStr)) / 1000);
|
|
if (diff < 60) return `${diff}s`;
|
|
if (diff < 3600) return `${Math.floor(diff/60)}m`;
|
|
if (diff < 86400) return `${Math.floor(diff/3600)}h`;
|
|
return new Date(dateStr).toLocaleDateString('cs-CZ', {day:'numeric', month:'numeric'});
|
|
}
|
|
|
|
function stripHTML(html) {
|
|
return html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
|
|
}
|
|
|
|
function postType(p) {
|
|
if (p.reblog) return 'boosts';
|
|
if (p.in_reply_to_id) return 'replies';
|
|
return 'original';
|
|
}
|
|
|
|
function renderPost(p) {
|
|
const isBoost = !!p.reblog;
|
|
const src = isBoost ? p.reblog : p;
|
|
const av = src.account.avatar
|
|
? `<img class="post-avatar" src="${src.account.avatar}" alt="" onerror="this.style.display='none'">`
|
|
: `<div class="post-avatar-fallback">${(src.account.display_name||src.account.username).charAt(0)}</div>`;
|
|
const text = stripHTML(src.content || '');
|
|
const media = src.media_attachments?.find(m => m.type === 'image');
|
|
const boostLine = isBoost
|
|
? `<div class="post-boost">🔁 <span>${p.account.display_name||p.account.username}</span> boostnul/a</div>`
|
|
: '';
|
|
return `
|
|
<div class="post">
|
|
${av}
|
|
<div class="post-main">
|
|
${boostLine}
|
|
<div class="post-top">
|
|
<span class="post-author">${src.account.display_name||src.account.username}</span>
|
|
<span class="post-time">${timeAgo(p.created_at)}</span>
|
|
</div>
|
|
<div class="post-handle">@${src.account.acct}</div>
|
|
<div class="post-text">${text.slice(0,300)}${text.length>300?'…':''}</div>
|
|
${media ? `<div class="post-media"><img src="${media.preview_url}" alt=""></div>` : ''}
|
|
</div>
|
|
</div>`;
|
|
}
|
|
|
|
function renderFeed() {
|
|
const feed = document.getElementById('feed');
|
|
const filtered = currentFilter === 'all' ? allPosts : allPosts.filter(p => postType(p) === currentFilter);
|
|
if (!filtered.length) { feed.innerHTML = '<div class="loading">Žádné příspěvky.</div>'; return; }
|
|
try { feed.innerHTML = filtered.map(renderPost).join(''); } catch(e) { console.error('renderFeed error:', e); feed.innerHTML = '<div class="loading">Chyba vykreslování.</div>'; }
|
|
}
|
|
|
|
function updateAuthors() {
|
|
const scroll = document.getElementById('authors-scroll');
|
|
if (!scroll) return;
|
|
const counts = {};
|
|
allPosts.forEach(p => {
|
|
const src = p.reblog ? p.reblog : p;
|
|
const key = src.account.acct;
|
|
if (!counts[key]) counts[key] = { account: src.account, count: 0 };
|
|
counts[key].count++;
|
|
});
|
|
const sorted = Object.values(counts).sort((a, b) => b.count - a.count).slice(0, 20);
|
|
scroll.innerHTML = sorted.map(({ account }) => {
|
|
const av = account.avatar
|
|
? `<img src="${account.avatar}" alt="" onerror="this.style.display='none'">`
|
|
: `<div class="author-chip-fallback">${(account.display_name||account.username).charAt(0)}</div>`;
|
|
const name = account.display_name || account.username;
|
|
return `<div class="author-chip">${av}<span class="author-chip-name">${name}</span></div>`;
|
|
}).join('');
|
|
}
|
|
|
|
function updateCounts() {
|
|
document.getElementById('count-all').textContent = allPosts.length;
|
|
document.getElementById('count-original').textContent = allPosts.filter(p => postType(p) === 'original').length;
|
|
document.getElementById('count-replies').textContent = allPosts.filter(p => postType(p) === 'replies').length;
|
|
document.getElementById('count-boosts').textContent = allPosts.filter(p => postType(p) === 'boosts').length;
|
|
}
|
|
|
|
async function loadFeed() {
|
|
try {
|
|
const res = await fetch('https://mamutovo.cz/api/v1/timelines/public?limit=30' + (currentScope === 'local' ? '&local=true' : ''));
|
|
allPosts = await res.json();
|
|
updateCounts();
|
|
renderFeed();
|
|
updateAuthors();
|
|
} catch(e) {
|
|
document.getElementById('feed').innerHTML = '<div class="loading">Nepodařilo se načíst příspěvky.</div>';
|
|
}
|
|
}
|
|
|
|
async function loadTopLinks() {
|
|
const el = document.getElementById('top-links');
|
|
try {
|
|
const res = await fetch('https://mamutovo.cz/api/v1/trends/links?limit=8');
|
|
const links = await res.json();
|
|
if (!links.length) { el.innerHTML = '<div class="loading">Žádné trendy.</div>'; return; }
|
|
el.innerHTML = links.map(l => {
|
|
const img = l.image
|
|
? `<img class="link-card-img" src="${l.image}" alt="" onerror="this.parentElement.innerHTML='<div class=link-card-img-placeholder>🔗</div>'">`
|
|
: `<div class="link-card-img-placeholder">🔗</div>`;
|
|
const domain = new URL(l.url).hostname.replace('www.','');
|
|
const sharedBy = l.history?.[0] ? `${l.history[0].accounts} lidí` : '';
|
|
return `
|
|
<a class="link-card" href="${l.url}" target="_blank" rel="noopener">
|
|
${img}
|
|
<div class="link-card-body">
|
|
<div class="link-domain">${domain}</div>
|
|
<div class="link-title">${l.title||l.url}</div>
|
|
<div class="link-shared">👥 Sdílelo ${sharedBy}</div>
|
|
</div>
|
|
</a>`;
|
|
}).join('');
|
|
} catch(e) {
|
|
el.innerHTML = '<div class="loading">Trendy nedostupné.</div>';
|
|
}
|
|
}
|
|
|
|
document.querySelectorAll('.filter-tab[data-filter]').forEach(btn => {
|
|
btn.addEventListener('click', () => {
|
|
document.querySelectorAll('.filter-tab[data-filter]').forEach(b => b.classList.remove('active'));
|
|
btn.classList.add('active');
|
|
currentFilter = btn.dataset.filter;
|
|
renderFeed();
|
|
});
|
|
});
|
|
|
|
loadTopLinks();
|
|
loadFeed();
|
|
setInterval(loadFeed, 60000);
|
|
</script>
|
|
</body>
|
|
</html>
|