Refactor web server and release workflow

This commit is contained in:
2026-07-14 18:35:24 +01:00
parent 9070ded66d
commit 4e0e87c86c
76 changed files with 616 additions and 84 deletions
+56
View File
@@ -0,0 +1,56 @@
const PLAYER_PUBLIC_BASE_URL = (process.env.PLAYER_PUBLIC_BASE_URL || process.env.PLAYER_BASE_URL || 'http://localhost:3001').replace(/\/$/, '');
function escapeHtml(value) {
return String(value ?? '')
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
function screenPlayerUrl(slug) {
return `${PLAYER_PUBLIC_BASE_URL}/screen/${encodeURIComponent(slug)}`;
}
function renderAdminShell(active, title, body, message) {
const navItems = [
{ key: 'dashboard', label: 'Dashboard', href: '/admin' },
{ key: 'playlists', label: 'Playlists', href: '/admin/playlists' },
{ key: 'screens', label: 'Screens', href: '/admin/screens' },
{ key: 'slides', label: 'Slides', href: '/admin/slides' },
{ key: 'templates', label: 'Slide templates', href: '/admin/templates' }
].map((item) => `
<a class="nav-item ${active === item.key ? 'active' : ''}" href="${item.href}">${escapeHtml(item.label)}</a>
`).join('');
return `<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>${escapeHtml(title)} - Pulse Signage</title>
<link rel="stylesheet" href="/assets/css/admin.css" />
</head>
<body>
<div class="app">
<aside class="sidebar">
<h1>Pulse Signage</h1>
<nav class="nav">${navItems}</nav>
</aside>
<main class="content">
<div class="page-header">
<h2>${escapeHtml(title)}</h2>
</div>
${body}
</main>
</div>
</body>
</html>`;
}
module.exports = {
escapeHtml,
screenPlayerUrl,
renderAdminShell
};