« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/content/dependencies/generatePageLayout.js3
-rw-r--r--src/content/dependencies/linkExternal.js25
-rw-r--r--src/repl.js4
-rwxr-xr-xsrc/upd8.js2
4 files changed, 28 insertions, 6 deletions
diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js
index cd831ba7..72dfbae5 100644
--- a/src/content/dependencies/generatePageLayout.js
+++ b/src/content/dependencies/generatePageLayout.js
@@ -449,7 +449,8 @@ export default {
             {[html.onlyIfContent]: true, class: 'skipper-list'},
             processSkippers([
               {id: 'tracks', string: 'tracks'},
-              {id: 'art', string: 'flashes'},
+              {id: 'art', string: 'artworks'},
+              {id: 'flashes', string: 'flashes'},
               {id: 'contributors', string: 'contributors'},
               {id: 'references', string: 'references'},
               {id: 'referenced-by', string: 'referencedBy'},
diff --git a/src/content/dependencies/linkExternal.js b/src/content/dependencies/linkExternal.js
index 73c656e3..5de612e2 100644
--- a/src/content/dependencies/linkExternal.js
+++ b/src/content/dependencies/linkExternal.js
@@ -3,10 +3,20 @@ const BANDCAMP_DOMAINS = ['bc.s3m.us', 'music.solatrux.com'];
 const MASTODON_DOMAINS = ['types.pl'];
 
 export default {
-  extraDependencies: ['html', 'language'],
+  extraDependencies: ['html', 'language', 'wikiData'],
 
-  data(url) {
-    return {url};
+  sprawl: ({wikiInfo}) => ({wikiInfo}),
+
+  data(sprawl, url) {
+    const data = {url};
+
+    const {canonicalBase} = sprawl.wikiInfo;
+    if (canonicalBase) {
+      const {hostname: canonicalDomain} = new URL(canonicalBase);
+      Object.assign(data, {canonicalDomain});
+    }
+
+    return data;
   },
 
   slots: {
@@ -20,6 +30,7 @@ export default {
     let isLocal;
     let domain;
     let pathname;
+
     try {
       const url = new URL(data.url);
       domain = url.hostname;
@@ -28,6 +39,14 @@ export default {
       // No support for relative local URLs yet, sorry! (I.e, local URLs must
       // be absolute relative to the domain name in order to work.)
       isLocal = true;
+      domain = null;
+      pathname = null;
+    }
+
+    // isLocal also applies for URLs which match the 'Canonical Base' under
+    // wiki-info.yaml, if present.
+    if (data.canonicalDomain && domain === data.canonicalDomain) {
+      isLocal = true;
     }
 
     const link = html.tag('a',
diff --git a/src/repl.js b/src/repl.js
index ead01567..7a6f5c45 100644
--- a/src/repl.js
+++ b/src/repl.js
@@ -16,6 +16,8 @@ import * as serialize from '#serialize';
 import * as sugar from '#sugar';
 import * as wikiDataUtils from '#wiki-data';
 
+import {DEFAULT_STRINGS_FILE} from './upd8.js';
+
 const __dirname = path.dirname(fileURLToPath(import.meta.url));
 
 export async function getContextAssignments({
@@ -46,7 +48,7 @@ export async function getContextAssignments({
     language = await processLanguageFile(
       path.join(
         path.dirname(fileURLToPath(import.meta.url)),
-        'strings-default.json'));
+        DEFAULT_STRINGS_FILE));
   } catch (error) {
     console.error(error);
     logWarn`Failed to create Language object`;
diff --git a/src/upd8.js b/src/upd8.js
index 868bfee4..24d0b92b 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -93,7 +93,7 @@ try {
 
 const BUILD_TIME = new Date();
 
-const DEFAULT_STRINGS_FILE = 'strings-default.yaml';
+export const DEFAULT_STRINGS_FILE = 'strings-default.yaml';
 
 const STATUS_NOT_STARTED       = `not started`;
 const STATUS_NOT_APPLICABLE    = `not applicable`;