Refactor web server and release workflow
This commit is contained in:
@@ -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, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
Reference in New Issue
Block a user