From 07ec0a1c3ee830a6d6be1742f6182f0e6103f70f Mon Sep 17 00:00:00 2001 From: David Ball Date: Sat, 15 Jun 2024 19:32:17 -0400 Subject: [PATCH] fix: video player was still using hard-coded paths. --- app/config.js | 2 +- app/server.js | 19 +++++++++---------- views/video-player.ejs | 7 ++++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/config.js b/app/config.js index 058a5064..a0e36e61 100644 --- a/app/config.js +++ b/app/config.js @@ -6,7 +6,7 @@ const dotenvExpand = require('dotenv-expand'); const process = require('process'); const env = {}; -let dotEnvConfig = dotenv.config({ path: path.join(__dirname, '..', '.env'), processEnv: env }); +let dotEnvConfig = dotenv.config({ path: path.join(__dirname, '.env'), process: dotenv.config({ path: path.join(__dirname, '..', '.env'), processEnv: env})}); dotEnvConfig = dotenvExpand.expand({ parsed: env, processEnv: env }); const getAppHttpHost = () => env.APP_HTTP_HOST||'nm3clol-express-app'; diff --git a/app/server.js b/app/server.js index 0ce91ea2..9df412a7 100644 --- a/app/server.js +++ b/app/server.js @@ -81,7 +81,6 @@ glob.globSync('**/*.md', { const route = expressRoutePathFromFilePath(filePath); const fullFilePath = path.join(config.pagesPath, filePath); let paths = route.split(path.posix.sep); - paths[0] = 'public'; console.log(`Serving ${route} route as a page at ${fullFilePath}.`); app.get(route, async (req, res) => { const fm = matter.read(fullFilePath); @@ -94,7 +93,7 @@ glob.globSync('**/*.md', { // console.log("Scanning for documents to create routes."); // glob.globSync('**/*{.pdf,.docx,.xlsx,.pptx,.doc,.xls,.ppt}', { -// cwd: path.join(__dirname, '..', 'public'), +// cwd: path.join(config.publicPath), // matchBase: true, // follow: true, // }).forEach((filePath) => { @@ -102,7 +101,7 @@ glob.globSync('**/*.md', { // return filePath.substring(0, filePath.length - path.extname(filePath).length).replaceAll(path.sep, path.posix.sep); // }; // const route = expressRoutePathFromFilePath(filePath); -// const fullFilePath = path.join(__dirname, '..', 'public', filePath); +// const fullFilePath = path.join(config.publicPath, filePath); // let paths = route.split(path.posix.sep); // paths[0] = 'public'; // console.log(`Setting route for ${route}`); @@ -118,7 +117,7 @@ glob.globSync('**/*.md', { //TODO: Rewrite this facility so that it utilizes Git index as a filesystem. console.log("Scanning for web archive HTML documents to create routes."); glob.globSync('Web_Site_Archives/**/*{.htm,.html}', { - cwd: path.join(__dirname, '..', 'public'), + cwd: config.publicPath, matchBase: true, follow: true, }).forEach((filePath) => { @@ -126,7 +125,7 @@ glob.globSync('Web_Site_Archives/**/*{.htm,.html}', { return '/' + filePath.replaceAll(path.sep, path.posix.sep); }; const route = expressRoutePathFromFilePath(filePath); - const fullFilePath = path.join(__dirname, '..', 'public', filePath); + const fullFilePath = path.join(config.publicPath, filePath); let paths = route.split(path.posix.sep); paths[0] = 'public'; console.log(`Setting route for ${route}`); @@ -141,7 +140,7 @@ glob.globSync('Web_Site_Archives/**/*{.htm,.html}', { //TODO: Rewrite this facility so that it utilizes Git index as a filesystem. console.log("Scanning for archived videos to create routes."); glob.globSync(['Russell_County/Board_of_Supervisors/YouTube_Archive/**/*.info.json', 'Virginia_Energy/YouTube_Archive/**/*.info.json', 'Virginia_Governor/**/*.info.json'], { - cwd: path.join(__dirname, '..', 'public'), + cwd: config.publicPath, matchBase: true, follow: true, }).forEach((filePath) => { @@ -153,16 +152,16 @@ glob.globSync(['Russell_County/Board_of_Supervisors/YouTube_Archive/**/*.info.js } const directory = dirFromFilePath(filePath); let videoURL = ""+glob.globSync("*.{mpg,mpeg,mp4,mkv,webm}", { - cwd: path.join(__dirname, '..', 'public', directory), + cwd: path.join(config.publicPath, directory), matchBase: true, follow: true, }).pop(); let subtitleURL = ""+glob.globSync("*.en.vtt", { - cwd: path.join(__dirname, '..', 'public', directory), + cwd: path.join(config.publicPath, directory), matchBase: true, follow: true, }).pop(); - let subtitleFile = path.join(__dirname, '..', 'public', directory, subtitleURL); + let subtitleFile = path.join(config.publicPath, directory, subtitleURL); const route = encodeURI(expressRoutePathFromFilePath(filePath)); let paths = filePath.substring(0, filePath.lastIndexOf(path.sep) > 0 ? filePath.lastIndexOf(path.sep) : filePath.length-1).split(path.sep); paths = paths.map((name, idx, aPaths) => { @@ -172,7 +171,7 @@ glob.globSync(['Russell_County/Board_of_Supervisors/YouTube_Archive/**/*.info.js url, }; }); - const fullFilePath = path.join(__dirname, '..', 'public', filePath); + const fullFilePath = path.join(config.publicPath, filePath); console.log(`Setting route for ${route}`); app.get(route, async (req, res) => { if (!req.path.endsWith('/')) { diff --git a/views/video-player.ejs b/views/video-player.ejs index 28dbaa31..9f79ef45 100644 --- a/views/video-player.ejs +++ b/views/video-player.ejs @@ -17,10 +17,11 @@ <% if (h.shouldShowDirectorySeparator({index})) { %> <% } %> - <% if (h.shouldShowWelcomeBanner({paths})) { %> - Welcome to <%= h.getDirectoryTitle({directory}) %> + <% if (h.shouldShowSiteWelcomeMessage({paths})) { %> +   + <%= h.getSiteWelcomeMessage() %> <% } else if (h.shouldOmitLinkOnLastBreadcrumb({paths, index})) { %> - <%= h.trimSlashes({path: value.name}) %> + <%= h.trimSlashes(value.name) %> <% } else if (index == 0) { %> <%= h.getSiteName() %> <% } else { %>