Minor changes, {Keywords} use the old method for performance.

This commit is contained in:
bingus_violet 2024-05-31 15:24:40 -05:00
parent 9ea5be1777
commit 0372cdcf6f
4 changed files with 39 additions and 46 deletions

View file

@ -67,6 +67,7 @@
"Fedi": "rgb(175, 125, 200)",
"Matrix": "limegreen",
"Element": "rgb(100, 255, 200)",
"Code": "rgb(150, 175, 255)",
"Codeberg": "rgb(0, 255, 255)",
"Docker": "blue",
"Github": "gray",
@ -83,7 +84,6 @@
"CSS": "rgb(50, 200, 255)",
"Thumbor": "rgb(225, 225, 255)",
"Spotify": "limegreen",
"Ultrakill": "red",
"Code": "rgb(150, 175, 255)"
"Ultrakill": "red"
}
}

View file

@ -21,7 +21,6 @@ var commitCount = "500+"
var lanyardData = undefined
var uptime = Date.now()
var reloads = 0
function firstToUpper(str) {
return str.charAt(0).toUpperCase() + str.slice(1)
@ -100,7 +99,6 @@ function converter(html) {
},
"SPINCOUNT": globalSpins,
"UPTIME": timeFormatter((Date.now() - uptime) / 1000),
"RELOAD_COUNT": reloads,
"WEATHER_MODIFIER": randomThemer.returnTheme(),
"WEATHER_TEXT": "",
"ANNOUNCEMENT": fs.readFileSync(path.join(__dirname, "config/announcement.html")),
@ -110,24 +108,8 @@ function converter(html) {
replacers.ALL_KEYWORDS = "{" + Object.keys(replacers).join("}{") + "} "
if (html.includes("<body>")) {
var bodyHTML = htmlMinifier.minify(html.substring(html.indexOf("<body>") + 6, html.lastIndexOf("</body>")))
var parsedHTML = himalaya.parse(bodyHTML)
} else {
var parsedHTML = himalaya.parse(html)
}
function scanParsedHTML(json) {
for (var i = 0; i < json.length; i++) {
var element = json[i]
if (element.type == "element") {
if (element.children.length > 0) {
element.children = scanParsedHTML(element.children)
}
} else if (element.type == "text") {
while (element.content.includes("{PATH_")) {
var pagePath = element.content.substring(element.content.indexOf("{PATH_"))
while (html.includes("{PATH_")) {
var pagePath = html.substring(html.indexOf("{PATH_"))
pagePath = pagePath.substring(6, pagePath.indexOf('}'))
var stringIndex = `{PATH_${pagePath}}`
@ -135,24 +117,41 @@ function converter(html) {
var pageHTML = fs.readFileSync(path.join(__dirname, 'static', pagePath, 'index.html')).toString()
pageHTML = pageHTML.substring(pageHTML.indexOf('<main>') + 6, pageHTML.indexOf('</main>'))
element.content = element.content.replaceAll(stringIndex, pageHTML)
html = html.replaceAll(stringIndex, pageHTML)
}
var rpTable = Object.keys(replacers)
for (let index = 0; index < rpTable.length; index++) {
const text = rpTable[index];
element.content = element.content.replaceAll(`{${text}}`, replacers[text])
html = html.replaceAll(`{${text}}`, replacers[text])
}
// console.log(element.content, himalaya.parse(element.content))
json[i] = element
}
if (html.includes("<body>")) {
var bodyHTML = htmlMinifier.minify(html.substring(html.indexOf("<body>") + 6, html.lastIndexOf("</body>")))
var parsedHTML = himalaya.parse(bodyHTML)
} else {
var parsedHTML = himalaya.parse(html)
}
return json
}
// function scanParsedHTML(json) {
// for (var i = 0; i < json.length; i++) {
// var element = json[i]
// if (element.type == "element") {
// if (element.children.length > 0) {
// element.children = scanParsedHTML(element.children)
// }
// } else if (element.type == "text") {
// json[i] = element
// }
// }
// return json
// }
// var highTable = Object.keys(highlightedWords)
@ -166,9 +165,9 @@ function converter(html) {
// element.content = element.content.replaceAll("TEMPORARY_REPLACE", `${term}`)
// }
parsedHTML = scanParsedHTML(parsedHTML)
// parsedHTML = scanParsedHTML(parsedHTML)
parsedHTML = himalaya.parse(himalaya.stringify(parsedHTML))
// parsedHTML = himalaya.parse(himalaya.stringify(parsedHTML))
function highlighter(json) {
for (var i = 0; i < json.length; i++) {

View file

@ -51,7 +51,7 @@
<div>
<h3>Coding</h3>
<a class="chip" href="https://git.violets-purgatory.dev/bingus_violet/">Forgejo: bingus_violet (git.violets-purgatory.dev)</a>
<a class="chip" href="https://codeberg.org/Bingus_violet">Codeberg: bingus_violet</a>
<a class="chip" href="https://codeberg.org/Bingus_violet">{Code}berg: bingus_violet</a>
<a class="chip" href="https://hub.docker.com/u/bingusviolet">Docker: bingusviolet</a>
<a class="chip" href="https://github.com/violets-puragtory">Github: violets-puragtory</a>
</div>

View file

@ -37,13 +37,7 @@
<ul>
<li>Page generation time: {LOAD_TIME}</li>
<li>Uptime: {UPTIME}</li>
<li>Total reloads: {RELOAD_COUNT} <sup>*1</sup></li>
<li>Cached Images: {CACHED_IMAGES} <sup>*2</sup></li>
</ul>
<br><br><br>
<ol class="noteList">
<li>Increments by 1 <em>EVERY</em> time <em>ANY</em> page is loaded.</li>
<li>Cached Images are cleared on server restart.</li>
<li>Cached Images: {CACHED_IMAGES}</li>
</ul>
</main>
</div>