« get me outta code hell

urls, write: integrate separate media cache - 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-10-29 15:28:20 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-29 15:43:30 -0300
commit08da5be83b7fe7f67ce861fa311ce9b32bb22f55 (patch)
tree63c14a48c56909e1b34ed91ed4d6273799a958b8
parent1a92f5e8198e5d1a56d0d9f7272f731f4e98bfce (diff)
urls, write: integrate separate media cache
-rw-r--r--src/url-spec.js13
-rw-r--r--src/write/build-modes/live-dev-server.js5
-rw-r--r--src/write/build-modes/static-build.js4
3 files changed, 21 insertions, 1 deletions
diff --git a/src/url-spec.js b/src/url-spec.js
index 2ff0fa5b..699f2bef 100644
--- a/src/url-spec.js
+++ b/src/url-spec.js
@@ -79,12 +79,25 @@ const urlSpec = {
       albumCover: 'album-art/<>/cover.<>',
       albumWallpaper: 'album-art/<>/bg.<>',
       albumBanner: 'album-art/<>/banner.<>',
+
       trackCover: 'album-art/<>/<>.<>',
+
       artistAvatar: 'artist-avatar/<>.<>',
+
       flashArt: 'flash-art/<>.<>',
+
       albumAdditionalFile: 'album-additional/<>/<>',
     },
   },
+
+  thumb: {
+    prefix: 'thumb/',
+
+    paths: {
+      root: '',
+      path: '<>',
+    },
+  },
 };
 
 // This gets automatically switched in place when working from a baseDirectory,
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index 1339c322..47d59f95 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -51,6 +51,7 @@ export async function go({
   cliOptions,
   _dataPath,
   mediaPath,
+  mediaCachePath,
 
   defaultLanguage,
   languages,
@@ -171,7 +172,7 @@ export async function go({
     const {
       area: localFileArea,
       path: localFilePath
-    } = pathname.match(/^\/(?<area>static|util|media)\/(?<path>.*)/)?.groups ?? {};
+    } = pathname.match(/^\/(?<area>static|util|media|thumb)\/(?<path>.*)/)?.groups ?? {};
 
     if (localFileArea) {
       // Not security tested, man, this is a dev server!!
@@ -182,6 +183,8 @@ export async function go({
         localDirectory = path.join(srcRootPath, localFileArea);
       } else if (localFileArea === 'media') {
         localDirectory = mediaPath;
+      } else if (localFileArea === 'thumb') {
+        localDirectory = mediaCachePath;
       }
 
       let filePath;
diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js
index 09316999..96f2a0ed 100644
--- a/src/write/build-modes/static-build.js
+++ b/src/write/build-modes/static-build.js
@@ -84,6 +84,7 @@ export async function go({
   cliOptions,
   _dataPath,
   mediaPath,
+  mediaCachePath,
   queueSize,
 
   defaultLanguage,
@@ -133,6 +134,7 @@ export async function go({
   await writeSymlinks({
     srcRootPath,
     mediaPath,
+    mediaCachePath,
     outputPath,
     urls,
   });
@@ -414,6 +416,7 @@ async function writePage({
 function writeSymlinks({
   srcRootPath,
   mediaPath,
+  mediaCachePath,
   outputPath,
   urls,
 }) {
@@ -421,6 +424,7 @@ function writeSymlinks({
     link(path.join(srcRootPath, 'util'), 'shared.utilityRoot'),
     link(path.join(srcRootPath, 'static'), 'shared.staticRoot'),
     link(mediaPath, 'media.root'),
+    link(mediaCachePath, 'thumb.root'),
   ]);
 
   async function link(directory, urlKey) {