2024-11-15 18:24:21 +01:00
|
|
|
const fs = require("fs");
|
|
|
|
const serverPath = require("./serverPath.js")
|
2024-12-17 19:11:08 +01:00
|
|
|
//const pages = ["/index.html", "/blogs/index.html", "/blogs/reviews/index.html", "/board/index.html", "/board/tech/index.html", "/board/gen/index.html", "/board/films/index.html", "/board/maths/index.html","/maths/index.html"];
|
2024-12-27 03:17:48 +01:00
|
|
|
const pages = ["/index.html", "/blogs/index.html", "/board/index.html", "/board/test/index.html", "/board/tech/index.html", "/board/gen/index.html", "/board/films/index.html", "/board/maths/index.html"]
|
2024-12-17 19:11:08 +01:00
|
|
|
let { pageTop, pageBottom } = require(serverPath+"/html.js")
|
2024-11-15 18:24:21 +01:00
|
|
|
const { exec } = require('child_process');
|
|
|
|
|
|
|
|
for (let x = 0; x < pages.length; x++) {
|
|
|
|
console.log(x)
|
|
|
|
page = serverPath + pages[x]
|
|
|
|
console.log("editing", page)
|
2024-12-17 19:11:08 +01:00
|
|
|
pageTop = pageTop.replace(/\n/g, '');
|
|
|
|
pageTop = pageTop.replace(/\\/g, '\\');
|
|
|
|
pageTop = pageTop.replace(/\|/g, "\\|");
|
|
|
|
pageTop = pageTop.replace(/'/g, "\\&\\#39;");
|
2024-11-15 18:24:21 +01:00
|
|
|
// Header
|
2024-12-27 03:17:48 +01:00
|
|
|
let command = `sed -i 's#.*<body>#${pageTop}#' ${page}`;
|
2024-11-15 18:24:21 +01:00
|
|
|
|
|
|
|
exec(command, (error, stdout, stderr) => {
|
|
|
|
if (error) {
|
|
|
|
console.error(`Error: ${error.message}`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.log(`Successfully added header to page`)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Footer
|
2024-12-17 19:11:08 +01:00
|
|
|
pageBottom = pageBottom.replace(/\n/g, '');
|
|
|
|
pageBottom = pageBottom.replace(/\\/g, '\\');
|
|
|
|
pageBottom = pageBottom.replace(/\|/g, "\\|");
|
|
|
|
pageBottom = pageBottom.replace(/'/g, "\\&\\#39;");
|
|
|
|
command = `sed -i 's#</body>.*#</body>${pageBottom}#' ${page}`;
|
2024-11-15 18:24:21 +01:00
|
|
|
|
|
|
|
exec(command, (error, stdout, stderr) => {
|
|
|
|
if (error) {
|
|
|
|
console.error(`Error: ${error.message}`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.log(`Successfully added footer to page`)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|