Templates 2.0 (#636)

Templates 2.0 and a whole bunch of other refactoring
This commit is contained in:
Zef Hemel
2024-01-20 19:16:07 +01:00
committed by GitHub
parent 0a6a0016a2
commit f30b1d3418
171 changed files with 2038 additions and 1628 deletions
+1 -1
View File
@@ -405,7 +405,7 @@ export class HttpServer {
const args: string[] = body;
try {
const result = await spaceServer.system!.syscall(
{ plug: plugName },
{ plug: plugName === "_" ? undefined : plugName },
syscall,
args,
);
+20 -1
View File
@@ -34,6 +34,8 @@ import { KVPrimitivesManifestCache } from "../plugos/manifest_cache.ts";
import { KvPrimitives } from "../plugos/lib/kv_primitives.ts";
import { ShellBackend } from "./shell_backend.ts";
import { ensureSpaceIndex } from "../common/space_index.ts";
import { FileMeta } from "$sb/types.ts";
import { buildQueryFunctions } from "../common/query_functions.ts";
// // Important: load this before the actual plugs
// import {
@@ -59,6 +61,7 @@ export class ServerSystem {
// denoKv!: Deno.Kv;
listInterval?: number;
ds!: DataStore;
allKnownPages = new Set<string>();
constructor(
private baseSpacePrimitives: SpacePrimitives,
@@ -69,7 +72,10 @@ export class ServerSystem {
// Always needs to be invoked right after construction
async init(awaitIndex = false) {
this.ds = new DataStore(this.kvPrimitives);
this.ds = new DataStore(
this.kvPrimitives,
buildQueryFunctions(this.allKnownPages),
);
this.system = new System(
"server",
@@ -177,6 +183,19 @@ export class ServerSystem {
}
});
eventHook.addLocalListener(
"file:listed",
(allFiles: FileMeta[]) => {
// Update list of known pages
this.allKnownPages.clear();
allFiles.forEach((f) => {
if (f.name.endsWith(".md")) {
this.allKnownPages.add(f.name.slice(0, -3));
}
});
},
);
// Ensure a valid index
const indexPromise = ensureSpaceIndex(this.ds, this.system);
if (awaitIndex) {