update html template dependency and templates
[websub-hub] / src / template / admin-overview-html.js
1 'use strict';
2
3 const th = require('./template-helper');
4
5 /**
6 * Show a summary of all topics.
7 * @param {Object} ctx
8 * @param {Object[]} ctx.topics
9 * @param {Object} options
10 * @param {Object} options.manager
11 * @param {String} options.manager.pageTitle
12 * @returns {String}
13 */
14 module.exports = (ctx, options) => {
15 const pageTitle = `${options.manager.pageTitle} - Topics`;
16 const logoUrl = options.manager.logoUrl;
17 const footerEntries = options.manager.footerEntries;
18 if (!ctx.topics) {
19 ctx.topics = [];
20 }
21
22 const htmlOptions = {
23 pageTitle,
24 logoUrl,
25 footerEntries,
26 };
27
28 const content = [
29 ` <section class="topics">
30 <p>${ctx.topics.length ? ctx.topics.length : 'no'} topic${(ctx.topics.length === 1) ? '' : 's'}</p>
31 <table>
32 <thead>`,
33 th.renderTopicRowHeader(),
34 ` </thead>
35 <tbody>`,
36 ...(ctx.topics && ctx.topics.map((topic) => th.renderTopicRow(topic, { length: topic.subscribers }))),
37 ` </tbody>
38 </table>
39 </section>`,
40 ];
41
42 return th.htmlPage(1, ctx, htmlOptions, content);
43 };