update dependencies, fixes to support new authentication features
[websub-hub] / src / template / root-html.js
index c68d52a33313810d581029eb2fabf456429a4a54..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>
@@ -46,6 +74,15 @@ function usageSection(isPublicHub, hubURL) {
               </code>
             </figure>
           </li>
+          <li>
+            Ideally, these should be combined in one header.
+            <figure>
+              <figcaption>Example:</figcaption>
+              <code>
+                Link: &lt;${hubURL}&gt;; rel="hub", &lt;https://example.com/feed/&gt;; rel="self"
+              </code>
+            </figure>
+          </li>
         </ul>
       </div>
       <div>
@@ -73,15 +110,21 @@ function usageSection(isPublicHub, hubURL) {
       </div>
       <div>
         <h3>Publishing Updates</h3>
-        Send a <code>POST</code> request to this hub with Form Data:
+        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>
           </li>
           <li>
-            <code>hub.url</code> set to the <code>self</code> link relation of the content
+            <code>hub.url</code> set to the <code>self</code> link relation of the content (this value may be set multiple times, to update more than one topic)
           </li>
         </ul>
+        <figure>
+          <figcaption>Example:</figcaption>
+          <code>
+            curl ${hubURL} -d'hub.mode=publish' -d'hub.url=https://example.com/blog_one/feed' -d'hub.url=https://example.com/blog_two/feed'
+          </code>
+        </figure>
       </div>`
     : `
       <h2>Private Hub</h2>
@@ -94,6 +137,11 @@ ${usageContent}
       </section>`;
 }
 
+/**
+ *
+ * @param {string} contactHTML html
+ * @returns {string} html
+ */
 function contactSection(contactHTML) {
   let section = '';
   if (contactHTML) {
@@ -106,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