3 const th
= require('./template-helper');
5 function aboutSection() {
6 return ` <section class="about">
9 This is a <a class="external" href="https://www.w3.org/TR/websub/">WebSub</a> Hub service.
12 It facilitates the timely distribution of new content from publishers to subscribers.
15 The typical use-case is where the content is a blog or news feed, but any type of content may be syndicated.
20 function usageSection(isPublicHub
, hubURL
) {
21 const usageContent
= isPublicHub
? ` <h2>Public Hub</h2>
23 This hub is available as a public resource; any topic which lists it as a hub can be syndicated.
26 To use this hub, your content needs to include some Link relations.
29 <h3>For Any Content</h3>
32 The content must be served with a <code>Link</code> HTTP header indicating this service as the <code>hub</code> relation.
34 <figcaption>Example:</figcaption>
36 Link: <${hubURL}>; rel="hub"
41 The content must be served with a <code>Link</code> HTTP header indicating its own URL with the <code>self</code> relation.
43 <figcaption>Example:</figcaption>
45 Link: <https://example.com/feed/>; rel="self"
50 Ideally, these should be combined in one header.
52 <figcaption>Example:</figcaption>
54 Link: <${hubURL}>; rel="hub", <https://example.com/feed/>; rel="self"
61 <h3>For Atom or RSS feeds</h3>
64 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.
66 <figcaption>Example:</figcaption>
68 <link xmlns="http://www.w3.org/2005/Atom" href="${hubURL}" rel="hub">
73 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.
75 <figcaption>Example:</figcaption>
77 <link xmlns="http://www.w3.org/2005/Atom" href="https://example.com/blog/feed" rel="self" type="application/atom+xml">
84 <h3>Publishing Updates</h3>
85 To notify the Hub 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>):
88 <code>hub.mode</code> set to <code>publish</code>
91 <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)
95 <figcaption>Example:</figcaption>
97 curl ${hubURL} -d'hub.mode=publish' -d'hub.url=https://example.com/blog_one/feed' -d'hub.url=https://example.com/blog_two/feed'
104 This hub only serves specific topics.
107 <section class="usage">
112 function contactSection(contactHTML
) {
115 section
= ` <section>
124 * @param {Object} ctx
125 * @param {Object} options
126 * @param {Object} options.manager
127 * @param {String} options.adminContactHTML
128 * @param {String} options.manager.pageTitle
129 * @param {String} options.manager.publicHub
130 * @param {Object} options.dingus
131 * @param {String} options.dingus.selfBaseUrl
134 module
.exports
= (ctx
, options
) => {
135 const pageTitle
= options
.manager
.pageTitle
;
136 const isPublicHub
= options
.manager
.publicHub
;
137 const contactHTML
= options
.adminContactHTML
;
138 const footerEntries
= options
.manager
.footerEntries
;
139 const hubURL
= options
.dingus
.selfBaseUrl
|| '<s>https://hub.example.com/</s>';
140 const headElements
= [];
142 const mainContent
= [
144 usageSection(isPublicHub
, hubURL
),
145 contactSection(contactHTML
),
147 return th
.htmlTemplate(1, pageTitle
, headElements
, navLinks
, mainContent
, footerEntries
,