Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
f2711bd3c3
|
|||
|
1c61a8736f
|
|||
|
6a76c377fa
|
|||
|
c863d45cf0
|
|||
|
6839670a8c
|
|||
|
efdddd2527
|
|||
|
944092f474
|
|||
|
aaa8774dea
|
|||
|
89f6d9b85c
|
|||
|
724fc33f87
|
@@ -1,84 +1,262 @@
|
||||
# fedi_start
|
||||
|
||||
Onboarding systém pro nové uživatele Mastodonu (CZ/SK komunita).
|
||||
Onboarding průvodce pro [Mamutovo.cz](https://mamutovo.cz) – pomáhá nováčkům začít na Fediverse.
|
||||
|
||||
## Soubory
|
||||
- **Web:** https://fedi.mamutovo.cz
|
||||
- **Repo:** https://git.arch-linux.cz/Mamutovo/fedi_start
|
||||
- **Účet:** [@archlinuxcz@mamutovo.cz](https://mamutovo.cz/@archlinuxcz)
|
||||
|
||||
---
|
||||
|
||||
## Obsah projektu
|
||||
|
||||
| Soubor | Popis |
|
||||
|---|---|
|
||||
| `start.html` | Úvodní onboarding stránka |
|
||||
| `accounts.html` | Interaktivní seznam CZ účtů s filtry |
|
||||
| `accounts.json` | Data účtů (generováno skriptem) |
|
||||
| `starter-general.csv` | Starter pack pro import do Mastodonu |
|
||||
| `mastodon_cz_accounts.py` | Automatický sběr CZ/SK účtů |
|
||||
| `upload_surfer.sh` | Upload dat na Surfer |
|
||||
| `index.html` | Hlavní stránka |
|
||||
| `start.html` | Krok za krokem onboarding pro nováčky |
|
||||
| `basics.html` | Základy Mastodonu |
|
||||
| `accounts.html` | Interaktivní seznam CZ/SK účtů s filtry |
|
||||
| `apps.html` | Doporučené aplikace (Android / iOS / Web / Desktop) |
|
||||
| `accounts.json` | Data účtů (generováno skriptem, nahrává se na Surfer) |
|
||||
| `accounts.csv` | Totéž v CSV (nahrává se na Surfer) |
|
||||
| `manual_accounts.csv` | Ručně přidané účty (GTS instance a výjimky) |
|
||||
| `starter-general.csv` | Starter pack – obecný – pro import do Mastodonu |
|
||||
| `starter-tech.csv` | Starter pack – tech – pro import do Mastodonu |
|
||||
| `mastodon_cz_accounts.py` | Hlavní skript – scraping CZ/SK účtů |
|
||||
| `upload_surfer.sh` | Upload `accounts.json` a `accounts.csv` na Cloudron Surfer |
|
||||
|
||||
---
|
||||
|
||||
## Lokální vývoj
|
||||
|
||||
## Lokální spuštění
|
||||
```bash
|
||||
# Spustí lokální HTTP server
|
||||
python3 -m http.server 8080
|
||||
# http://localhost:8080/accounts.html
|
||||
# Otevři v prohlížeči: http://localhost:8080/
|
||||
```
|
||||
|
||||
## Generování dat
|
||||
```bash
|
||||
python3 mastodon_cz_accounts.py --output .
|
||||
---
|
||||
|
||||
## Skript `mastodon_cz_accounts.py`
|
||||
|
||||
Sbírá CZ/SK účty z Mastodonu a GoToSocial instancí, filtruje je a ukládá do `accounts.json` a `accounts.csv`.
|
||||
|
||||
### Jak funguje sběr dat
|
||||
|
||||
1. Pro každou instanci v `QUERY_INSTANCES` volá `/api/v1/directory` (veřejné Mastodon API).
|
||||
2. Načte `manual_accounts.csv` a dohledá každý účet přes `/api/v1/accounts/lookup`.
|
||||
3. Sloučí obojí, odstraní duplicity, seřadí a ořízne na `TOP_N` (výchozí 250) automatických účtů + všechny manuální.
|
||||
|
||||
### Kritéria pro zařazení (automatické účty)
|
||||
|
||||
| Podmínka | Hodnota |
|
||||
|---|---|
|
||||
| `discoverable = true` | Uživatel chce být nalezen |
|
||||
| Aktivní za posledních | 90 dní |
|
||||
| Min. počet příspěvků | 10 |
|
||||
| Min. počet sledujících | 10 |
|
||||
|
||||
**Manuálně přidané účty** (`manual_accounts.csv`) jsou vždy zahrnuty bez ohledu na tato kritéria.
|
||||
|
||||
### Sledované instance
|
||||
|
||||
CZ/SK instance jsou v konstantě `QUERY_INSTANCES` v hlavičce skriptu:
|
||||
|
||||
```
|
||||
mastodonczech.cz, cztwitter.cz, witter.cz, mastodon.pirati.cz,
|
||||
f.cz, lgbtcz.social, boskovice.social, mamutovo.cz,
|
||||
gts.arch-linux.cz, kompost.cz, spondr.cz, skorpil.cz,
|
||||
ajtaci.club, toot.whatever.cz
|
||||
```
|
||||
|
||||
### Spuštění
|
||||
|
||||
```bash
|
||||
# Základní spuštění (výstup do aktuálního adresáře)
|
||||
python3 mastodon_cz_accounts.py
|
||||
|
||||
# Výstup do konkrétního adresáře
|
||||
python3 mastodon_cz_accounts.py --output /var/www/start/
|
||||
|
||||
# Omezení počtu účtů
|
||||
python3 mastodon_cz_accounts.py --top 100
|
||||
|
||||
# Ladění
|
||||
python3 mastodon_cz_accounts.py --debug
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Konfigurace `.env`
|
||||
|
||||
Vytvoř soubor `.env` v kořeni projektu (je v `.gitignore`, nikdy ho necommituj):
|
||||
|
||||
```ini
|
||||
# Volitelný Mastodon token (pro vyšší rate limity)
|
||||
MASTODON_TOKEN=tvuj_mastodon_token
|
||||
|
||||
# GoToSocial tokeny per-instance (viz sekce níže)
|
||||
GTS_TOKEN_GTS_ARCH_LINUX_CZ=tvuj_token_zde
|
||||
GTS_TOKEN_DALSI_INSTANCE_CZ=dalsi_token
|
||||
|
||||
# Surfer token pro upload na web
|
||||
SURFER_TOKEN=tvuj_surfer_token
|
||||
|
||||
# Volitelně: jiný Surfer server (výchozí je fedi.mamutovo.cz)
|
||||
# SURFER_SERVER=cloud.oscloud.cz
|
||||
```
|
||||
|
||||
### Proměnné prostředí
|
||||
|
||||
| Proměnná | Povinná | Popis |
|
||||
|---|---|---|
|
||||
| `MASTODON_TOKEN` | ne | Token pro Mastodon API (vyšší rate limity) |
|
||||
| `GTS_TOKEN_<DOMAIN>` | pro GTS instance | Read token per GoToSocial instance |
|
||||
| `SURFER_TOKEN` | pro upload | Token z Cloudron Surfer |
|
||||
| `SURFER_SERVER` | ne | Server Surferu, pokud není výchozí |
|
||||
|
||||
Název proměnné pro GTS token se tvoří z domény – tečky a pomlčky se nahradí podtržítkem a vše se převede na VELKÁ PÍSMENA:
|
||||
|
||||
```
|
||||
gts.arch-linux.cz → GTS_TOKEN_GTS_ARCH_LINUX_CZ
|
||||
shimon.gts.example → GTS_TOKEN_SHIMON_GTS_EXAMPLE
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GoToSocial instance – jak získat read token
|
||||
|
||||
GoToSocial nepodporuje veřejné `/api/v1/directory`, takže každá GTS instance potřebuje vlastní read token. Postup:
|
||||
|
||||
### 1. Přihlášení a vytvoření aplikace
|
||||
|
||||
Přihlas se na dané GTS instanci a jdi do **Settings → Applications → New application**.
|
||||
|
||||
Vyplň:
|
||||
- **Název aplikace:** např. `fedi_start scraper`
|
||||
- **Scopes:** zaškrtni pouze `read`
|
||||
- Ostatní pole nech prázdná nebo vyplň libovolně
|
||||
|
||||
Uložíš aplikaci a GTS ti vygeneruje `client_id` a `client_secret`. Poznamenej si obojí.
|
||||
|
||||
### 2. Získání authorization code
|
||||
|
||||
Otevři v prohlížeči tuto URL (nahraď `INSTANCI.CZ` a `CLIENT_ID`):
|
||||
|
||||
```
|
||||
https://INSTANCI.CZ/oauth/authorize?client_id=CLIENT_ID&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=read
|
||||
```
|
||||
|
||||
Přihlášený prohlížeč zobrazí stránku s kódem – zkopíruj ho (jednorázový, platí jen chvíli).
|
||||
|
||||
### 3. Výměna code za access token
|
||||
|
||||
```bash
|
||||
curl -X POST "https://INSTANCI.CZ/oauth/token" \
|
||||
-d "client_id=CLIENT_ID" \
|
||||
-d "client_secret=CLIENT_SECRET" \
|
||||
-d "redirect_uri=urn:ietf:wg:oauth:2.0:oob" \
|
||||
-d "grant_type=authorization_code" \
|
||||
-d "code=AUTHORIZATION_CODE" \
|
||||
-d "scope=read"
|
||||
```
|
||||
|
||||
V odpovědi dostaneš JSON s `access_token`.
|
||||
|
||||
### 4. Přidání tokenu do `.env`
|
||||
|
||||
```ini
|
||||
GTS_TOKEN_GTS_ARCH_LINUX_CZ=ziskany_access_token
|
||||
```
|
||||
|
||||
### 5. Ověření
|
||||
|
||||
```bash
|
||||
curl -H "Authorization: Bearer TVUJ_TOKEN" "https://INSTANCI.CZ/api/v1/accounts/verify_credentials"
|
||||
```
|
||||
|
||||
Pokud vrátí JSON s tvým účtem, token funguje.
|
||||
|
||||
---
|
||||
|
||||
## Přidání nového účtu
|
||||
|
||||
### Mastodon instance
|
||||
|
||||
Uživatel se zobrazí automaticky, pokud má v nastavení zapnuté:
|
||||
|
||||
> **Settings → Privacy → Appearance in search engines** (nebo česky „Zobrazovat profil ve vyhledávacích algoritmech")
|
||||
|
||||
A splňuje kritéria výše (aktivita, min. počet příspěvků atd.).
|
||||
|
||||
Pokud chceš účet přidat ručně bez ohledu na kritéria, přidej ho do `manual_accounts.csv`:
|
||||
|
||||
```csv
|
||||
handle@instance.cz,true,false,
|
||||
```
|
||||
|
||||
### GoToSocial instance
|
||||
|
||||
GTS nemá veřejný adresář, proto:
|
||||
|
||||
1. Získej read token (viz postup výše).
|
||||
2. Přidej `GTS_TOKEN_<DOMAIN>=token` do `.env`.
|
||||
3. Přidej konkrétní účty do `manual_accounts.csv` (GTS adresář je přístupný s tokenem, ale pro jistotu je lepší přidat je ručně).
|
||||
4. Přidej instanci do `QUERY_INSTANCES` v `mastodon_cz_accounts.py`.
|
||||
|
||||
---
|
||||
|
||||
## Nasazení na VPS
|
||||
|
||||
Projekt běží na VPS Hetzner v `/opt/fedi_start/`.
|
||||
|
||||
### Závislosti
|
||||
|
||||
```bash
|
||||
pip3 install requests python-dateutil
|
||||
# Python (stdlib only, žádné externí balíčky)
|
||||
python3 --version # 3.10+
|
||||
|
||||
# Node.js – Cloudron Surfer CLI
|
||||
npm install -g cloudron-surfer
|
||||
```
|
||||
|
||||
### Nastavení .env
|
||||
Vytvoř soubor `.env` v kořeni projektu:
|
||||
```
|
||||
MASTODON_TOKEN=tvuj_mastodon_token
|
||||
GTS_TOKEN=tvuj_gts_token
|
||||
SURFER_TOKEN=tvuj_surfer_token
|
||||
### Nastavení na serveru
|
||||
|
||||
```bash
|
||||
git clone https://git.arch-linux.cz/Mamutovo/fedi_start /opt/fedi_start
|
||||
cd /opt/fedi_start
|
||||
cp .env.example .env # nebo vytvoř .env ručně
|
||||
# Vyplň tokeny v .env
|
||||
```
|
||||
|
||||
- **MASTODON_TOKEN** — přístupový token z nastavení Mastodon účtu (Settings → Development → New application)
|
||||
- **GTS_TOKEN** — token pro GoToSocial instanci
|
||||
- **SURFER_TOKEN** — token z Cloudron Surfer (viz sekce Upload na Surfer)
|
||||
### Cron
|
||||
|
||||
## Cron
|
||||
Automatická aktualizace 4× denně:
|
||||
|
||||
Automatické generování dat každý den ve 3:00:
|
||||
```
|
||||
0 3 * * * cd /opt/fedi_start && python3 mastodon_cz_accounts.py --output . && bash upload_surfer.sh
|
||||
0 6,12,18,0 * * * cd /opt/fedi_start && python3 mastodon_cz_accounts.py --output . && bash upload_surfer.sh >> /var/log/fedi_start.log 2>&1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Upload na Surfer
|
||||
|
||||
### Instalace
|
||||
```bash
|
||||
npm install -g cloudron-surfer
|
||||
```
|
||||
[Cloudron Surfer](https://cloudron.io/store/io.cloudron.surfer.html) je jednoduchý statický file hosting.
|
||||
|
||||
### Konfigurace
|
||||
```bash
|
||||
surfer config --server fedi.mamutovo.cz --token TOKEN
|
||||
```
|
||||
### Ruční spuštění uploadu
|
||||
|
||||
### Spuštění uploadu
|
||||
```bash
|
||||
bash upload_surfer.sh
|
||||
```
|
||||
|
||||
### CLI — manuální upload
|
||||
Skript načte `SURFER_TOKEN` z `.env` a nahraje `accounts.json` + `accounts.csv` do kořene Surfer serveru.
|
||||
|
||||
### Manuální Surfer příkazy
|
||||
|
||||
```bash
|
||||
# Nahrát konkrétní soubor do kořene
|
||||
surfer put -t $SURFER_TOKEN accounts.json /
|
||||
|
||||
# Nahrát více souborů najednou
|
||||
# Nahrát konkrétní soubory
|
||||
surfer put -t $SURFER_TOKEN accounts.json accounts.csv /
|
||||
|
||||
# Nahrát celý adresář
|
||||
surfer put -t $SURFER_TOKEN dist/ /
|
||||
|
||||
# Zobrazit obsah na serveru
|
||||
surfer get
|
||||
|
||||
@@ -86,6 +264,30 @@ surfer get
|
||||
surfer del /accounts.json
|
||||
```
|
||||
|
||||
## Web
|
||||
---
|
||||
|
||||
Stránka je dostupná na: https://fedi.mamutovo.cz
|
||||
## Struktura dat `accounts.json`
|
||||
|
||||
Každý záznam v poli `accounts` obsahuje:
|
||||
|
||||
```json
|
||||
{
|
||||
"handle": "uzivatel@instance.cz",
|
||||
"display_name": "Zobrazované jméno",
|
||||
"note": "Bio uživatele",
|
||||
"followers": 123,
|
||||
"following": 45,
|
||||
"statuses": 678,
|
||||
"last_active": "2024-03-15",
|
||||
"avatar": "https://...",
|
||||
"url": "https://instance.cz/@uzivatel",
|
||||
"fields": [...],
|
||||
"tags": ["linux", "opensource"]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Přispívání
|
||||
|
||||
Pull requesty vítány. Repo: https://git.arch-linux.cz/Mamutovo/fedi_start
|
||||
|
||||
+33
-2
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>CZ účty na Mastodonu – Mamutovo</title>
|
||||
<script>if(localStorage.getItem('theme')==='light')document.documentElement.classList.add('light');</script>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;700;800&display=swap');
|
||||
|
||||
@@ -20,7 +21,22 @@
|
||||
--muted2: #555;
|
||||
--border: #282828;
|
||||
--radius: 10px;
|
||||
--nav-bg: rgba(13,13,13,0.9);
|
||||
}
|
||||
html.light {
|
||||
--bg: #ffffff;
|
||||
--surface: #f8f8f8;
|
||||
--surface2: #f0f0f0;
|
||||
--surface3: #e8e8e8;
|
||||
--border: #e0e0e0;
|
||||
--text: #1a1a1a;
|
||||
--muted: #666666;
|
||||
--muted2: #999999;
|
||||
--accent: #06b6d4;
|
||||
--nav-bg: rgba(245,245,245,0.9);
|
||||
}
|
||||
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 1rem; line-height: 1; flex-shrink: 0; color: var(--text); transition: border-color .15s; }
|
||||
.theme-toggle:hover { border-color: var(--accent); }
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
@@ -38,7 +54,7 @@ nav {
|
||||
justify-content: space-between;
|
||||
padding: 1rem 2rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: rgba(13,13,13,0.9);
|
||||
background: var(--nav-bg);
|
||||
backdrop-filter: blur(10px);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
@@ -303,6 +319,11 @@ select:focus { border-color: var(--accent); }
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
}
|
||||
.card-avatar {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
border-color: var(--accent);
|
||||
@@ -566,6 +587,7 @@ select:focus { border-color: var(--accent); }
|
||||
}
|
||||
|
||||
.site-footer-inner a:hover { color: var(--accent); }
|
||||
.modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.7);z-index:1000;align-items:center;justify-content:center} .modal-overlay.active{display:flex} .modal-card{background:var(--surface);border-radius:16px;max-width:420px;width:90%;overflow:hidden;position:relative} .modal-close{position:absolute;top:.75rem;right:.75rem;background:none;border:none;color:var(--muted);font-size:1.2rem;cursor:pointer} .modal-header{position:relative;height:120px;background:var(--surface2)} .modal-header-img{width:100%;height:120px;object-fit:cover} .modal-avatar{width:72px;height:72px;border-radius:12px;border:3px solid var(--surface);position:absolute;bottom:-36px;left:1.2rem} .modal-body{padding:2.5rem 1.2rem 1.2rem} .modal-name{font-size:1.2rem;font-weight:700;color:var(--text)} .modal-handle{color:var(--muted);font-size:.85rem;margin-bottom:.5rem} .modal-bio{color:var(--muted);font-size:.9rem;margin-bottom:.75rem;line-height:1.5} .modal-tags{display:flex;flex-wrap:wrap;gap:.4rem;margin-bottom:.75rem} .modal-stats{display:flex;gap:1.5rem}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -576,6 +598,7 @@ select:focus { border-color: var(--accent); }
|
||||
<a href="start.html">← Průvodce</a>
|
||||
<a href="accounts.html" class="active">CZ účty</a>
|
||||
</div>
|
||||
<button id="theme-toggle" class="theme-toggle" onclick="toggleTheme()" aria-label="Přepnout téma">🌙</button>
|
||||
<span class="nav-updated"><span id="lastUpdated">načítám...</span><span id="refreshCountdown" style="margin-left:0.4rem;color:var(--muted2);font-size:0.65rem;font-family:'Space Mono',monospace;"></span><span id="refreshBadge" style="margin-left:0.5rem;font-size:0.65rem;font-family:'Space Mono',monospace;transition:color 0.3s;"></span></span>
|
||||
</nav>
|
||||
|
||||
@@ -629,6 +652,13 @@ select:focus { border-color: var(--accent); }
|
||||
<div class="empty" id="emptyEl">Žádné účty neodpovídají filtru. Zkus jiný výraz.</div>
|
||||
|
||||
<script>
|
||||
function toggleTheme() {
|
||||
const light = document.documentElement.classList.toggle('light');
|
||||
localStorage.setItem('theme', light ? 'light' : 'dark');
|
||||
document.getElementById('theme-toggle').textContent = light ? '☀️' : '🌙';
|
||||
}
|
||||
if (localStorage.getItem('theme') === 'light') document.getElementById('theme-toggle').textContent = '☀️';
|
||||
|
||||
// ────────────────────────────────
|
||||
// DATA – fallback když není JSON
|
||||
// ────────────────────────────────
|
||||
@@ -857,7 +887,7 @@ function cardHTML(a, idx) {
|
||||
<a class="card-link" href="${a.url}" target="_blank" rel="noopener noreferrer" aria-label="Profil ${a.name}"></a>
|
||||
<div class="card-header">
|
||||
${a.header ? `<img class="card-header-img" src="${a.header}" alt="">` : ''}
|
||||
<img class="card-avatar" src="${av}" alt="" onerror="this.src='${avatarFallback(a.name)}'">
|
||||
<img class="card-avatar" src="${av}" alt="" onclick="event.stopPropagation();openModal(filtered[${idx}])" onerror="this.src='${avatarFallback(a.name)}'">
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-name">${a.name}</div>
|
||||
@@ -1119,5 +1149,6 @@ loadAccounts();
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<div id="profile-modal" class="modal-overlay" onclick="closeModal()"><div class="modal-card" onclick="event.stopPropagation()"><button class="modal-close" onclick="closeModal()">✕</button><div class="modal-header"><img id="modal-header-img" class="modal-header-img" src="" alt="" style="display:none"><img id="modal-avatar" class="modal-avatar" src="" alt=""></div><div class="modal-body"><div id="modal-name" class="modal-name"></div><div id="modal-handle" class="modal-handle"></div><div id="modal-bio" class="modal-bio"></div><div id="modal-tags" class="modal-tags"></div><div class="modal-stats"><div class="stat"><span id="modal-followers" class="stat-val"></span><span class="stat-label">Sledující</span></div><div class="stat"><span id="modal-statuses" class="stat-val"></span><span class="stat-label">Postů</span></div></div><a id="modal-follow" href="" target="_blank" class="follow-btn" style="margin-top:1rem;display:inline-block">+ Sledovat</a></div></div></div><script>function openModal(a){const av=a.avatar||avatarFallback(a.name);document.getElementById('modal-avatar').src=av;document.getElementById('modal-avatar').onerror=function(){this.src=avatarFallback(a.name);};const hi=document.getElementById('modal-header-img');if(a.header){hi.src=a.header;hi.style.display='block';}else{hi.style.display='none';}document.getElementById('modal-name').textContent=a.name;document.getElementById('modal-handle').textContent='@'+a.handle;document.getElementById('modal-bio').textContent=a.bio||'';document.getElementById('modal-tags').innerHTML=(a.tags||[]).map(t=>`<span class="card-tag">#${t}</span>`).join('');document.getElementById('modal-followers').textContent=fmt(a.followers);document.getElementById('modal-statuses').textContent=fmt(a.statuses);document.getElementById('modal-follow').href=followUrl(a.handle);document.getElementById('profile-modal').classList.add('active');document.body.style.overflow='hidden';}function closeModal(){document.getElementById('profile-modal').classList.remove('active');document.body.style.overflow='';}document.addEventListener('keydown',e=>{if(e.key==='Escape')closeModal();});</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Aplikace – Mamutovo</title>
|
||||
<script>if(localStorage.getItem('theme')==='light')document.documentElement.classList.add('light');</script>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;700;800&display=swap');
|
||||
|
||||
@@ -21,6 +22,19 @@
|
||||
--border: #282828;
|
||||
--radius: 10px;
|
||||
}
|
||||
html.light {
|
||||
--bg: #ffffff;
|
||||
--surface: #f8f8f8;
|
||||
--surface2: #f0f0f0;
|
||||
--surface3: #e8e8e8;
|
||||
--border: #e0e0e0;
|
||||
--text: #1a1a1a;
|
||||
--muted: #666666;
|
||||
--muted2: #999999;
|
||||
--accent: #06b6d4;
|
||||
}
|
||||
.theme-toggle { background: var(--surface); border: 1px solid var(--border); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 1rem; line-height: 1; position: fixed; top: 1rem; right: 1rem; z-index: 200; transition: border-color .15s; }
|
||||
.theme-toggle:hover { border-color: var(--accent); }
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
@@ -278,6 +292,7 @@ h1 span { color: var(--accent); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button id="theme-toggle" class="theme-toggle" onclick="toggleTheme()" aria-label="Přepnout téma">🌙</button>
|
||||
|
||||
<div class="header">
|
||||
<a href="https://fedi.mamutovo.cz" class="badge">🦣 MAMUTOVO · APLIKACE</a>
|
||||
@@ -485,6 +500,13 @@ h1 span { color: var(--accent); }
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleTheme() {
|
||||
const light = document.documentElement.classList.toggle('light');
|
||||
localStorage.setItem('theme', light ? 'light' : 'dark');
|
||||
document.getElementById('theme-toggle').textContent = light ? '☀️' : '🌙';
|
||||
}
|
||||
if (localStorage.getItem('theme') === 'light') document.getElementById('theme-toggle').textContent = '☀️';
|
||||
|
||||
(function () {
|
||||
const filters = document.querySelectorAll('.ftag');
|
||||
const cards = document.querySelectorAll('.card');
|
||||
|
||||
+31
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Základy Mastodonu – Mamutovo</title>
|
||||
<script>if(localStorage.getItem('theme')==='light')document.documentElement.classList.add('light');</script>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;700;800&display=swap');
|
||||
|
||||
@@ -18,6 +19,17 @@
|
||||
--border: #2e2e2e;
|
||||
--radius: 10px;
|
||||
}
|
||||
html.light {
|
||||
--bg: #ffffff;
|
||||
--surface: #f8f8f8;
|
||||
--surface2: #f0f0f0;
|
||||
--border: #e0e0e0;
|
||||
--text: #1a1a1a;
|
||||
--muted: #666666;
|
||||
--accent: #06b6d4;
|
||||
}
|
||||
.theme-toggle { background: var(--surface); border: 1px solid var(--border); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 1rem; line-height: 1; position: fixed; top: 1rem; right: 1rem; z-index: 200; transition: border-color .15s; }
|
||||
.theme-toggle:hover { border-color: var(--accent); }
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
@@ -174,6 +186,7 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button id="theme-toggle" class="theme-toggle" onclick="toggleTheme()" aria-label="Přepnout téma">🌙</button>
|
||||
|
||||
<div class="hero">
|
||||
<a href="https://fedi.mamutovo.cz" class="badge">🦣 MAMUTOVO · ZÁKLADY</a>
|
||||
@@ -208,6 +221,16 @@
|
||||
<p><code>@Archos@mamutovo.cz</code> a <code>@archos@mamutovo.cz</code> jsou stejný účet. Velká a malá písmena nehrají roli.</p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Co je toot?</h2>
|
||||
<p>Toot je příspěvek na Mastodonu – jako tweet na Twitteru. Může mít až 2000 znaků (na Mamutovo), obrázky, ankety nebo upozornění pro citlivý obsah. Veřejné tooty vidí celý Fediverse.</p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Co je boost?</h2>
|
||||
<p>Boost je přesdílení cizího tootu – jako retweet. Toot se zobrazí tvým sledujícím. Boost je způsob jak podpořit zajímavý obsah a pomoci mu se šířit. Na rozdíl od Twitteru nelze boost okomentovat.</p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Jak správně odpovídat</h2>
|
||||
<p>Při odpovědi na toot se automaticky přidají zmínky (@) všech lidí v konverzaci.</p>
|
||||
@@ -243,5 +266,13 @@
|
||||
<a href="start.html">← Zpět na průvodce</a>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleTheme() {
|
||||
const light = document.documentElement.classList.toggle('light');
|
||||
localStorage.setItem('theme', light ? 'light' : 'dark');
|
||||
document.getElementById('theme-toggle').textContent = light ? '☀️' : '🌙';
|
||||
}
|
||||
if (localStorage.getItem('theme') === 'light') document.getElementById('theme-toggle').textContent = '☀️';
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
<!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>
|
||||
<script>if(localStorage.getItem('theme')==='light')document.documentElement.classList.add('light');</script>
|
||||
<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;
|
||||
--nav-bg: rgba(13,13,13,0.95);
|
||||
}
|
||||
html.light {
|
||||
--bg: #ffffff;
|
||||
--surface: #f8f8f8;
|
||||
--surface2: #f0f0f0;
|
||||
--border: #e0e0e0;
|
||||
--text: #1a1a1a;
|
||||
--muted: #666666;
|
||||
--accent: #06b6d4;
|
||||
--nav-bg: rgba(245,245,245,0.95);
|
||||
}
|
||||
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 1rem; line-height: 1; flex-shrink: 0; color: var(--text); transition: border-color .15s; }
|
||||
.theme-toggle:hover { border-color: var(--accent); }
|
||||
html.light .post { box-shadow: 0 1px 3px rgba(0,0,0,.08); }
|
||||
* { 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: var(--nav-bg); 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; gap: .75rem; }
|
||||
.post { display: flex; gap: .75rem; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; 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>
|
||||
<button id="theme-toggle" class="theme-toggle" onclick="toggleTheme()" aria-label="Přepnout téma">🌙</button>
|
||||
</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>
|
||||
function toggleTheme() {
|
||||
const light = document.documentElement.classList.toggle('light');
|
||||
localStorage.setItem('theme', light ? 'light' : 'dark');
|
||||
document.getElementById('theme-toggle').textContent = light ? '☀️' : '🌙';
|
||||
}
|
||||
if (localStorage.getItem('theme') === 'light') document.getElementById('theme-toggle').textContent = '☀️';
|
||||
|
||||
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>
|
||||
@@ -111,3 +111,4 @@ Oskar456@mastodon.social,true,false,
|
||||
jmlich@fosstodon.org,true,false,
|
||||
ronny@metalhead.club,true,false,
|
||||
vancura@mastodon.design,true,false,
|
||||
shimon@gts.shimonh.eu,true,false,
|
||||
|
||||
|
+20
-9
@@ -37,6 +37,17 @@ def _load_tokens():
|
||||
break
|
||||
if val:
|
||||
tokens[key] = val.strip()
|
||||
# per-instance GTS tokeny: GTS_TOKEN_<DOMAIN>
|
||||
for key, val in os.environ.items():
|
||||
if key.startswith("GTS_TOKEN_") and val:
|
||||
tokens[key] = val.strip()
|
||||
for line in env_lines:
|
||||
line = line.strip()
|
||||
if line.startswith("GTS_TOKEN_") and "=" in line:
|
||||
key, val = line.split("=", 1)
|
||||
key = key.strip()
|
||||
if key not in tokens and val.strip():
|
||||
tokens[key] = val.strip()
|
||||
# fallback: raw token value (legacy .env bez klíče)
|
||||
if "MASTODON_TOKEN" not in tokens:
|
||||
for line in env_lines:
|
||||
@@ -47,8 +58,9 @@ def _load_tokens():
|
||||
return tokens
|
||||
|
||||
_TOKENS = _load_tokens()
|
||||
MASTODON_TOKEN = _TOKENS.get("MASTODON_TOKEN")
|
||||
GTS_TOKEN = _TOKENS.get("GTS_TOKEN")
|
||||
MASTODON_TOKEN = _TOKENS.get("MASTODON_TOKEN")
|
||||
GTS_TOKEN = _TOKENS.get("GTS_TOKEN") # legacy fallback
|
||||
_GTS_INSTANCE_TOKENS = {k: v for k, v in _TOKENS.items() if k.startswith("GTS_TOKEN_")}
|
||||
|
||||
_gts_cache: dict[str, bool] = {}
|
||||
|
||||
@@ -62,8 +74,11 @@ def _is_gts(instance: str) -> bool:
|
||||
return result
|
||||
|
||||
def _token_for(instance: str) -> str | None:
|
||||
if GTS_TOKEN and _is_gts(instance):
|
||||
return GTS_TOKEN
|
||||
if _is_gts(instance):
|
||||
key = "GTS_TOKEN_" + re.sub(r"[.\-]", "_", instance).upper()
|
||||
token = _GTS_INSTANCE_TOKENS.get(key) or GTS_TOKEN
|
||||
if token:
|
||||
return token
|
||||
return MASTODON_TOKEN
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s", datefmt="%H:%M:%S")
|
||||
@@ -177,11 +192,6 @@ def load_manual_accounts(seen_handles=None):
|
||||
url = f"https://{instance}/api/v1/accounts/lookup?acct={urllib.parse.quote(handle_part)}"
|
||||
token = _token_for(instance)
|
||||
acc = api_get(url, token=token)
|
||||
if not acc or not isinstance(acc, dict):
|
||||
log.debug(f" {instance}: is_gts={_is_gts(instance)}, gts_token={GTS_TOKEN is not None}")
|
||||
if GTS_TOKEN and _is_gts(instance):
|
||||
log.debug(f" {handle}: zkouším GTS_TOKEN")
|
||||
acc = api_get(url, token=GTS_TOKEN)
|
||||
if not acc or not isinstance(acc, dict):
|
||||
log.warning(f" {handle}: lookup selhal")
|
||||
continue
|
||||
@@ -287,6 +297,7 @@ def _to_output(acc):
|
||||
"handle": handle,
|
||||
"bio": bio[:220],
|
||||
"avatar": acc.get("avatar", ""),
|
||||
"header": acc.get("header_static", "") if "missing" not in acc.get("header_static", "") else "",
|
||||
"followers": acc.get("followers_count", 0),
|
||||
"statuses": acc.get("statuses_count", 0),
|
||||
"score": score(acc),
|
||||
|
||||
+21
-1
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Začni na Mastodonu – Mamutovo</title>
|
||||
<script>if(localStorage.getItem('theme')==='light')document.documentElement.classList.add('light');</script>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;700;800&display=swap');
|
||||
|
||||
@@ -18,6 +19,17 @@
|
||||
--border: #2e2e2e;
|
||||
--radius: 10px;
|
||||
}
|
||||
html.light {
|
||||
--bg: #ffffff;
|
||||
--surface: #f8f8f8;
|
||||
--surface2: #f0f0f0;
|
||||
--border: #e0e0e0;
|
||||
--text: #1a1a1a;
|
||||
--muted: #666666;
|
||||
--accent: #06b6d4;
|
||||
}
|
||||
.theme-toggle { background: var(--surface); border: 1px solid var(--border); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 1rem; line-height: 1; position: fixed; top: 1rem; right: 1rem; z-index: 200; transition: border-color .15s; }
|
||||
.theme-toggle:hover { border-color: var(--accent); }
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
@@ -382,6 +394,7 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button id="theme-toggle" class="theme-toggle" onclick="toggleTheme()" aria-label="Přepnout téma">🌙</button>
|
||||
|
||||
<div class="hero">
|
||||
<a href="https://fedi.mamutovo.cz" class="badge">🦣 MAMUTOVO · PRŮVODCE</a>
|
||||
@@ -389,7 +402,7 @@
|
||||
<p class="tagline">
|
||||
Žádné algoritmy. Žádné reklamy. <strong>Patří komunitě.</strong><br>
|
||||
Tyhle 4 kroky ti zaplní feed a pomůžou udělat první post.<br>
|
||||
<a href="https://about.mamutovo.cz" target="_blank" class="about-link">Co je Mamutovo.cz?</a>
|
||||
<a href="https://about.mamutovo.cz" target="_blank" class="about-link">Co je Mamutovo.cz?</a> · <a href="deni.html" class="about-link">Co se teď děje? ⚡</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -488,6 +501,13 @@ Rád/a poznám nové lidi 🙂 #Představení #novacek #cesky
|
||||
<div class="copy-toast" id="toast">Zkopírováno! Vlož do pole pro post ✓</div>
|
||||
|
||||
<script>
|
||||
function toggleTheme() {
|
||||
const light = document.documentElement.classList.toggle('light');
|
||||
localStorage.setItem('theme', light ? 'light' : 'dark');
|
||||
document.getElementById('theme-toggle').textContent = light ? '☀️' : '🌙';
|
||||
}
|
||||
if (localStorage.getItem('theme') === 'light') document.getElementById('theme-toggle').textContent = '☀️';
|
||||
|
||||
function copyPost(el) {
|
||||
const text = el.innerText.trim();
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
|
||||
Reference in New Issue
Block a user