fix: video player was still using hard-coded paths.

This commit is contained in:
David Ball 2024-06-15 19:32:17 -04:00
parent a86fe7f198
commit 07ec0a1c3e
3 changed files with 14 additions and 14 deletions

View File

@ -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';

View File

@ -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('/')) {

View File

@ -17,10 +17,11 @@
<% if (h.shouldShowDirectorySeparator({index})) { %>
<span class="separator">&rsaquo; </span>
<% } %>
<% if (h.shouldShowWelcomeBanner({paths})) { %>
Welcome to <%= h.getDirectoryTitle({directory}) %>
<% if (h.shouldShowSiteWelcomeMessage({paths})) { %>
<i>&nbsp;</i>
<%= h.getSiteWelcomeMessage() %>
<% } else if (h.shouldOmitLinkOnLastBreadcrumb({paths, index})) { %>
<%= h.trimSlashes({path: value.name}) %>
<%= h.trimSlashes(value.name) %>
<% } else if (index == 0) { %>
<a href="/"><%= h.getSiteName() %></a>
<% } else { %>