diff --git a/.gitignore b/.gitignore index 256fe834..82e358a8 100644 --- a/.gitignore +++ b/.gitignore @@ -132,7 +132,7 @@ dist .yarn/install-state.gz .pnp.* -# iisnode +# iisnode logs iisnode/ # transpiler artifacts diff --git a/app/server.js b/app/server.js index 9c5eadb6..898ec8e2 100644 --- a/app/server.js +++ b/app/server.js @@ -109,6 +109,28 @@ glob.globSync('pages/**/*.md', { // }); // }); +console.log("Scanning for web archive HTML documents to create routes"); +glob.globSync('Web_Site_Archives/**/*{.htm,.html}', { + cwd: path.join(__dirname, '..', 'public'), + matchBase: true, + follow: true, +}).forEach((filePath) => { + const expressRoutePathFromFilePath = (filePath) => { + return '/' + filePath.replaceAll(path.sep, path.posix.sep); + }; + const route = expressRoutePathFromFilePath(filePath); + const fullFilePath = path.join(__dirname, '..', 'public', filePath); + let paths = route.split(path.posix.sep); + paths[0] = 'public'; + console.log(`Setting route for ${route}`); + app.get(route, async (req, res) => { + const html = fs.readFileSync(fullFilePath).toString(); + const renderData = { route, filePath, fullFilePath, req, paths, html }; + res.render("archive", { h: helpers, ...renderData }); + }); +}); + + // Endpoints for all the site's YouTube videos. 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'], { @@ -220,7 +242,7 @@ app.get('*', async (req, res) => { source: "/OCR-Encoded-PDFs/Russell-County-Web-Site_2024-02-13_19_50_Modified-With-OCR-Encoding/:u(.*)", destination: "/Web_Site_Archives/Russell_County_Web_Site-2024-02-13_19_50_Modified_With_OCR_Encoding:u" }, - { source: '/YouTube Channel', destination: '/Russell_County/Board_of_Supervisors/YouTube_Channel' }, + { source: '/YouTube Channel', destination: '/Russell_County/Board_of_Supervisors/YouTube_Archive/@russellcountyvirginia8228' }, // { source: '/YouTube Channel.zip', destination: '/Russell_County_BOS/YouTube_Channel.zip' }, // { source: '/YouTube Channel/:u?', destination: '/Russell_County_BOS/YouTube_Channel/:u' }, { source: '/Project Reclaim [WI19KR9Ogwg].mkv', destination: '/YouTube_Archives/@VADMME/Project Reclaim [WI19KR9Ogwg].mkv' }, diff --git a/static/css/nm3clol.css b/static/css/nm3clol.css index 40a4e92b..99c77c95 100644 --- a/static/css/nm3clol.css +++ b/static/css/nm3clol.css @@ -173,6 +173,14 @@ ul#files a.file.svg::before { background-color: #f44336; color: #fff; } +.bg-primary ::selection { + background-color: #fff; + color: #f44336; +} +.bg-primary ::-moz-selection { + background-color: #fff; + color: #f44336; +} header h1 { font-size: 2em; } diff --git a/views/archive.ejs b/views/archive.ejs new file mode 100644 index 00000000..e343eab6 --- /dev/null +++ b/views/archive.ejs @@ -0,0 +1 @@ +<%-h.renderArchive(html)%> \ No newline at end of file diff --git a/views/helpers/functions.js b/views/helpers/functions.js index 89b5da4f..989dcf9f 100644 --- a/views/helpers/functions.js +++ b/views/helpers/functions.js @@ -32,8 +32,13 @@ const getDirectoryName = ({directory}) => { }; const getDirectoryTitle = ({directory}) => { directory = trimSlashes({path: directory}); - let title = trimSlashes({path: directory.replace("public", "")}).replaceAll(path.sep, path.posix.sep); - return (directory=="public") ? getSiteName() : `${title} Listing - ${getSiteName()}`; + let title = trimSlashes({path: directory.replace("public", "")}) + .replaceAll(path.sep, path.posix.sep) + .replaceAll('_', ' ') + .split('/') + .reverse() + .join(' - '); + return (directory=="public") ? getSiteName() : `${title} - ${getSiteName()}`; }; const getWelcomeBanner = ({directory}) => { //return trimSlashes({path: directory.replace("public", `Welcome to ${getSiteName()}`)}); @@ -80,6 +85,81 @@ const stripWebVTT = (webvttText) => { } return webvttText; }; +const renderArchive = (html, paths) => { + // Header and Footer content + const headHeaderContent = ``; + const headFooterContent = ` + + + + + + + + + + +`; + const bodyHeaderContent = ` + +
+

No Moss 3 Carbo Landfill Online Library

+

Archived Web Site

+

+ This is an archived version of the original website. Online features will not be functional. Do not submit any personal information to this archive. +

+

+ Current Directory Listing | Back to Library Home +

+
+ +`; + const bodyFooterContent = ` + +
+

+ This is an archived version of the original website. Online features will not be functional. Do not submit any personal information to this archive. +

+

+ Current Directory Listing | Back to Library Home +

+
+ +`; + + // Add archive branding + html = html.substring(0, html.indexOf('>', html.indexOf(''.length) + headHeaderContent + html.substring(html.indexOf('>', html.indexOf(''.length); + html = html.substring(0, html.indexOf('') + ''.length) + headFooterContent + html.substring(html.indexOf('') + ''.length); + html = html.substring(0, html.indexOf('>', html.indexOf(''.length) + bodyHeaderContent + html.substring(html.indexOf('>', html.indexOf(''.length); + html = html.substring(0, html.indexOf('') + ''.length) + bodyFooterContent + html.substring(html.indexOf('') + ''.length); + + // Output the modified HTML content + return html; +} module.exports = { trimSlashes, @@ -93,6 +173,7 @@ module.exports = { directoryContainsReadme, printReadme, stripWebVTT, + renderArchive, md, moment, }; \ No newline at end of file diff --git a/web.config b/web.config index 73bdd53c..d02dbde9 100644 --- a/web.config +++ b/web.config @@ -1,8 +1,8 @@ - - + + @@ -31,5 +31,6 @@ + \ No newline at end of file