IndieAuth login support, allows viewing of topics related to profile
[websub-hub] / src / template / admin-ia-html.js
diff --git a/src/template/admin-ia-html.js b/src/template/admin-ia-html.js
new file mode 100644 (file)
index 0000000..103582d
--- /dev/null
@@ -0,0 +1,39 @@
+'use strict';
+
+const th = require('./template-helper');
+
+function errorsSection(ctx) {
+  return (ctx.errors && ctx.errors.length) ? `        <section class="errors">
+          <h2>Troubles</h2>
+          <p>Problems were encountered while trying to authenticate your profile URL.</p>
+          <ul>` +
+          ctx.errors.map((error) => `<li>${error}</li>`).join('\n') + `
+          </ul>
+        </section>
+        <div>
+          <a href="./login">Try Again?</a>
+        </div>`
+    : '';
+}
+
+/**
+ * Render any errors from attempting IndieAuth.
+ * @param {Object} ctx
+ * @param {String[]} ctx.errors
+ * @param {Object} options
+ * @param {Object} options.manager
+ * @param {String} options.manager.pageTitle
+ * @param {Object} options.dingus
+ * @param {String} options.dingus.selfBaseUrl
+ * @returns {String}
+ */
+module.exports = (ctx, options) => {
+  const pageTitle = options.manager.pageTitle;
+  const footerEntries = options.manager.footerEntries;
+  const headElements = [];
+  const navLinks = [];
+  const mainContent = [
+    errorsSection(ctx),
+  ];
+  return th.htmlTemplate(ctx, 2, pageTitle, headElements, navLinks, mainContent, footerEntries);
+};
\ No newline at end of file