Add WikiLog page and nav link showing last 50 content changes
This commit is contained in:
@@ -141,6 +141,7 @@ const { title = 'BincioWiki', description = 'La memoria collettiva del gruppo Bi
|
|||||||
)}
|
)}
|
||||||
<div class="ml-auto shrink-0 flex items-center gap-2">
|
<div class="ml-auto shrink-0 flex items-center gap-2">
|
||||||
<span id="nav-handle" class="text-xs text-zinc-500" style="display:none"></span>
|
<span id="nav-handle" class="text-xs text-zinc-500" style="display:none"></span>
|
||||||
|
<a id="nav-wikilog" href="/log/" class="text-xs text-zinc-500 hover:text-white transition-colors px-1" style="display:none">WikiLog</a>
|
||||||
<button id="nav-logout" class="text-xs text-zinc-500 hover:text-white transition-colors px-1" style="display:none">Log out</button>
|
<button id="nav-logout" class="text-xs text-zinc-500 hover:text-white transition-colors px-1" style="display:none">Log out</button>
|
||||||
<button
|
<button
|
||||||
id="theme-toggle"
|
id="theme-toggle"
|
||||||
@@ -173,8 +174,10 @@ const { title = 'BincioWiki', description = 'La memoria collettiva del gruppo Bi
|
|||||||
const user = await r.json().catch(() => null);
|
const user = await r.json().catch(() => null);
|
||||||
if (user) {
|
if (user) {
|
||||||
const handleEl = document.getElementById('nav-handle');
|
const handleEl = document.getElementById('nav-handle');
|
||||||
|
const wikilogEl = document.getElementById('nav-wikilog');
|
||||||
const logoutEl = document.getElementById('nav-logout');
|
const logoutEl = document.getElementById('nav-logout');
|
||||||
if (handleEl) { handleEl.textContent = '@' + user.handle; handleEl.style.display = ''; }
|
if (handleEl) { handleEl.textContent = '@' + user.handle; handleEl.style.display = ''; }
|
||||||
|
if (wikilogEl) wikilogEl.style.display = '';
|
||||||
if (logoutEl) logoutEl.style.display = '';
|
if (logoutEl) logoutEl.style.display = '';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
import Base from '../../layouts/Base.astro';
|
||||||
|
import { SITE_TITLE } from '../../consts';
|
||||||
|
---
|
||||||
|
|
||||||
|
<Base title={`WikiLog — ${SITE_TITLE}`} description="Ultime modifiche al wiki">
|
||||||
|
<div class="max-w-3xl mx-auto">
|
||||||
|
<h1 class="text-3xl font-bold mb-8" style="color: var(--text-primary)">WikiLog</h1>
|
||||||
|
<div id="log-list" class="space-y-2">
|
||||||
|
<p class="text-sm" style="color: var(--text-4)">Caricamento…</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Base>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
fetch('/api/log', { credentials: 'include' })
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(({ log }) => {
|
||||||
|
const el = document.getElementById('log-list');
|
||||||
|
if (!el) return;
|
||||||
|
if (!log?.length) { el.innerHTML = '<p class="text-sm" style="color:var(--text-4)">Nessuna modifica ancora.</p>'; return; }
|
||||||
|
el.innerHTML = log.map((e: any) => {
|
||||||
|
const [author, rest] = e.message.includes(': ') ? e.message.split(': ', 2) : ['', e.message];
|
||||||
|
return `
|
||||||
|
<div class="flex items-baseline gap-3 px-3 py-2 rounded-lg text-sm" style="background:var(--bg-card)">
|
||||||
|
<span class="font-mono text-xs shrink-0" style="color:var(--text-5)">${e.hash}</span>
|
||||||
|
<span class="shrink-0" style="color:var(--accent)">${author || e.author}</span>
|
||||||
|
<span class="flex-1 truncate" style="color:var(--text-2)">${rest || e.message}</span>
|
||||||
|
<span class="shrink-0 text-xs" style="color:var(--text-5)">${e.date}</span>
|
||||||
|
</div>`;
|
||||||
|
}).join('');
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
const el = document.getElementById('log-list');
|
||||||
|
if (el) el.innerHTML = '<p class="text-sm" style="color:#f87171">Errore nel caricamento.</p>';
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user