Minor changes, {Keywords} use the old method for performance.
This commit is contained in:
parent
9ea5be1777
commit
0372cdcf6f
4 changed files with 39 additions and 46 deletions
|
@ -67,6 +67,7 @@
|
||||||
"Fedi": "rgb(175, 125, 200)",
|
"Fedi": "rgb(175, 125, 200)",
|
||||||
"Matrix": "limegreen",
|
"Matrix": "limegreen",
|
||||||
"Element": "rgb(100, 255, 200)",
|
"Element": "rgb(100, 255, 200)",
|
||||||
|
"Code": "rgb(150, 175, 255)",
|
||||||
"Codeberg": "rgb(0, 255, 255)",
|
"Codeberg": "rgb(0, 255, 255)",
|
||||||
"Docker": "blue",
|
"Docker": "blue",
|
||||||
"Github": "gray",
|
"Github": "gray",
|
||||||
|
@ -83,7 +84,6 @@
|
||||||
"CSS": "rgb(50, 200, 255)",
|
"CSS": "rgb(50, 200, 255)",
|
||||||
"Thumbor": "rgb(225, 225, 255)",
|
"Thumbor": "rgb(225, 225, 255)",
|
||||||
"Spotify": "limegreen",
|
"Spotify": "limegreen",
|
||||||
"Ultrakill": "red",
|
"Ultrakill": "red"
|
||||||
"Code": "rgb(150, 175, 255)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,7 +21,6 @@ var commitCount = "500+"
|
||||||
var lanyardData = undefined
|
var lanyardData = undefined
|
||||||
|
|
||||||
var uptime = Date.now()
|
var uptime = Date.now()
|
||||||
var reloads = 0
|
|
||||||
|
|
||||||
function firstToUpper(str) {
|
function firstToUpper(str) {
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1)
|
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||||
|
@ -100,7 +99,6 @@ function converter(html) {
|
||||||
},
|
},
|
||||||
"SPINCOUNT": globalSpins,
|
"SPINCOUNT": globalSpins,
|
||||||
"UPTIME": timeFormatter((Date.now() - uptime) / 1000),
|
"UPTIME": timeFormatter((Date.now() - uptime) / 1000),
|
||||||
"RELOAD_COUNT": reloads,
|
|
||||||
"WEATHER_MODIFIER": randomThemer.returnTheme(),
|
"WEATHER_MODIFIER": randomThemer.returnTheme(),
|
||||||
"WEATHER_TEXT": "",
|
"WEATHER_TEXT": "",
|
||||||
"ANNOUNCEMENT": fs.readFileSync(path.join(__dirname, "config/announcement.html")),
|
"ANNOUNCEMENT": fs.readFileSync(path.join(__dirname, "config/announcement.html")),
|
||||||
|
@ -110,6 +108,25 @@ function converter(html) {
|
||||||
|
|
||||||
replacers.ALL_KEYWORDS = "{" + Object.keys(replacers).join("}{") + "} "
|
replacers.ALL_KEYWORDS = "{" + Object.keys(replacers).join("}{") + "} "
|
||||||
|
|
||||||
|
while (html.includes("{PATH_")) {
|
||||||
|
var pagePath = html.substring(html.indexOf("{PATH_"))
|
||||||
|
pagePath = pagePath.substring(6, pagePath.indexOf('}'))
|
||||||
|
|
||||||
|
var stringIndex = `{PATH_${pagePath}}`
|
||||||
|
pagePath = pagePath.toLowerCase()
|
||||||
|
|
||||||
|
var pageHTML = fs.readFileSync(path.join(__dirname, 'static', pagePath, 'index.html')).toString()
|
||||||
|
pageHTML = pageHTML.substring(pageHTML.indexOf('<main>') + 6, pageHTML.indexOf('</main>'))
|
||||||
|
html = html.replaceAll(stringIndex, pageHTML)
|
||||||
|
}
|
||||||
|
|
||||||
|
var rpTable = Object.keys(replacers)
|
||||||
|
|
||||||
|
for (let index = 0; index < rpTable.length; index++) {
|
||||||
|
const text = rpTable[index];
|
||||||
|
html = html.replaceAll(`{${text}}`, replacers[text])
|
||||||
|
}
|
||||||
|
|
||||||
if (html.includes("<body>")) {
|
if (html.includes("<body>")) {
|
||||||
var bodyHTML = htmlMinifier.minify(html.substring(html.indexOf("<body>") + 6, html.lastIndexOf("</body>")))
|
var bodyHTML = htmlMinifier.minify(html.substring(html.indexOf("<body>") + 6, html.lastIndexOf("</body>")))
|
||||||
var parsedHTML = himalaya.parse(bodyHTML)
|
var parsedHTML = himalaya.parse(bodyHTML)
|
||||||
|
@ -117,42 +134,24 @@ function converter(html) {
|
||||||
var parsedHTML = himalaya.parse(html)
|
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_")) {
|
// function scanParsedHTML(json) {
|
||||||
var pagePath = element.content.substring(element.content.indexOf("{PATH_"))
|
// for (var i = 0; i < json.length; i++) {
|
||||||
pagePath = pagePath.substring(6, pagePath.indexOf('}'))
|
// var element = json[i]
|
||||||
|
// if (element.type == "element") {
|
||||||
|
// if (element.children.length > 0) {
|
||||||
|
// element.children = scanParsedHTML(element.children)
|
||||||
|
// }
|
||||||
|
// } else if (element.type == "text") {
|
||||||
|
|
||||||
var stringIndex = `{PATH_${pagePath}}`
|
|
||||||
pagePath = pagePath.toLowerCase()
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
var rpTable = Object.keys(replacers)
|
// json[i] = element
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
for (let index = 0; index < rpTable.length; index++) {
|
// return json
|
||||||
const text = rpTable[index];
|
// }
|
||||||
element.content = element.content.replaceAll(`{${text}}`, replacers[text])
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log(element.content, himalaya.parse(element.content))
|
|
||||||
|
|
||||||
json[i] = element
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return json
|
|
||||||
}
|
|
||||||
|
|
||||||
// var highTable = Object.keys(highlightedWords)
|
// var highTable = Object.keys(highlightedWords)
|
||||||
|
|
||||||
|
@ -166,9 +165,9 @@ function converter(html) {
|
||||||
// element.content = element.content.replaceAll("TEMPORARY_REPLACE", `${term}`)
|
// 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) {
|
function highlighter(json) {
|
||||||
for (var i = 0; i < json.length; i++) {
|
for (var i = 0; i < json.length; i++) {
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
<div>
|
<div>
|
||||||
<h3>Coding</h3>
|
<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://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://hub.docker.com/u/bingusviolet">Docker: bingusviolet</a>
|
||||||
<a class="chip" href="https://github.com/violets-puragtory">Github: violets-puragtory</a>
|
<a class="chip" href="https://github.com/violets-puragtory">Github: violets-puragtory</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -37,13 +37,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li>Page generation time: {LOAD_TIME}</li>
|
<li>Page generation time: {LOAD_TIME}</li>
|
||||||
<li>Uptime: {UPTIME}</li>
|
<li>Uptime: {UPTIME}</li>
|
||||||
<li>Total reloads: {RELOAD_COUNT} <sup>*1</sup></li>
|
<li>Cached Images: {CACHED_IMAGES}</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>
|
|
||||||
</ul>
|
</ul>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue