/**
* Render a topic as a row of details.
- * @param {Object} topic
- * @param {Object[]} subscribers
- * @param {Boolean} detailsLink
- * @returns {String}
+ * @param {object} topic topic
+ * @param {object[]} subscribers subscribers
+ * @param {boolean} detailsLink link to details
+ * @returns {string} html
*/
function renderTopicRow(topic, subscribers, detailsLink = true) {
if (!topic) {
/**
* Render the header row for topic details.
- * @returns {String}
+ * @returns {string} html
*/
function renderTopicRowHeader() {
return `<tr>
/**
* Render a subscription as a row of details.
- * @param {Object} subscription
- * @returns {String}
+ * @param {object} subscription subscription
+ * @returns {string} html
*/
function renderSubscriptionRow(subscription) {
if (!subscription) {
</tr>`;
}
return `<tr>
- <td scope="row">${subscription.callback}</td>
+ <td>${subscription.callback}</td>
<td>${TemplateHelper.dateFormat(subscription.created, Message.EndOfTime, Message.BeginningOfTime, Message.Unknown)}</td>
<td>${TemplateHelper.dateFormat(subscription.verified, Message.EndOfTime, Message.Never, Message.Never)}</td>
<td>${TemplateHelper.dateFormat(subscription.expires, Message.Never, Message.BeginningOfTime, Message.Never)}</td>
/**
* Render a row of headers for subscription details.
- * @returns {String}
+ * @returns {string} html
*/
function renderSubscriptionRowHeader() {
return `<tr>
/**
* Escape some xml things in strings.
- * @param {String} string
+ * @param {string} string string to escape
+ * @returns {string} escaped
*/
function xmlEscape(string) {
if (typeof string === 'number') {
}[c]));
}
+
+/**
+ * Add common site links to navigation header.
+ * @param {number} pagePathLevel depth from root
+ * @param {object} ctx context
+ * @param {object} options options
+ */
+function navLinks(pagePathLevel, ctx, options) {
+ if (!options.navLinks) {
+ options.navLinks = [];
+ }
+ const rootPath = '../'.repeat(pagePathLevel);
+
+ if (options.pageIdentifier !== 'admin') {
+ options.navLinks.push({
+ text: 'Admin',
+ href: `${rootPath}admin/`,
+ });
+ }
+}
+
+
module.exports = Object.assign(Object.create(TemplateHelper), {
+ navLinks,
xmlEscape,
renderTopicRowHeader,
renderTopicRow,
renderSubscriptionRowHeader,
renderSubscriptionRow,
-});
\ No newline at end of file
+});