(() => {
const encodeSVG /**/ = svg => "data:image/svg+xml;base64," + btoa(svg)
const formatDate /**/ = str => new Date(str).toDateString().slice(4).toUpperCase()
const icons = {
// NOTE: External Images should have the version parameter appended to them.
// e.g. /public/.../image.png?v=${dataVersion}
diamond_fill: /**/ encodeSVG(``),
diamond_empty: /**/ encodeSVG(``),
icon_cross: /**/ encodeSVG(``),
icon_rss: /**/ encodeSVG(``),
icon_top: /**/ encodeSVG(``),
tags_development: /**/ encodeSVG(``),
tags_personal: /**/ encodeSVG(``),
author_bakonpancakz: /**/ `data:image/gif;base64,R0lGODlhRABOAPAAAAAAAMDAwCH5BAUKAAAALAAAAABEAE4AAAL/hI+pF+0P45p0uQqi3hD79CjcSF6fZzLlyp1iCrKy5KphPOe3SyP6D0N1fMBioGYxKpFE5ZKZcTqR0urxZM0Ks9Utd1r5WimksFgzKWNy5FHavZ61W0m6eeXt4TYfVp9fBxhX8of2AjeoVrjTZHenmNcQKPiIGHm1RzkHmRhkQHhp2Mlo47hpeUr66TeJV6kadaaZCSurdSjVmIsLtjrG++TbBQzUamT887arWxQqR1s8qkOcLM0GXR0rWRqNbZvN/N3NLd7sXf4cjn59vg7a7o4qHJ+uTs85f+8Krz/E3+9JG0B8AgeaymdQlL2EnhgSdCivIMSAE2dJrIgMI7mKPow4OvJICaRCkXpI+rvokdpEZezSTYvyj5SMjWq20ZS3D6Ggjjkz2sy05RwVPTxgQTk6NCDSpYt+Mn2aB0EBADs=`,
}
// Parse Data from Webpage //
const dataVersion /**/ = document.querySelector("data[key='version']").value
const dataManifest /**/ = JSON.parse(document.querySelector("data[key='manifest']").value)
{
// Additional Validation //
if (!dataManifest.articles) /**/ throw "Missing Key: .articles" // Type: Metadata
if (!dataManifest.authors) /**/ throw "Missing Key: .authors" // Type: Filter
if (!dataManifest.links) /**/ throw "Missing Key: .links" // Type: Metadata
if (!dataManifest.tags) /**/ throw "Missing Key: .tags" // Type: Filter
const lookupAuthor /**/ = new Set(dataManifest.authors.map(t => t.id))
const lookupTags /**/ = new Set(dataManifest.tags.map(t => t.id))
console.info("Authors IDs:", [...lookupAuthor].join(", "))
console.info("Tags IDs: ", [...lookupTags].join(", "))
dataManifest.articles = dataManifest.articles.filter((a, i) => {
if (!a.date) {
console.warn(`Article '${a.id}' has no date and will be hidden.`)
return false
}
for (const t of a.tags) {
if (!lookupTags.has(t)) {
console.warn(`Article '${a.id}' has an unknown tag id (${t})`)
return false
}
}
if (!lookupAuthor.has(a.author)) {
console.warn(`Article '${a.id}' has an unknown author id (${a.author})`)
return false
}
console.info(`Article OK: ${a.id}`)
return true
})
}
// Render Functions //
let articleHeader /**/ = document.querySelector("div.article-header")
let articleContent /**/ = document.querySelector("div.article-content")
let navigation /**/ = document.querySelector("nav.section-navigation")
let listArticles /**/ = document.querySelector("div.article-list")
let listChapters /**/ = null
function updateNavigation() {
function templateLink(link, name, description, icon) {
const image = icon.startsWith("script:")
? icons[icon.slice(7)]
: icon // use uri
const html = `
${name} ${description}
Fetch Error, please see console for more information.
` }) // Render Article Header (Metadata) // const author /**/ = dataManifest.authors.find(a => a.id === article.author) const tags /**/ = article.tags.map(id => dataManifest.tags.find(t => t.id === id)) listChapters.innerHTML += ` ` articleHeader.innerHTML += `${results.length} RESULT${results.length === 1 ? "" : "s"} ${new Array(...filterTags.values()).map(s => `<TAG:${s.toUpperCase()}>`).join(" ")} ${new Array(...filterAuthor.values()).map(s => `<AUTHOR:${s.toUpperCase()}>`).join(" ")} _