Fixes #90: Re-enables full text search

This commit is contained in:
Zef Hemel
2022-10-19 09:52:29 +02:00
parent e225c926f5
commit 70501bc3e4
13 changed files with 128 additions and 80 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
export * from "../common/deps.ts";
export { DB as SQLite } from "https://deno.land/x/sqlite@v3.5.0/mod.ts";
export { DB as SQLite } from "../plugos/forked/deno-sqlite/mod.ts";
export { Application, Router } from "https://deno.land/x/oak@v11.1.0/mod.ts";
export * as etag from "https://deno.land/x/oak@v11.1.0/etag.ts";
+17 -3
View File
@@ -6,6 +6,7 @@ import {
} from "../../common/spaces/space_primitives.ts";
import { FileMeta } from "../../common/types.ts";
import { NamespaceOperation, PageNamespaceHook } from "./page_namespace.ts";
import { base64DecodeDataUrl } from "../../plugos/asset_bundle/base64.ts";
export class PlugSpacePrimitives implements SpacePrimitives {
constructor(
@@ -46,13 +47,26 @@ export class PlugSpacePrimitives implements SpacePrimitives {
return allFiles;
}
readFile(
async readFile(
name: string,
encoding: FileEncoding,
): Promise<{ data: FileData; meta: FileMeta }> {
const result = this.performOperation("readFile", name);
const wantArrayBuffer = encoding === "arraybuffer";
const result: { data: FileData; meta: FileMeta } | false = await this
.performOperation(
"readFile",
name,
wantArrayBuffer ? "dataurl" : encoding,
);
if (result) {
return result;
if (wantArrayBuffer) {
return {
data: base64DecodeDataUrl(result.data as string),
meta: result.meta,
};
} else {
return result;
}
}
return this.wrapped.readFile(name, encoding);
}
+11 -3
View File
@@ -1,4 +1,4 @@
import { Application, path, Router, SQLite } from "./deps.ts";
import { Application, etag, path, Router, SQLite } from "./deps.ts";
import { Manifest, SilverBulletHooks } from "../common/manifest.ts";
import { loadMarkdownExtensions } from "../common/markdown_ext.ts";
import buildMarkdown from "../common/parser.ts";
@@ -15,7 +15,10 @@ import { DenoCronHook } from "../plugos/hooks/cron.deno.ts";
import { esbuildSyscalls } from "../plugos/syscalls/esbuild.ts";
import { eventSyscalls } from "../plugos/syscalls/event.ts";
import fileSystemSyscalls from "../plugos/syscalls/fs.deno.ts";
import { fullTextSearchSyscalls } from "../plugos/syscalls/fulltext.knex_sqlite.ts";
import {
ensureFTSTable,
fullTextSearchSyscalls,
} from "../plugos/syscalls/fulltext.knex_sqlite.ts";
import sandboxSyscalls from "../plugos/syscalls/sandbox.ts";
import shellSyscalls from "../plugos/syscalls/shell.node.ts";
import {
@@ -43,6 +46,7 @@ export type ServerOptions = {
};
const indexRequiredKey = "$spaceIndexed";
const staticLastModified = new Date().toUTCString();
export class HttpServer {
app: Application;
@@ -198,7 +202,7 @@ export class HttpServer {
async start() {
await ensureIndexTable(this.db);
await ensureStoreTable(this.db, "store");
// await ensureFTSTable(this.db, "fts");
await ensureFTSTable(this.db, "fts");
await this.ensureAndLoadSettings();
// Load plugs
@@ -211,6 +215,8 @@ export class HttpServer {
response.body = this.assetBundle.readTextFileSync(
"web/index.html",
);
response.headers.set("Last-Modified", staticLastModified);
response.headers.set("ETag", await etag.calculate(response.body));
return;
}
try {
@@ -224,6 +230,8 @@ export class HttpServer {
assetName,
);
response.headers.set("Content-length", "" + data.length);
response.headers.set("Last-Modified", staticLastModified);
response.headers.set("ETag", await etag.calculate(data));
if (request.method === "GET") {
response.body = data;