indexing_view.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const { a, br, div, h2, p, progress, section, span, strong, meta, head, html, link, title, body, main } = require("../server/node_modules/hyperaxe");
  2. const { template, i18n } = require('./main_views');
  3. const { getConfig } = require('../configs/config-manager.js');
  4. const doctypeString = '<!DOCTYPE html>';
  5. exports.indexingView = ({ percent }) => {
  6. let metaRefresh;
  7. try {
  8. const cfg = getConfig() || {};
  9. const theme = cfg.themes?.current || 'Dark-SNH';
  10. void theme;
  11. } catch (_) {}
  12. const pct = Math.max(0, Math.min(100, Number(percent) || 0));
  13. const headingText = i18n.indexingTitle || 'Synchronizing';
  14. const message = i18n.indexingMessage || 'Oasis is trying to syncronize a huge network of inhabitants. Just wait!';
  15. const refreshNote = i18n.indexingRefreshNote || 'This page refreshes every 10 seconds.';
  16. const editProfileLabel = i18n.indexingEditProfileLink || 'Set up my profile';
  17. const welcomeLabel = i18n.indexingWelcomeLink || 'Tour of Oasis';
  18. return template(
  19. headingText,
  20. section(
  21. div({ class: 'tags-header' },
  22. h2(`❤ ${headingText}`),
  23. p(message)
  24. ),
  25. div({ class: 'indexing-progress-block' },
  26. progress({ value: String(pct), max: '100', class: 'indexing-progress' }),
  27. p({ class: 'indexing-percent' }, strong(`${pct.toFixed(1)} %`)),
  28. p({ class: 'indexing-note' }, refreshNote)
  29. ),
  30. div({ class: 'indexing-actions' },
  31. a({ href: '/profile/edit', class: 'filter-btn welcome-action-primary' }, editProfileLabel),
  32. a({ href: '/welcome', class: 'filter-btn' }, welcomeLabel),
  33. a({ href: '/modules', class: 'filter-btn' }, i18n.modulesTitle || 'Modules')
  34. )
  35. )
  36. ).replace('</head>', '<meta http-equiv="refresh" content="10"></head>');
  37. };