Release 2.7.3
Publish Docker Image / build-and-push (./build/Dockerfile, git.lzstealth.com/lzstealth/pulse-signage-web, web) (push) Successful in 1m15s
Publish Docker Image / build-and-push (./build/Dockerfile.player, git.lzstealth.com/lzstealth/pulse-signage-player, player) (push) Successful in 32s

This commit is contained in:
2026-08-15 11:43:07 +01:00
parent 15dc6eb7f2
commit f0177e6628
25 changed files with 871 additions and 127 deletions
+51 -24
View File
@@ -3,6 +3,10 @@
const fs = require('fs');
const { hasAnyPermission, PERMISSION_DENIED_MESSAGE } = require('#src/rbac');
const fontLibrary = require('#src/web/lib/media/font-library');
const { buildPagination } = require('../../lib/pagination');
const { createSearchMatcher, getSearchQuery, getSortDirectionQuery, getSortQuery, parsePageNumber, sortRows } = require('../../lib/list-query');
const LIST_PAGE_SIZE = 25;
function normalizeFontFamilyName(value) {
return String(value || '').replace(/\s+/g, ' ').trim().toLowerCase();
@@ -43,6 +47,48 @@ async function isFontUsed(pool, family) {
return Number(rows && rows[0] && rows[0].match_count) > 0;
}
async function buildFontsPageData(pool, uploadDir, req, common) {
const library = fontLibrary.loadFontLibrary(uploadDir);
const usedFamilies = await fetchUsedFontFamilies(pool, library.fonts);
const search = common && typeof common.getSearchQuery === 'function' ? common.getSearchQuery(req) : getSearchQuery(req);
const sort = common && typeof common.getSortQuery === 'function' ? common.getSortQuery(req) : getSortQuery(req);
const direction = common && typeof common.getSortDirectionQuery === 'function' ? common.getSortDirectionQuery(req) : getSortDirectionQuery(req);
const searchableFonts = sortRows(library.fonts.map(function (font) {
const family = normalizeFontFamilyName(font.family || font.name);
return Object.assign({}, font, {
inUse: usedFamilies.has(family)
});
}), function (font) {
if (sort === 'file') {
return String(font && font.fileName || '').trim();
}
if (sort === 'format') {
return String(font && font.format || '').trim();
}
if (sort === 'status') {
return font && font.enabled ? 'Enabled' : 'Disabled';
}
return String(font && font.family || font && font.name || '').trim();
}, direction).filter(createSearchMatcher(search, [
'family',
'name',
'fileName',
'format',
function (font) {
return font && font.enabled ? 'enabled' : 'disabled';
}
]));
const pagination = buildPagination(searchableFonts.length, parsePageNumber(req && req.query && req.query.page), 'page', { search: search, sort: sort, direction: direction }, LIST_PAGE_SIZE, 'fonts', 'Font pages');
const startIndex = (pagination.currentPage - 1) * LIST_PAGE_SIZE;
return {
fonts: searchableFonts.slice(startIndex, startIndex + LIST_PAGE_SIZE),
pagination: pagination,
stylesheetHref: library.stylesheetHref
};
}
function redirectToLogin(res, setAuthMessageCookie) {
if (typeof setAuthMessageCookie === 'function') {
setAuthMessageCookie(res, 'Please sign in to continue.');
@@ -71,6 +117,7 @@ function requireFontsAccess(setAuthMessageCookie) {
module.exports = function registerFontRoutes(app, deps) {
const pool = deps.pool;
const common = deps.common || {};
const pages = deps.pages;
const upload = deps.upload;
const uploadDir = deps.uploadDir;
@@ -85,18 +132,8 @@ module.exports = function registerFontRoutes(app, deps) {
app.get('/settings/fonts', requireFontsAccess(setAuthMessageCookie), async function (req, res, next) {
try {
const library = fontLibrary.loadFontLibrary(uploadDir);
const usedFamilies = await fetchUsedFontFamilies(pool, library.fonts);
const fonts = library.fonts.map(function (font) {
const family = normalizeFontFamilyName(font.family || font.name);
return Object.assign({}, font, {
inUse: usedFamilies.has(family)
});
});
res.send(pages.renderFontsPage({
fonts: fonts,
stylesheetHref: library.stylesheetHref
}, req.query.message ? String(req.query.message) : '', req.currentUser));
const data = await buildFontsPageData(pool, uploadDir, req, common);
res.send(pages.renderFontsPage(data, req.query.message ? String(req.query.message) : '', req.currentUser));
} catch (error) {
next(error);
}
@@ -132,19 +169,9 @@ module.exports = function registerFontRoutes(app, deps) {
}
if (error && /already exists/i.test(String(error.message || ''))) {
const library = fontLibrary.loadFontLibrary(uploadDir);
const usedFamilies = await fetchUsedFontFamilies(pool, library.fonts);
const fonts = library.fonts.map(function (font) {
const family = normalizeFontFamilyName(font.family || font.name);
return Object.assign({}, font, {
inUse: usedFamilies.has(family)
});
});
const data = await buildFontsPageData(pool, uploadDir, req, common);
return res.status(400).send(pages.renderFontsPage({
fonts: fonts,
stylesheetHref: library.stylesheetHref
}, String(error.message || 'Font already exists.'), req.currentUser));
return res.status(400).send(pages.renderFontsPage(data, String(error.message || 'Font already exists.'), req.currentUser));
}
next(error);
+1
View File
@@ -9,6 +9,7 @@ module.exports = function renderFontsPage(data, message, currentUser) {
message: message,
currentUser: currentUser || null,
fonts: data.fonts || [],
pagination: data.pagination || null,
stylesheetHref: data.stylesheetHref || ''
});
};