X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=src%2Ftemplate%2Froot-html.js;h=aa5cebab6ae64da5c3d3d37a2faf954154f39be3;hb=refs%2Fheads%2Fmaster;hp=d1939b84cd6bb690c07c0c65cd5cd7bbab6dd9c7;hpb=38aba0869dc3ade99d439e74cbc6239b4fa1f632;p=websub-hub
diff --git a/src/template/root-html.js b/src/template/root-html.js
index d1939b8..aa5ceba 100644
--- a/src/template/root-html.js
+++ b/src/template/root-html.js
@@ -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 `
+ h-app Information for IndieAuth Logins
+
+ ${pageTitle}
+
+ This is a WebSub Hub service, facilitating content distribution.
+ Authenticated users may view details of any syndications related to their profile.
+
+ `;
+}
+
+/**
+ * @returns {string} element
+ */
function aboutSection() {
return `
What
@@ -9,7 +31,7 @@ function aboutSection() {
This is a WebSub Hub service.
- It facilitates the timely distribution of new content from publishers to subscribers.
+ It facilitates the timely distribution of new content from publishers to subscribers.
The typical use-case is where the content is a blog or news feed, but any type of content may be syndicated.
@@ -17,6 +39,12 @@ function aboutSection() {
`;
}
+/**
+ *
+ * @param {boolean} isPublicHub is public hub
+ * @param {string} hubURL hub url
+ * @returns {string} html
+ */
function usageSection(isPublicHub, hubURL) {
const usageContent = isPublicHub ? ` Public Hub
@@ -46,6 +74,15 @@ function usageSection(isPublicHub, hubURL) {
+
+ Ideally, these should be combined in one header.
+
+ Example:
+
+ Link: <${hubURL}>; rel="hub", <https://example.com/feed/>; rel="self"
+
+
+
@@ -69,19 +106,25 @@ function usageSection(isPublicHub, hubURL) {
-
Publishing Updates
- Send a
POST
request to this hub with Form Data:
+ To notify the Hub either of a new topic to syndicate, or that a topic's content has been updated and should be distributed to subscribers, send a
POST
request with Form Data (
application/x-www-form-urlencoded
):
hub.mode
set to publish
- hub.url
set to the self
link relation of the content
+ hub.url
set to the self
link relation of the content (this value may be set multiple times, to update more than one topic)
+
+ Example:
+
+ curl ${hubURL} -d'hub.mode=publish' -d'hub.url=https://example.com/blog_one/feed' -d'hub.url=https://example.com/blog_two/feed'
+
+
`
: `
Private Hub
@@ -94,6 +137,11 @@ ${usageContent}
`;
}
+/**
+ *
+ * @param {string} contactHTML html
+ * @returns {string} html
+ */
function contactSection(contactHTML) {
let section = '';
if (contactHTML) {
@@ -106,26 +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 || 'https://hub.example.com/ ';
- const headElements = [];
- const navLinks = [];
- return th.htmlTemplate(1, pageTitle, headElements, navLinks, [
+ 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.htmlPage(pagePathLevel, ctx, htmlOptions, content);
};
\ No newline at end of file