3 const th
= require('./template-helper');
7 * @param {string} pageTitle page title
8 * @param {string} logoUrl logo url
9 * @returns {string} element
11 function hAppSection(pageTitle
, logoUrl
) {
12 return ` <section hidden class="h-app">
13 <h2>h-app Information for IndieAuth Logins</h2>
14 <img src="${logoUrl}" class="u-logo">
15 <a href="" class="u-url p-name">${pageTitle}</a>
17 This is a WebSub Hub service, facilitating content distribution.
18 Authenticated users may view details of any syndications related to their profile.
24 * @returns {string} element
26 function aboutSection() {
27 return ` <section class="about">
30 This is a <a class="external" href="https://www.w3.org/TR/websub/">WebSub</a> Hub service.
33 It facilitates the timely distribution of new content from publishers to subscribers.
36 The typical use-case is where the content is a blog or news feed, but any type of content may be syndicated.
43 * @param {boolean} isPublicHub is public hub
44 * @param {string} hubURL hub url
45 * @returns {string} html
47 function usageSection(isPublicHub
, hubURL
) {
48 const usageContent
= isPublicHub
? ` <h2>Public Hub</h2>
50 This hub is available as a public resource; any topic which lists it as a hub can be syndicated.
53 To use this hub, your content needs to include some Link relations.
56 <h3>For Any Content</h3>
59 The content must be served with a <code>Link</code> HTTP header indicating this service as the <code>hub</code> relation.
61 <figcaption>Example:</figcaption>
63 Link: <${hubURL}>; rel="hub"
68 The content must be served with a <code>Link</code> HTTP header indicating its own URL with the <code>self</code> relation.
70 <figcaption>Example:</figcaption>
72 Link: <https://example.com/feed/>; rel="self"
77 Ideally, these should be combined in one header.
79 <figcaption>Example:</figcaption>
81 Link: <${hubURL}>; rel="hub", <https://example.com/feed/>; rel="self"
88 <h3>For Atom or RSS feeds</h3>
91 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.
93 <figcaption>Example:</figcaption>
95 <link xmlns="http://www.w3.org/2005/Atom" href="${hubURL}" rel="hub">
100 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.
102 <figcaption>Example:</figcaption>
104 <link xmlns="http://www.w3.org/2005/Atom" href="https://example.com/blog/feed" rel="self" type="application/atom+xml">
111 <h3>Publishing Updates</h3>
112 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>):
115 <code>hub.mode</code> set to <code>publish</code>
118 <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)
122 <figcaption>Example:</figcaption>
124 curl ${hubURL} -d'hub.mode=publish' -d'hub.url=https://example.com/blog_one/feed' -d'hub.url=https://example.com/blog_two/feed'
131 This hub only serves specific topics.
134 <section class="usage">
141 * @param {string} contactHTML html
142 * @returns {string} html
144 function contactSection(contactHTML
) {
147 section
= ` <section>
156 * @param {object} ctx context
157 * @param {object} options options
158 * @param {object} options.manager manager options
159 * @param {string} options.adminContactHTML html
160 * @param {string} options.manager.pageTitle title
161 * @param {string} options.manager.publicHub is public
162 * @param {object} options.dingus dingus options
163 * @param {string} options.dingus.selfBaseUrl url
164 * @returns {string} html
166 module
.exports
= (ctx
, options
) => {
167 const pageTitle
= options
.manager
.pageTitle
;
168 const isPublicHub
= options
.manager
.publicHub
;
169 const contactHTML
= options
.adminContactHTML
;
170 const footerEntries
= options
.manager
.footerEntries
;
171 const hubURL
= options
.dingus
.selfBaseUrl
|| '<s>https://hub.example.com/</s>';
176 const htmlOptions
= {
178 logoUrl: options
.manager
.logoUrl
,
184 usageSection(isPublicHub
, hubURL
),
185 contactSection(contactHTML
),
186 hAppSection(pageTitle
, options
.manager
.logoUrl
),
188 return th
.htmlPage(0, ctx
, htmlOptions
, content
);