-function renderNavLink(nav) {
- return `<li>
- <a href="${nav.href}"${nav.class ? (' class="' + nav.class + '"') : ''}>${nav.text}</a>
-</li>`;
-}
-
-
-/**
- * Render the navigation header, and open the main section.
- * @param {String} pageTitle
- * @param {Object[]} navLinks
- * @returns {String}
- */
-function htmlHeader(pageTitle, navLinks = []) {
- return ` <header>
- <h1>${pageTitle}</h1>
- <nav>` +
- (navLinks.length ? `
- <ol>
- ${navLinks.map((l) => renderNavLink(l)).join('\n')}
- </ol>`
- : '') + `
- </nav>
- </header>
- <main>`;
-}
-
-
-/**
- * Close the main section and finish off with boilerplate.
- * @param {String[]} footerEntries
- * @returns {String}
- */
-function htmlFooter(footerEntries = []) {
- return ` </main>
- <footer>` +
- (footerEntries.length ? `
- <ol>` + footerEntries.map((f) => ` <li>${f}</li>`).join('\n') + `
- </ol>`
- : '') + `
- </footer>`;
-}
-
-
-/**
- * Render all parts of an HTML page. Adds user logout nav link automatically.
- * @param {Object} ctx
- * @param {Number} pagePathLevel
- * @param {String} pageTitle
- * @param {String[]} headElements
- * @param {Object[]} navLinks
- * @param {String[]} main
- * @param {String[]} footerEntries
- * @returns {String}
- */
-function htmlTemplate(ctx, pagePathLevel, pageTitle, headElements = [], navLinks = [], main = [], footerEntries = []) {
- const user = (ctx && ctx.session && ctx.session.authenticatedProfile) || (ctx && ctx.session && ctx.session.authenticatedIdentifier);
- if (user) {
- let logoutPath;
- if (pagePathLevel > 0) {
- logoutPath = `${'../'.repeat(pagePathLevel - 1)}`;
- } else {
- logoutPath = 'admin/';
- }
- navLinks.push({
- text: `Logout (${user})`,
- href: `${logoutPath}logout`,
- });