remove fastnav system

This commit is contained in:
hippoz 2022-08-27 15:49:19 +03:00
parent 797c47b4a0
commit 134e1a98c4
Signed by: hippoz
GPG key ID: 7C52899193467641
3 changed files with 7 additions and 84 deletions

View file

@ -1,26 +0,0 @@
const map = {"projects.html":"<div class=\"card inner-card\"><div><b>📘 waffle</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/waffle>view >></a></div><p class=\"grayed-out\">Mysterious! This project has no description.</p></div><div class=\"card inner-card\"><div><b>📘 brainlet-react</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/brainlet-react>view >></a></div><p>a react frontend for waffle (brainlet)</p></div><div class=\"card inner-card\"><div><b>📘 raven</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/raven>view >></a></div><p>Simple experimental low-level UI library written in C++.</p></div><div class=\"card inner-card\"><div><b>📘 bridgecord</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/bridgecord>view >></a></div><p>bridge bot api for discord servers</p></div><div class=\"card inner-card\"><div><b>📘 rice</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/rice>view >></a></div><p>my personal forks of various software and my dotfiles</p></div><div class=\"card inner-card\"><div><b>📘 hippOS</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/hippOS>view >></a></div><p>simple osdev testing</p></div><div class=\"card inner-card\"><div><b>📘 homepage</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/homepage>view >></a></div><p class=\"grayed-out\">Mysterious! This project has no description.</p></div><div class=\"card inner-card\"><div><b>📘 brainlet</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/brainlet>view >></a></div><p>🎤🐢 An open source, self-hosted alternative to Discord</p></div><div class=\"card inner-card\"><div><b>📘 portal</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/portal>view >></a></div><p>waffletv's interface app</p></div><div class=\"card inner-card\"><div><b>📘 capybara</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/capybara>view >></a></div><p>simple and fast remote touchpad</p></div><div class=\"card inner-card\"><div><b>📘 rotcpu</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/rotcpu>view >></a></div><p class=\"grayed-out\">Mysterious! This project has no description.</p></div><div class=\"card inner-card\"><div><b>📘 quad-j</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/quad-j>view >></a></div><p>a simple upload server</p></div><div class=\"card inner-card\"><div><b>📘 blocklists</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/blocklists>view >></a></div><p>Some pi-hole blocklists</p></div><div class=\"card inner-card\"><div><b>📘 wormhole</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/wormhole>view >></a></div><p>A simple websocket abstraction.</p></div><div class=\"card inner-card\"><div><b>📘 mcli</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/mcli>view >></a></div><p>a command-line minecraft launcher written in rust</p></div><div class=\"card inner-card\"><div><b>📘 must</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/must>view >></a></div><p>Helper program for deploying protocol associations needed for running Roblox on Linux</p></div><div class=\"card inner-card\"><div><b>🍴 brainlet-client</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/brainlet-client>view >></a></div><p class=\"grayed-out\">Mysterious! This project has no description.</p></div><div class=\"card inner-card\"><div><b>📘 luapage</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/luapage>view >></a></div><p class=\"grayed-out\">Mysterious! This project has no description.</p></div><div class=\"card inner-card\"><div><b>📘 page-simplify</b><a class=\"button-default float-right\" href=https://git.hippoz.xyz/hippoz/page-simplify>view >></a></div><p>turn pages into pure html</p></div>","index.html":"<h2>hippoz's website</h2><p>i think</p>"};
const content = document.getElementById("content");
const load = (page) => content.innerHTML = map[page.substring(1, page.length) || "_notfound"];
const navigate = (page) => {
history.pushState(null, "", page);
load(page);
};
const populate = () => {
const elements = document.querySelectorAll("[href]");
elements.forEach(element => {
const existingLink = element.getAttribute("href");
if (map[existingLink]) {
element.setAttribute("href", "#");
element.onclick = () => navigate(existingLink);
}
});
};
const main = () => {
populate();
window.onpopstate = () => {load(location.pathname); console.log("a");};
};
main();

View file

@ -1,29 +0,0 @@
const map = "{{NAV_DATA}}";
const content = document.getElementById("content");
const load = (page) => {
content.innerHTML = map[page.substring(1, page.length) || "_notfound"];
console.log("a");
};
const navigate = (page) => {
history.pushState(null, "", page);
load(page);
};
const populate = () => {
const elements = document.querySelectorAll("[href]");
elements.forEach(element => {
const existingLink = element.getAttribute("href");
if (map[existingLink]) {
element.setAttribute("href", "");
element.onclick = () => navigate(existingLink);
}
});
};
const main = () => {
populate();
window.onpopstate = () => load(location.pathname);
};
main();

View file

@ -6,7 +6,7 @@ const { html: beautifyHtml } = require('js-beautify');
const data = { const data = {
outputDirectory: "./out", outputDirectory: "./out",
navigationLinks: [ navigationLinks: [
{link: "index.html", text: "home", name: "home"}, {link: "index.html", text: "home", name: "index"},
{link: "projects.html", text: "projects", name: "projects"}, {link: "projects.html", text: "projects", name: "projects"},
{link: "https://git.hippoz.xyz", text: "git", name: "__ext_git"}, {link: "https://git.hippoz.xyz", text: "git", name: "__ext_git"},
], ],
@ -45,14 +45,14 @@ const linkButton = ({ link, text, selected=false }) => `
`; `;
const navigation = ({currentName}) => ` const navigation = ({currentName}) => `
<div class="card layout-card noselect"> <nav class="card layout-card noselect">
<div class="float-left"> <div class="float-left">
<b class="navigation-branding-text">${data.navigationBrandingText}</b> <b class="navigation-branding-text">${data.navigationBrandingText}</b>
</div> </div>
<div class="align-right"> <div class="align-right">
${data.navigationLinks.map(e => linkButton({ ...e, selected: currentName === e.name })).join("")} ${data.navigationLinks.map(e => linkButton({ ...e, selected: currentName === e.name })).join("")}
</div> </div>
</div> </nav>
`; `;
const makePage = ({ name, description, title }) => content => [` const makePage = ({ name, description, title }) => content => [`
@ -67,11 +67,9 @@ const makePage = ({ name, description, title }) => content => [`
</head> </head>
<body> <body>
${navigation({currentName: name})} ${navigation({currentName: name})}
<section class="card layout-card" id="content"> <main class="card layout-card" id="content">
${content} ${content}
</section> </main>
<script src="res/fastnav.js"></script>
</body> </body>
</html> </html>
`, content]; `, content];
@ -79,7 +77,7 @@ const makePage = ({ name, description, title }) => content => [`
const indexPage = () => makePage({ const indexPage = () => makePage({
title: "hippoz", title: "hippoz",
description: "hippoz website homepage", description: "hippoz website homepage",
name: "home", name: "index",
})(` })(`
<h2>hippoz's website</h2> <h2>hippoz's website</h2>
<p>i think</p> <p>i think</p>
@ -101,7 +99,7 @@ const projectsPage = async () => makePage({
<b>${repo.fork ? "🍴" : "📘"} ${repo.name}</b> <b>${repo.fork ? "🍴" : "📘"} ${repo.name}</b>
<a class="button-default float-right" href=${repo.html_url}>view >></a> <a class="button-default float-right" href=${repo.html_url}>view >></a>
</div> </div>
${repo.description ? `<p>${repo.description}</p>` : `<p class="grayed-out">Mysterious! This project has no description.</p>`} ${repo.description ? `<p>${repo.description}</p>` : ""}
</div>` </div>`
) )
.join("\n") .join("\n")
@ -124,25 +122,6 @@ const renderPages = async () => {
return renderedPageCache; return renderedPageCache;
}; };
const deployNavScript = async () => {
let script = await fs.readFile("./src/assets/fastnav.js");
if (script) script = script.toString();
const renderedPages = await renderPages();
let navMap = {};
for (let [pageName, content] of Object.entries(renderedPages)) {
if (data.postProcessing.beautifyOutput) {
content = beautifyHtml(content[1], data.postProcessing.minifyOutputOptions);
}
navMap[pageName] = content;
}
const content = script.replace(`"{{NAV_DATA}}"`, JSON.stringify(navMap));
await fs.writeFile("./out/res/fastnav.js", content);
};
const deployPages = async () => { const deployPages = async () => {
const renderedPages = await renderPages(); const renderedPages = await renderPages();
for (let [pageName, content] of Object.entries(renderedPages)) { for (let [pageName, content] of Object.entries(renderedPages)) {
@ -155,7 +134,6 @@ const deployPages = async () => {
}; };
const deployAll = async () => { const deployAll = async () => {
await deployNavScript();
await deployPages(); await deployPages();
}; };