update dependencies, fixes to support new authentication features
[websub-hub] / src / template / root-html.js
index 8797564e54e93b1ef816de4c4e4b6e01269e3b7c..575d4bcbdf439c0287f1bc565e15fb4d10834ab0 100644 (file)
@@ -1,7 +1,29 @@
 'use strict';
 
 const th = require('./template-helper');
+const { sessionNavLinks } = require('@squeep/authentication-module');
 
+/**
+ *
+ * @param {string} pageTitle page title
+ * @param {string} logoUrl logo url
+ * @returns {string} element
+ */
+function hAppSection(pageTitle, logoUrl) {
+  return `      <section hidden class="h-app">
+        <h2>h-app Information for IndieAuth Logins</h2>
+        <img src="${logoUrl}" class="u-logo">
+        <a href="" class="u-url p-name">${pageTitle}</a>
+        <p class="p-summary">
+          This is a WebSub Hub service, facilitating content distribution.
+          Authenticated users may view details of any syndications related to their profile.
+        </p>
+      </section>`;
+}
+
+/**
+ * @returns {string} element
+ */
 function aboutSection() {
   return `      <section class="about">
         <h2>What</h2>
@@ -17,6 +39,12 @@ function aboutSection() {
       </section>`;
 }
 
+/**
+ *
+ * @param {boolean} isPublicHub is public hub
+ * @param {string} hubURL hub url
+ * @returns {string} html
+ */
 function usageSection(isPublicHub, hubURL) {
   const usageContent = isPublicHub ? `      <h2>Public Hub</h2>
       <p>
@@ -82,7 +110,7 @@ function usageSection(isPublicHub, hubURL) {
       </div>
       <div>
         <h3>Publishing Updates</h3>
-        To notify the Hub that a topic&apos;s content has been updated and should be distributed to subscribers, send a <code>POST</code> request with Form Data (<code>application/x-www-form-urlencoded</code>):
+        To notify the Hub either of a new topic to syndicate, or that a topic&apos;s content has been updated and should be distributed to subscribers, send a <code>POST</code> request with Form Data (<code>application/x-www-form-urlencoded</code>):
         <ul>
           <li>
             <code>hub.mode</code> set to <code>publish</code>
@@ -109,6 +137,11 @@ ${usageContent}
       </section>`;
 }
 
+/**
+ *
+ * @param {string} contactHTML html
+ * @returns {string} html
+ */
 function contactSection(contactHTML) {
   let section = '';
   if (contactHTML) {
@@ -121,29 +154,37 @@ ${contactHTML}
 
 /**
  * 
- * @param {Object} ctx
- * @param {Object} options
- * @param {Object} options.manager
- * @param {String} options.adminContactHTML
- * @param {String} options.manager.pageTitle
- * @param {String} options.manager.publicHub
- * @param {Object} options.dingus
- * @param {String} options.dingus.selfBaseUrl
- * @returns {String}
+ * @param {object} ctx context
+ * @param {object} options options
+ * @param {object} options.manager manager options
+ * @param {string} options.adminContactHTML html
+ * @param {string} options.manager.pageTitle title
+ * @param {string} options.manager.publicHub is public
+ * @param {object} options.dingus dingus options
+ * @param {string} options.dingus.selfBaseUrl url
+ * @returns {string} html
  */
 module.exports = (ctx, options) => {
+  const pagePathLevel = 0;
   const pageTitle = options.manager.pageTitle;
   const isPublicHub = options.manager.publicHub;
   const contactHTML = options.adminContactHTML;
   const footerEntries = options.manager.footerEntries;
   const hubURL = options.dingus.selfBaseUrl || '<s>https://hub.example.com/</s>';
-  const headElements = [];
-  const navLinks = [];
-  const mainContent = [
+  const htmlOptions = {
+    pageIdentifier: 'root',
+    pageTitle,
+    logoUrl: options.manager.logoUrl,
+    footerEntries,
+    navLinks: [],
+  };
+  th.navLinks(pagePathLevel, ctx, htmlOptions);
+  sessionNavLinks(pagePathLevel, ctx, htmlOptions);
+  const content = [
     aboutSection(),
     usageSection(isPublicHub, hubURL),
     contactSection(contactHTML),
+    hAppSection(pageTitle, options.manager.logoUrl),
   ];
-  return th.htmlTemplate(1, pageTitle, headElements, navLinks, mainContent, footerEntries,
-  );
+  return th.htmlPage(pagePathLevel, ctx, htmlOptions, content);
 };
\ No newline at end of file