3 const th
= require('./template-helper');
4 const { sessionNavLinks
} = require('@squeep/authentication-module');
8 * @param {string} pageTitle page title
9 * @param {string} logoUrl logo url
10 * @returns {string} element
12 function hAppSection(pageTitle
, logoUrl
) {
13 return ` <section hidden class="h-app">
14 <h2>h-app Information for IndieAuth Logins</h2>
15 <img src="${logoUrl}" class="u-logo">
16 <a href="" class="u-url p-name">${pageTitle}</a>
18 This is a WebSub Hub service, facilitating content distribution.
19 Authenticated users may view details of any syndications related to their profile.
25 * @returns {string} element
27 function aboutSection() {
28 return ` <section class="about">
31 This is a <a class="external" href="https://www.w3.org/TR/websub/">WebSub</a> Hub service.
34 It facilitates the timely distribution of new content from publishers to subscribers.
37 The typical use-case is where the content is a blog or news feed, but any type of content may be syndicated.
44 * @param {boolean} isPublicHub is public hub
45 * @param {string} hubURL hub url
46 * @returns {string} html
48 function usageSection(isPublicHub
, hubURL
) {
49 const usageContent
= isPublicHub
? ` <h2>Public Hub</h2>
51 This hub is available as a public resource; any topic which lists it as a hub can be syndicated.
54 To use this hub, your content needs to include some Link relations.
57 <h3>For Any Content</h3>
60 The content must be served with a <code>Link</code> HTTP header indicating this service as the <code>hub</code> relation.
62 <figcaption>Example:</figcaption>
64 Link: <${hubURL}>; rel="hub"
69 The content must be served with a <code>Link</code> HTTP header indicating its own URL with the <code>self</code> relation.
71 <figcaption>Example:</figcaption>
73 Link: <https://example.com/feed/>; rel="self"
78 Ideally, these should be combined in one header.
80 <figcaption>Example:</figcaption>
82 Link: <${hubURL}>; rel="hub", <https://example.com/feed/>; rel="self"
89 <h3>For Atom or RSS feeds</h3>
92 The feed must include a <code>link</code> element within the <code>http://www.w3.org/2005/Atom</code> namespace with the <code>hub</code> relation and this service as the <code>href</code> attribute.
94 <figcaption>Example:</figcaption>
96 <link xmlns="http://www.w3.org/2005/Atom" href="${hubURL}" rel="hub">
101 The feed must include a <code>link</code> element within the <code>http://www.w3.org/2005/Atom</code> namespace with the <code>self</code> relation, its own URL as the <code>href</code> attribute, and its content-type as the <code>type</code> attribute.
103 <figcaption>Example:</figcaption>
105 <link xmlns="http://www.w3.org/2005/Atom" href="https://example.com/blog/feed" rel="self" type="application/atom+xml">
112 <h3>Publishing Updates</h3>
113 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 <code>POST</code> request with Form Data (<code>application/x-www-form-urlencoded</code>):
116 <code>hub.mode</code> set to <code>publish</code>
119 <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)
123 <figcaption>Example:</figcaption>
125 curl ${hubURL} -d'hub.mode=publish' -d'hub.url=https://example.com/blog_one/feed' -d'hub.url=https://example.com/blog_two/feed'
132 This hub only serves specific topics.
135 <section class="usage">
142 * @param {string} contactHTML html
143 * @returns {string} html
145 function contactSection(contactHTML
) {
148 section
= ` <section>
157 * @param {object} ctx context
158 * @param {object} options options
159 * @param {object} options.manager manager options
160 * @param {string} options.adminContactHTML html
161 * @param {string} options.manager.pageTitle title
162 * @param {string} options.manager.publicHub is public
163 * @param {object} options.dingus dingus options
164 * @param {string} options.dingus.selfBaseUrl url
165 * @returns {string} html
167 module
.exports
= (ctx
, options
) => {
168 const pagePathLevel
= 0;
169 const pageTitle
= options
.manager
.pageTitle
;
170 const isPublicHub
= options
.manager
.publicHub
;
171 const contactHTML
= options
.adminContactHTML
;
172 const footerEntries
= options
.manager
.footerEntries
;
173 const hubURL
= options
.dingus
.selfBaseUrl
|| '<s>https://hub.example.com/</s>';
174 const htmlOptions
= {
175 pageIdentifier: 'root',
177 logoUrl: options
.manager
.logoUrl
,
181 th
.navLinks(pagePathLevel
, ctx
, htmlOptions
);
182 sessionNavLinks(pagePathLevel
, ctx
, htmlOptions
);
185 usageSection(isPublicHub
, hubURL
),
186 contactSection(contactHTML
),
187 hAppSection(pageTitle
, options
.manager
.logoUrl
),
189 return th
.htmlPage(pagePathLevel
, ctx
, htmlOptions
, content
);