indexing_view.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const { html, head, title, link, meta, body, main, p, progress } = require("../server/node_modules/hyperaxe");
  2. const { i18n } = require('./main_views');
  3. const doctypeString = '<!DOCTYPE html>';
  4. function toAttributes(attrs) {
  5. return Object.entries(attrs).map(([key, value]) => `${key}=${JSON.stringify(value)}`).join(', ');
  6. }
  7. exports.indexingView = ({ percent }) => {
  8. const message = `Oasis has only processed ${percent}% of the messages and needs to catch up. This page will refresh every 10 seconds. Thanks for your patience! ❤`;
  9. const nodes = html(
  10. { lang: "en" },
  11. head(
  12. title("Oasis"),
  13. link({ rel: "icon", type: "image/svg+xml", href: "/assets/favicon.svg" }),
  14. meta({ charset: "utf-8" }),
  15. meta({
  16. name: "description",
  17. content: i18n.oasisDescription,
  18. }),
  19. meta({
  20. name: "viewport",
  21. content: "width=device-width, initial-scale=1",
  22. }),
  23. meta({ "http-equiv": "refresh", content: 10 })
  24. ),
  25. body(
  26. main(
  27. { id: "content" },
  28. p(message),
  29. progress({ value: percent, max: 100 })
  30. )
  31. )
  32. );
  33. return doctypeString + nodes.outerHTML;
  34. };