forked from tools/josh
1
0
Fork 0

Remove API nav files, and add privacy link in help

Fixes #168.
This commit is contained in:
Florine W. Dekker 2021-05-06 17:05:31 +02:00
parent 8dfcba0be4
commit 5abf9d8201
Signed by: FWDekker
GPG Key ID: 78B3EAF58145AF25
5 changed files with 13 additions and 56 deletions

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "fwdekker.com",
"version": "0.40.6",
"version": "0.40.7",
"description": "The source code of [my personal website](https://fwdekker.com/).",
"author": "Felix W. Dekker",
"browser": "dist/bundle.js",
@ -24,27 +24,27 @@
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/chai": "^4.2.16",
"@types/chai": "^4.2.17",
"@types/js-cookie": "^2.2.6",
"@types/mocha": "^8.2.2",
"@types/semver": "^6.2.1",
"chai": "^4.3.4",
"grunt": "^1.3.0",
"grunt": "^1.4.0",
"grunt-cli": "^1.4.2",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0",
"grunt-webpack": "^4.0.2",
"grunt-webpack": "^4.0.3",
"jsdom": "^16.5.3",
"jsdom-global": "^3.0.2",
"mocha": "^8.3.2",
"nyc": "^15.1.0",
"ts-loader": "^8.1.0",
"ts-loader": "^9.1.2",
"ts-node": "^9.1.1",
"typescript": "^4.2.4",
"webpack": "^5.32.0",
"webpack-cli": "^4.6.0"
"webpack": "^5.36.2",
"webpack-cli": "^4.7.0"
}
}

View File

@ -649,7 +649,9 @@ return new Command(
const target = josh.util.isStandalone() ? \`target="_blank"\` : "";
streams.out.writeLine(
\`The source code of this website is ${n}
<a href="https://git.fwdekker.com/FWDekker/fwdekker.com" \${target}>available on git</a>.
<a href="https://git.fwdekker.com/FWDekker/fwdekker.com" \${target}>available on git</a>. ${n}
This website also has a <a href="https://fwdekker.com/privacy/">privacy policy</a> to assure you I won't
steal your data.
<b>List of commands</b>
\${commandEntries.join("\\n")}

View File

@ -8,52 +8,12 @@ import {HashProvider, User} from "./UserList";
* A file system.
*/
export class FileSystem {
/**
* The root of the directory structure defined by the navigation API of fwdekker.com.
*
* This value is initialized only if `Persistence.hasFileSystem` returns false when the application is loaded.
*/
static navRoot: Directory;
/**
* The root directory.
*/
readonly root: Directory;
/**
* Loads the contents of my home directory based on the navigation API of fwdekker.com.
*
* @return an empty promise :'(
*/
static async loadNavApi(): Promise<any> {
await fetch("https://fwdekker.com/api/nav/")
.then(it => it.json())
.then(json => this.navRoot = this.unpack(json)[1] as Directory)
.catch(e => {
console.error("Failed to fetch navigation elements", e);
this.navRoot = new Directory();
});
}
/**
* Unpacks the given entry from the navigation API.
*
* @param entry the entry to unpack
* @return the name and the (traversed and filled) node unpacked from the given entry
* @private
*/
private static unpack(entry: any): [string, Node] {
const name = entry.name?.toLowerCase()?.replace(/ /g, "-") ?? "";
if (entry.entries.length === 0)
return [`${name}.lnk`, new File(entry.link)];
const dir = new Directory();
entry.entries.forEach((child: any) => dir.add(...(this.unpack(child))));
return [name, dir];
}
/**
* Constructs a new file system.
*
@ -86,18 +46,16 @@ export class FileSystem {
}),
"home": new Directory({
"felix": new Directory({
"pgp.pub": new File("https://fwdkr.co/pgp", "lnk"),
"privacy.lnk": new File("https://fwdekker.com/privacy/"),
"pgp-key.pub": new File("https://fwdkr.co/pgp", "lnk"),
"privacy-policy.lnk": new File("https://fwdekker.com/privacy/"),
"resume.pdf": new File("https://fwdkr.co/cv", "lnk"),
"source-code.lnk": new File("https://git.fwdekker.com/FWDekker/fwdekker.com"),
}),
}),
"root": new Directory({
"password.txt": new File("root: g9PjKu"),
}),
});
const home = this.get(new Path("home", "felix")) as Directory;
Object.keys(FileSystem.navRoot.nodes).forEach(name => home.add(name, FileSystem.navRoot.get(name)!));
}

View File

@ -1,7 +1,6 @@
import * as semver from "semver";
// @ts-ignore
const {$, doAfterLoad, nav} = window.fwdekker;
import {FileSystem} from "./FileSystem";
import {Persistence} from "./Persistence";
import {ExpectedGoodbyeError} from "./Shared";
import {Terminal} from "./Terminal";
@ -63,8 +62,6 @@ doAfterLoad(() => {
*/
doAfterLoad(async () => {
$("#nav").appendChild(nav("/"));
if (!Persistence.hasFileSystem())
await FileSystem.loadNavApi();
window.terminal = new Terminal(
$("#terminal"),