3 const th
= require('./template-helper');
5 function hAppSection(pageTitle
, logoUrl
) {
6 return ` <section hidden class="h-app">
7 <h2>h-app Information for IndieAuth Logins</h2>
8 <img src="${logoUrl}" class="u-logo">
9 <a href="" class="u-url p-name">${pageTitle}</a>
11 This is a WebSub Hub service, facilitating content distribution.
12 Authenticated users may view details of any syndications related to their profile.
17 function aboutSection() {
18 return ` <section class="about">
21 This is a <a class="external" href="https://www.w3.org/TR/websub/">WebSub</a> Hub service.
24 It facilitates the timely distribution of new content from publishers to subscribers.
27 The typical use-case is where the content is a blog or news feed, but any type of content may be syndicated.
32 function usageSection(isPublicHub
, hubURL
) {
33 const usageContent
= isPublicHub
? ` <h2>Public Hub</h2>
35 This hub is available as a public resource; any topic which lists it as a hub can be syndicated.
38 To use this hub, your content needs to include some Link relations.
41 <h3>For Any Content</h3>
44 The content must be served with a <code>Link</code> HTTP header indicating this service as the <code>hub</code> relation.
46 <figcaption>Example:</figcaption>
48 Link: <${hubURL}>; rel="hub"
53 The content must be served with a <code>Link</code> HTTP header indicating its own URL with the <code>self</code> relation.
55 <figcaption>Example:</figcaption>
57 Link: <https://example.com/feed/>; rel="self"
62 Ideally, these should be combined in one header.
64 <figcaption>Example:</figcaption>
66 Link: <${hubURL}>; rel="hub", <https://example.com/feed/>; rel="self"
73 <h3>For Atom or RSS feeds</h3>
76 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.
78 <figcaption>Example:</figcaption>
80 <link xmlns="http://www.w3.org/2005/Atom" href="${hubURL}" rel="hub">
85 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.
87 <figcaption>Example:</figcaption>
89 <link xmlns="http://www.w3.org/2005/Atom" href="https://example.com/blog/feed" rel="self" type="application/atom+xml">
96 <h3>Publishing Updates</h3>
97 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>):
100 <code>hub.mode</code> set to <code>publish</code>
103 <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)
107 <figcaption>Example:</figcaption>
109 curl ${hubURL} -d'hub.mode=publish' -d'hub.url=https://example.com/blog_one/feed' -d'hub.url=https://example.com/blog_two/feed'
116 This hub only serves specific topics.
119 <section class="usage">
124 function contactSection(contactHTML
) {
127 section
= ` <section>
136 * @param {Object} ctx
137 * @param {Object} options
138 * @param {Object} options.manager
139 * @param {String} options.adminContactHTML
140 * @param {String} options.manager.pageTitle
141 * @param {String} options.manager.publicHub
142 * @param {Object} options.dingus
143 * @param {String} options.dingus.selfBaseUrl
146 module
.exports
= (ctx
, options
) => {
147 const pageTitle
= options
.manager
.pageTitle
;
148 const isPublicHub
= options
.manager
.publicHub
;
149 const contactHTML
= options
.adminContactHTML
;
150 const footerEntries
= options
.manager
.footerEntries
;
151 const hubURL
= options
.dingus
.selfBaseUrl
|| '<s>https://hub.example.com/</s>';
156 const htmlOptions
= {
158 logoUrl: options
.manager
.logoUrl
,
164 usageSection(isPublicHub
, hubURL
),
165 contactSection(contactHTML
),
166 hAppSection(pageTitle
, options
.manager
.logoUrl
),
168 return th
.htmlPage(0, ctx
, htmlOptions
, content
);