IndieAuth login support, allows viewing of topics related to profile
[websub-hub] / src / template / admin-topic-details-html.js
1 'use strict';
2
3 const th = require('./template-helper');
4
5 /**
6 * Show a topic with all of its subscribers.
7 * @param {Object} ctx
8 * @param {Object} ctx.topic
9 * @param {Object[]} ctx.subscriptions
10 * @param {Object} options
11 * @param {Object} options.manager
12 * @param {String} options.manager.pageTitle
13 * @returns {String}
14 */
15 module.exports = (ctx, options) => {
16 const pageTitle = `${options.manager.pageTitle} - Topic Details`;
17 const headElements = [];
18 const navLinks = [
19 {
20 href: '..',
21 text: '↑ All Topics',
22 },
23 ];
24 const footerEntries = options.manager.footerEntries;
25 if (!ctx.subscriptions) {
26 ctx.subscriptions = [];
27 }
28 return th.htmlTemplate(ctx, 2, pageTitle, headElements, navLinks, [
29 ` <section class="topics">
30 <table>
31 <thead>`,
32 th.renderTopicRowHeader(),
33 ` </thead>
34 <tbody>`,
35 ...(ctx.topic && [ th.renderTopicRow(ctx.topic, ctx.subscriptions, false) ] || []),
36 ` </tbody>
37 </table>
38 </section>`,
39 ` <section class="subscriptions">
40 <p>${ctx.subscriptions.length ? ctx.subscriptions.length : 'no'} subscription${(ctx.subscriptions.length === 1) ? '' : 's'}</p>
41 <table>
42 <thead>`,
43 th.renderSubscriptionRowHeader(),
44 ` </thead>
45 <tbody>`,
46 ...(ctx.subscriptions && ctx.subscriptions.map(th.renderSubscriptionRow)),
47 ` </tbody>
48 </table>
49 </section>`,
50 ], footerEntries);
51 };