From 9915fd047ecd95692e53d93ddb3ad25ae1680925 Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Mon, 16 Aug 2021 13:29:39 -0700 Subject: [PATCH] allow customizing html footer via config --- CHANGELOG.md | 4 ++++ config/default.js | 4 ++++ src/template/admin-overview-html.js | 3 ++- src/template/admin-topic-details-html.js | 3 ++- src/template/root-html.js | 7 +++++-- src/template/template-helper.js | 25 ++++++++++-------------- 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05ed31d..759570c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Releases and notable changes to this project are documented here. - Prevent task processor from being re-invoked if it is already running. +### Added + +- Allow more configuration of html page content. + ## [v1.1.3] - 2021-08-13 ### Fixed diff --git a/config/default.js b/config/default.js index 1905315..70837b1 100644 --- a/config/default.js +++ b/config/default.js @@ -44,6 +44,10 @@ const defaultOptions = { manager: { pageTitle: packageName, // title on html pages + footerEntries: [ // common footers on all html pages + 'Development Repository / GitHub mirror', + '©', + ], strictSecrets: false, // If true, reject requests with secrets but not over https publicHub: true, // Accept publish requests as new topics. processImmediately: true, // If true, immediately attempt to process requests when accepted. diff --git a/src/template/admin-overview-html.js b/src/template/admin-overview-html.js index b86f7af..3d4f62c 100644 --- a/src/template/admin-overview-html.js +++ b/src/template/admin-overview-html.js @@ -15,6 +15,7 @@ module.exports = (ctx, options) => { const pageTitle = `${options.manager.pageTitle} - Topics`; const headElements = []; const navLinks = []; + const footerEntries = options.manager.footerEntries; if (!ctx.topics) { ctx.topics = []; } @@ -30,5 +31,5 @@ module.exports = (ctx, options) => { ` `, - ]); + ], footerEntries); }; \ No newline at end of file diff --git a/src/template/admin-topic-details-html.js b/src/template/admin-topic-details-html.js index 448de09..df13f21 100644 --- a/src/template/admin-topic-details-html.js +++ b/src/template/admin-topic-details-html.js @@ -21,6 +21,7 @@ module.exports = (ctx, options) => { text: '↑ All Topics', }, ]; + const footerEntries = options.manager.footerEntries; if (!ctx.subscriptions) { ctx.subscriptions = []; } @@ -46,5 +47,5 @@ module.exports = (ctx, options) => { ` `, - ]); + ], footerEntries); }; \ No newline at end of file diff --git a/src/template/root-html.js b/src/template/root-html.js index d1939b8..c68d52a 100644 --- a/src/template/root-html.js +++ b/src/template/root-html.js @@ -120,12 +120,15 @@ module.exports = (ctx, options) => { const pageTitle = options.manager.pageTitle; const isPublicHub = options.manager.publicHub; const contactHTML = options.adminContactHTML; + const footerEntries = options.manager.footerEntries; const hubURL = options.dingus.selfBaseUrl || 'https://hub.example.com/'; const headElements = []; const navLinks = []; - return th.htmlTemplate(1, pageTitle, headElements, navLinks, [ + const mainContent = [ aboutSection(), usageSection(isPublicHub, hubURL), contactSection(contactHTML), - ]); + ]; + return th.htmlTemplate(1, pageTitle, headElements, navLinks, mainContent, footerEntries, + ); }; \ No newline at end of file diff --git a/src/template/template-helper.js b/src/template/template-helper.js index d3962f9..f36829d 100644 --- a/src/template/template-helper.js +++ b/src/template/template-helper.js @@ -221,22 +221,16 @@ function htmlHeader(pageTitle, navLinks = []) { /** * Close the main section and finish off with boilerplate. + * @param {String[]} footerEntries * @returns {String} */ -function htmlFooter() { +function htmlFooter(footerEntries = []) { return ` -