diff --git a/.gitignore b/.gitignore index 314667d..49e32c8 100644 --- a/.gitignore +++ b/.gitignore @@ -27,5 +27,8 @@ Thumbs.db # --- Playwright test artifacts --- .playwright-mcp/ +# --- Generated version data --- +public/version.json + # --- Internal audit (not for commit) --- SECURITY_AUDIT.md diff --git a/public/admin.css b/public/admin.css index 3bd1a31..e7b072b 100644 --- a/public/admin.css +++ b/public/admin.css @@ -29,6 +29,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b .sidebar nav a.active svg{color:var(--accent)} .sidebar .bottom a[data-nav=home] svg{color:#2563eb} .sidebar .bottom{padding:12px 20px;border-top:1px solid var(--border)} +.sidebar .version{color:var(--muted);font-size:.72rem;padding:0 20px 8px} .sidebar .bottom a{display:flex;align-items:center;gap:10px;color:var(--muted);text-decoration:none;font-size:.8rem;padding:6px 0} .sidebar .bottom a:hover{color:var(--text)} .sidebar .bottom .logout{color:#ef4444;cursor:pointer;margin-top:4px} diff --git a/public/admin.js b/public/admin.js index e7c79b9..34a8bb4 100644 --- a/public/admin.js +++ b/public/admin.js @@ -77,10 +77,26 @@ function buildSidebar(active) { ${nav.map(n => `${n.label}`).join('')}
+
На главную Выйти
`; renderIcons(); + loadVersion(); +} + +async function loadVersion() { + const el = document.getElementById('sidebarVersion'); + if (!el) return; + try { + const res = await fetch(`${API}/version.json?t=${Date.now()}`); + if (!res.ok) { el.textContent = ''; return; } + const v = await res.json(); + if (!v.short) { el.textContent = ''; return; } + const d = (v.date || '').slice(0, 10); + el.textContent = `v${v.short}${d ? ' · ' + d : ''}`; + el.title = `${v.short} · ${v.date || ''}`; + } catch { el.textContent = ''; } } // --- Common UI --- diff --git a/scripts/gen-version.js b/scripts/gen-version.js new file mode 100644 index 0000000..41caf90 --- /dev/null +++ b/scripts/gen-version.js @@ -0,0 +1,18 @@ +const { execSync } = require('child_process'); +const fs = require('fs'); +const path = require('path'); + +function sh(cmd) { + try { return execSync(cmd, { encoding: 'utf8' }).trim(); } catch { return ''; } +} + +const out = { + full: sh('git rev-parse HEAD'), + short: sh('git rev-parse --short HEAD'), + date: sh('git log -1 --format=%cI') +}; + +fs.writeFileSync( + path.join(__dirname, '..', 'public', 'version.json'), + JSON.stringify(out, null, 2) +); \ No newline at end of file diff --git a/scripts/post-commit.sh b/scripts/post-commit.sh new file mode 100755 index 0000000..ea062ed --- /dev/null +++ b/scripts/post-commit.sh @@ -0,0 +1,3 @@ +#!/bin/sh +ROOT="$(git rev-parse --show-toplevel)" +node "$ROOT/scripts/gen-version.js" \ No newline at end of file