« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/write/build-modes
diff options
context:
space:
mode:
Diffstat (limited to 'src/write/build-modes')
-rw-r--r--src/write/build-modes/live-dev-server.js41
-rw-r--r--src/write/build-modes/static-build.js78
2 files changed, 36 insertions, 83 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index edee3267..2767a02f 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -1,35 +1,26 @@
-import * as http from 'http';
-import {createReadStream} from 'fs';
-import {stat} from 'fs/promises';
-import * as path from 'path';
-import {pipeline} from 'stream/promises'
+import * as http from 'node:http';
+import {createReadStream} from 'node:fs';
+import {stat} from 'node:fs/promises';
+import * as path from 'node:path';
+import {pipeline} from 'node:stream/promises'
+
+import {logInfo, logWarn, progressCallAll} from '#cli';
+import {watchContentDependencies} from '#content-dependencies';
+import {quickEvaluate} from '#content-function';
+import * as html from '#html';
+import * as pageSpecs from '#page-specs';
+import {serializeThings} from '#serialize';
+import {empty} from '#sugar';
 
-import {bindUtilities} from '../bind-utilities.js';
-
-import {serializeThings} from '../../data/serialize.js';
-
-import * as pageSpecs from '../../page/index.js';
-
-import {logInfo, logWarn, progressCallAll} from '../../util/cli.js';
-import * as html from '../../util/html.js';
-import {empty} from '../../util/sugar.js';
 import {
   getPagePathname,
   getPagePathnameAcrossLanguages,
   getURLsFrom,
   getURLsFromRoot,
-} from '../../util/urls.js';
+} from '#urls';
 
-import {
-  generateGlobalWikiDataJSON,
-  generateRedirectHTML,
-} from '../page-template.js';
-
-import {
-  watchContentDependencies,
-} from '../../content/dependencies/index.js';
-
-import {quickEvaluate} from '../../content-function.js';
+import {bindUtilities} from '../bind-utilities.js';
+import {generateGlobalWikiDataJSON, generateRedirectHTML} from '../common-templates.js';
 
 const defaultHost = '0.0.0.0';
 const defaultPort = 8002;
diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js
index 4f074058..2210dfe7 100644
--- a/src/write/build-modes/static-build.js
+++ b/src/write/build-modes/static-build.js
@@ -1,20 +1,20 @@
-import * as path from 'path';
-
-import {bindUtilities} from '../bind-utilities.js';
-// import {validateWrites} from '../validate-writes.js';
+import * as path from 'node:path';
 
 import {
-  quickLoadContentDependencies,
-} from '../../content/dependencies/index.js';
-
-import {quickEvaluate} from '../../content-function.js';
-
-import {serializeThings} from '../../data/serialize.js';
-
-import * as pageSpecs from '../../page/index.js';
+  copyFile,
+  mkdir,
+  stat,
+  symlink,
+  writeFile,
+  unlink,
+} from 'node:fs/promises';
 
-import * as html from '../../util/html.js';
-import {empty, queue, withEntries} from '../../util/sugar.js';
+import {quickLoadContentDependencies} from '#content-dependencies';
+import {quickEvaluate} from '#content-function';
+import * as html from '#html';
+import * as pageSpecs from '#page-specs';
+import {serializeThings} from '#serialize';
+import {empty, queue, withEntries} from '#sugar';
 
 import {
   logError,
@@ -22,14 +22,17 @@ import {
   logWarn,
   progressCallAll,
   progressPromiseAll,
-} from '../../util/cli.js';
+} from '#cli';
 
 import {
   getPagePathname,
   getPagePathnameAcrossLanguages,
   getURLsFrom,
   getURLsFromRoot,
-} from '../../util/urls.js';
+} from '#urls';
+
+import {bindUtilities} from '../bind-utilities.js';
+import {generateRedirectHTML, generateGlobalWikiDataJSON} from '../common-templates.js';
 
 const pageFlags = Object.keys(pageSpecs);
 
@@ -78,36 +81,6 @@ export function getCLIOptions() {
   };
 }
 
-function generateRedirectHTML(title, target, {language}) {
-  return `<!DOCTYPE html>\n` + html.tag('html', [
-    html.tag('head', [
-      html.tag('title', language.$('redirectPage.title', {title})),
-      html.tag('meta', {charset: 'utf-8'}),
-
-      html.tag('meta', {
-        'http-equiv': 'refresh',
-        content: `0;url=${target}`,
-      }),
-
-      // TODO: Is this OK for localized pages?
-      html.tag('link', {
-        rel: 'canonical',
-        href: target,
-      }),
-    ]),
-
-    html.tag('body',
-      html.tag('main', [
-        html.tag('h1',
-          language.$('redirectPage.title', {title})),
-        html.tag('p',
-          language.$('redirectPage.infoLine', {
-            target: html.tag('a', {href: target}, target),
-          })),
-      ])),
-  ]);
-}
-
 export async function go({
   cliOptions,
   _dataPath,
@@ -173,12 +146,10 @@ export async function go({
     outputPath,
     urls,
     wikiData,
-    /*
     wikiDataJSON: generateGlobalWikiDataJSON({
       serializeThings,
       wikiData,
-    })
-    */
+    }),
   });
 
   const buildSteps = writeAll
@@ -409,15 +380,6 @@ async function wrapLanguages(fn, {
   }
 }
 
-import {
-  copyFile,
-  mkdir,
-  stat,
-  symlink,
-  writeFile,
-  unlink,
-} from 'fs/promises';
-
 async function writePage({
   pageHTML,
   oEmbedJSON = '',