From 526e42a2af614cf9f8598c9e00fc09d80e5209a4 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Tue, 5 May 2026 20:45:36 +0200 Subject: [PATCH] srbdbrfdbfha --- .gitea/workflows/deploy.yml | 2 +- app.js | 20 ++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 3f87d81..d5a7a17 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -17,7 +17,7 @@ jobs: - name: Inject commit SHA run: | - echo "const COMMIT_SHA = '${GITEA_SHA}';" > version.js + echo "${GITEA_SHA}" > version.sha - name: Upload via FTP uses: SamKirkland/FTP-Deploy-Action@v4.3.4 diff --git a/app.js b/app.js index 1550a2e..0c5d40f 100644 --- a/app.js +++ b/app.js @@ -479,33 +479,25 @@ window.addEventListener('keydown', (e)=>{ // small helper to set initial focus - mobile browsers will not open keyboard for divs document.addEventListener('touchstart', ()=>{}, {passive:true}) -// Load commit SHA into footer (robust: prefers window.COMMIT_SHA, then meta tag, then fetch plain file) +// Load commit SHA into footer (simple: prefer window.COMMIT_SHA/meta, else fetch /version.sha which contains only the hash) document.addEventListener('DOMContentLoaded', async () => { const el = document.getElementById('commit-sha') if (!el) return - // 1) prefer a global injected by CI: window.COMMIT_SHA let sha = (window.COMMIT_SHA || '').toString().trim() - // 2) fallback to meta tag if CI injects that instead if (!sha) { const meta = document.querySelector('meta[name="commit-sha"]') if (meta && meta.content) sha = meta.content.trim() } - // 3) finally try to fetch the external file (works if it's plain text or a tiny JS file) if (!sha) { try { - const res = await fetch('/version.js', { cache: 'no-cache' }) + const res = await fetch('/version.sha', { cache: 'no-cache' }) if (res.ok) { - const txt = (await res.text()).trim() - // try to extract a quoted/assigned sha like: window.COMMIT_SHA = "abc..." or COMMIT_SHA: "..." - const m = txt.match(/COMMIT_SHA\s*(?:=|:)\s*["']?([0-9a-fA-F]{7,40})["']?/) - if (m && m[1]) sha = m[1] - else { - const firstLine = txt.split(/\r?\n/).find(l => l.trim().length>0) - if (firstLine) sha = firstLine.trim() - } + const txt = await res.text() + const first = txt.split(/\r?\n/).find(l => l.trim().length > 0) + if (first) sha = first.trim() } } catch (e) { - // ignore failures silently + // ignore } } if (sha) el.textContent = sha.slice(0,8)