« get me outta code hell

content: generateFooterLocalizationLinks - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-04-08 18:18:13 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-04-08 18:26:12 -0300
commit76845689c624b603509abbe6f0a289362bb42a04 (patch)
tree04b59dce0d656aa02759fe638c609fc66f8781a5
parent392d6ec799c87ef536335211cb34b1b795147369 (diff)
content: generateFooterLocalizationLinks
-rw-r--r--src/content/dependencies/generateFooterLocalizationLinks.js56
-rw-r--r--src/misc-templates.js38
-rw-r--r--src/write/bind-utilities.js4
-rw-r--r--src/write/build-modes/live-dev-server.js2
-rw-r--r--src/write/page-template.js4
5 files changed, 60 insertions, 44 deletions
diff --git a/src/content/dependencies/generateFooterLocalizationLinks.js b/src/content/dependencies/generateFooterLocalizationLinks.js
new file mode 100644
index 0000000..01b5b20
--- /dev/null
+++ b/src/content/dependencies/generateFooterLocalizationLinks.js
@@ -0,0 +1,56 @@
+export default {
+  extraDependencies: [
+    'defaultLanguage',
+    'html',
+    'language',
+    'languages',
+    'pagePath',
+    'to',
+  ],
+
+  generate({
+    defaultLanguage,
+    html,
+    language,
+    languages,
+    pagePath,
+    to,
+  }) {
+    const links = Object.entries(languages)
+      .filter(([code, language]) => code !== 'default' && !language.hidden)
+      .map(([code, language]) => language)
+      .sort(({name: a}, {name: b}) => (a < b ? -1 : a > b ? 1 : 0))
+      .map((language) =>
+        html.tag('span',
+          html.tag('a',
+            {
+              href:
+                language === defaultLanguage
+                  ? to(
+                      'localizedDefaultLanguage.' + pagePath[0],
+                      ...pagePath.slice(1))
+                  : to(
+                      'localizedWithBaseDirectory.' + pagePath[0],
+                      language.code,
+                      ...pagePath.slice(1)),
+            },
+            language.name)));
+
+    return html.tag('div', {class: 'footer-localization-links'},
+      language.$('misc.uiLanguage', {
+        languages: links.join('\n'),
+      }));
+  },
+};
+
+/*
+function unbound_getFooterLocalizationLinks({
+  html,
+  defaultLanguage,
+  language,
+  languages,
+  pagePath,
+  to,
+}) {
+}
+*/
diff --git a/src/misc-templates.js b/src/misc-templates.js
index 1842970..a8a207a 100644
--- a/src/misc-templates.js
+++ b/src/misc-templates.js
@@ -463,42 +463,6 @@ function unbound_generateStickyHeadingContainer({
     ]);
 }
 
-// Footer stuff
-
-function unbound_getFooterLocalizationLinks({
-  html,
-  defaultLanguage,
-  language,
-  languages,
-  pagePath,
-  to,
-}) {
-  const links = Object.entries(languages)
-    .filter(([code, language]) => code !== 'default' && !language.hidden)
-    .map(([code, language]) => language)
-    .sort(({name: a}, {name: b}) => (a < b ? -1 : a > b ? 1 : 0))
-    .map((language) =>
-      html.tag('span',
-        html.tag('a',
-          {
-            href:
-              language === defaultLanguage
-                ? to(
-                    'localizedDefaultLanguage.' + pagePath[0],
-                    ...pagePath.slice(1))
-                : to(
-                    'localizedWithBaseDirectory.' + pagePath[0],
-                    language.code,
-                    ...pagePath.slice(1)),
-          },
-          language.name)));
-
-  return html.tag('div', {class: 'footer-localization-links'},
-    language.$('misc.uiLanguage', {
-      languages: links.join('\n'),
-    }));
-}
-
 // Exports
 
 export {
@@ -516,6 +480,4 @@ export {
   unbound_generateNavigationLinks as generateNavigationLinks,
 
   unbound_generateStickyHeadingContainer as generateStickyHeadingContainer,
-
-  unbound_getFooterLocalizationLinks as getFooterLocalizationLinks,
 }
diff --git a/src/write/bind-utilities.js b/src/write/bind-utilities.js
index 50596a3..be9ad66 100644
--- a/src/write/bind-utilities.js
+++ b/src/write/bind-utilities.js
@@ -26,6 +26,7 @@ export function bindUtilities({
   getSizeOfImageFile,
   language,
   languages,
+  pagePath,
   to,
   urls,
   wikiData,
@@ -44,10 +45,11 @@ export function bindUtilities({
     html,
     language,
     languages,
+    pagePath,
     thumb,
     to,
     urls,
-    wikiData,
+    wikiInfo: wikiData.wikiInfo,
   });
 
   bound.getColors = bindOpts(getColors, {chroma});
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index 129ac9a..6dbcf3e 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -20,7 +20,6 @@ import {
 } from '../../util/urls.js';
 
 import {
-  generateDocumentHTML,
   generateGlobalWikiDataJSON,
   generateRedirectHTML,
 } from '../page-template.js';
@@ -350,6 +349,7 @@ export async function go({
         getSizeOfImageFile,
         language,
         languages,
+        pagePath: servePath,
         to,
         urls,
         wikiData,
diff --git a/src/write/page-template.js b/src/write/page-template.js
index 1c448fc..d3d7b09 100644
--- a/src/write/page-template.js
+++ b/src/write/page-template.js
@@ -3,10 +3,6 @@ import chroma from 'chroma-js';
 import * as html from '../util/html.js';
 import {getColors} from '../util/colors.js';
 
-import {
-  getFooterLocalizationLinks,
-} from '../misc-templates.js';
-
 export function generateDevelopersCommentHTML({
   buildTime,
   commit,