IndieAuth login support, allows viewing of topics related to profile
[websub-hub] / src / template / admin-ia-html.js
1 'use strict';
2
3 const th = require('./template-helper');
4
5 function errorsSection(ctx) {
6 return (ctx.errors && ctx.errors.length) ? ` <section class="errors">
7 <h2>Troubles</h2>
8 <p>Problems were encountered while trying to authenticate your profile URL.</p>
9 <ul>` +
10 ctx.errors.map((error) => `<li>${error}</li>`).join('\n') + `
11 </ul>
12 </section>
13 <div>
14 <a href="./login">Try Again?</a>
15 </div>`
16 : '';
17 }
18
19 /**
20 * Render any errors from attempting IndieAuth.
21 * @param {Object} ctx
22 * @param {String[]} ctx.errors
23 * @param {Object} options
24 * @param {Object} options.manager
25 * @param {String} options.manager.pageTitle
26 * @param {Object} options.dingus
27 * @param {String} options.dingus.selfBaseUrl
28 * @returns {String}
29 */
30 module.exports = (ctx, options) => {
31 const pageTitle = options.manager.pageTitle;
32 const footerEntries = options.manager.footerEntries;
33 const headElements = [];
34 const navLinks = [];
35 const mainContent = [
36 errorsSection(ctx),
37 ];
38 return th.htmlTemplate(ctx, 2, pageTitle, headElements, navLinks, mainContent, footerEntries);
39 };