X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=src%2Ftemplate%2Ftemplate-helper.js;h=0ff90772ec7ebd2479344979b08e7d4c075fdb01;hb=5442e8fa4a42ff9e85d94159a5eaedf8ffb9535b;hp=eb379172098925987febda3ee2f0a61339284744;hpb=6013420158d848f6411a7210585d107191fc5ee7;p=websub-hub
diff --git a/src/template/template-helper.js b/src/template/template-helper.js
index eb37917..0ff9077 100644
--- a/src/template/template-helper.js
+++ b/src/template/template-helper.js
@@ -30,7 +30,7 @@ const dateOrNot = (date, otherwise) => {
* @param {Number} seconds
* @returns {String}
*/
- const secondsToPeriod = (seconds) => {
+const secondsToPeriod = (seconds) => {
let value = seconds;
const result = [];
@@ -61,6 +61,11 @@ const dateOrNot = (date, otherwise) => {
* @returns {String}
*/
function renderTopicRow(topic, subscribers, detailsLink = true) {
+ if (!topic) {
+ return `
+ (topic not found) |
+
`;
+ }
return `
${detailsLink ? '' : ''}${topic.url}${detailsLink ? '' : ''} |
${subscribers.length} |
@@ -112,6 +117,11 @@ function renderTopicRowHeader() {
* @returns {String}
*/
function renderSubscriptionRow(subscription) {
+ if (!subscription) {
+ return `
+ (topic not found) |
+
`;
+ }
return `
${subscription.callback} |
${dateOrNot(subscription.created, 'Unknown')} |
@@ -162,7 +172,7 @@ function renderSubscriptionRowHeader() {
function htmlHead(pagePathLevel, pageTitle, headElements = []) {
const rootPathPfx = '../'.repeat(pagePathLevel);
return `
-
` +
headElements.map((e) => `${' '.repeat(2)}${e}`).join('\n') + `
@@ -212,7 +222,7 @@ function htmlHeader(pageTitle, navLinks = []) {
${navLinks.map((l) => renderNavLink(l)).join('\n')}
`
- : '') + `
+ : '') + `
`;
@@ -221,41 +231,50 @@ function htmlHeader(pageTitle, navLinks = []) {
/**
* Close the main section and finish off with boilerplate.
+ * @param {String[]} footerEntries
* @returns {String}
*/
-function htmlFooter() {
+function htmlFooter(footerEntries = []) {
return `
-