Work on client modes
This commit is contained in:
@@ -10,7 +10,7 @@ import { extractFrontmatter } from "$sb/lib/frontmatter.ts";
|
||||
import type { PageMeta } from "../../web/types.ts";
|
||||
import { isFederationPath } from "$sb/lib/resolve.ts";
|
||||
import { MQMessage } from "$sb/types.ts";
|
||||
import { sleep } from "../../common/async_util.ts";
|
||||
import { sleep } from "$sb/lib/async.ts";
|
||||
|
||||
const directiveUpdateQueueName = "directiveUpdateQueue";
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function brokenLinksCommand() {
|
||||
if (tree.type === "WikiLinkPage") {
|
||||
// Add the prefix in the link text
|
||||
const [pageName] = tree.children![0].text!.split("@");
|
||||
if (pageName.startsWith("💭 ")) {
|
||||
if (pageName.startsWith("!")) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
@@ -31,7 +31,7 @@ export async function brokenLinksCommand() {
|
||||
}
|
||||
if (tree.type === "PageRef") {
|
||||
const pageName = tree.children![0].text!.slice(2, -2);
|
||||
if (pageName.startsWith("💭 ")) {
|
||||
if (pageName.startsWith("!")) {
|
||||
return true;
|
||||
}
|
||||
if (!allPagesMap.has(pageName)) {
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { editor } from "$sb/syscalls.ts";
|
||||
|
||||
export async function setThinClient(def: any) {
|
||||
console.log("Setting thin client to", def.value);
|
||||
await editor.setUiOption("thinClientMode", def.value);
|
||||
await editor.reloadUI();
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
name: editor
|
||||
requiredPermissions:
|
||||
- fetch
|
||||
syntax:
|
||||
NakedURL:
|
||||
firstCharacters:
|
||||
@@ -59,6 +57,10 @@ functions:
|
||||
name: "Navigate: Home"
|
||||
key: "Alt-h"
|
||||
page: ""
|
||||
moveToPos:
|
||||
path: "./editor.ts:moveToPosCommand"
|
||||
command:
|
||||
name: "Navigate: Move Cursor to Position"
|
||||
|
||||
# Text editing commands
|
||||
quoteSelectionCommand:
|
||||
@@ -113,12 +115,8 @@ functions:
|
||||
centerCursor:
|
||||
path: "./editor.ts:centerCursorCommand"
|
||||
command:
|
||||
name: "Editor: Center Cursor"
|
||||
name: "Navigate: Center Cursor"
|
||||
key: "Ctrl-Alt-l"
|
||||
moveToPos:
|
||||
path: "./editor.ts:moveToPosCommand"
|
||||
command:
|
||||
name: "Editor: Move Cursor to Position"
|
||||
|
||||
# Debug commands
|
||||
parseCommand:
|
||||
@@ -197,18 +195,6 @@ functions:
|
||||
command:
|
||||
name: "Broken Links: Show"
|
||||
|
||||
# Client mode
|
||||
enableThinClient:
|
||||
path: ./client.ts:setThinClient
|
||||
command:
|
||||
name: "Client: Enable Thin Client"
|
||||
value: true
|
||||
disableThinClient:
|
||||
path: ./client.ts:setThinClient
|
||||
command:
|
||||
name: "Client: Disable Thin Client"
|
||||
value: false
|
||||
|
||||
# Random stuff
|
||||
statsCommand:
|
||||
path: ./stats.ts:statsCommand
|
||||
|
||||
@@ -96,8 +96,6 @@ functions:
|
||||
events:
|
||||
- editor:complete
|
||||
|
||||
|
||||
|
||||
# Hashtags
|
||||
indexTags:
|
||||
path: "./tags.ts:indexTags"
|
||||
|
||||
+2
-4
@@ -11,7 +11,7 @@ import {
|
||||
|
||||
import { applyQuery } from "$sb/lib/query.ts";
|
||||
import type { MQMessage } from "$sb/types.ts";
|
||||
import { sleep } from "../../common/async_util.ts";
|
||||
import { sleep } from "$sb/lib/async.ts";
|
||||
|
||||
// Key space:
|
||||
// meta: => metaJson
|
||||
@@ -53,9 +53,7 @@ export async function processIndexQueue(messages: MQMessage[]) {
|
||||
const name: string = message.body;
|
||||
console.log(`Indexing page ${name}`);
|
||||
const text = await space.readPage(name);
|
||||
// console.log("Going to parse markdown");
|
||||
const parsed = await markdown.parseMarkdown(text);
|
||||
// console.log("Dispatching ;age:index");
|
||||
await events.dispatchEvent("page:index", {
|
||||
name,
|
||||
tree: parsed,
|
||||
@@ -69,7 +67,7 @@ export async function clearPageIndex(page: string) {
|
||||
}
|
||||
|
||||
export async function parseIndexTextRepublish({ name, text }: IndexEvent) {
|
||||
console.log("Reindexing", name);
|
||||
// console.log("Reindexing", name);
|
||||
await events.dispatchEvent("page:index", {
|
||||
name,
|
||||
tree: await markdown.parseMarkdown(text),
|
||||
|
||||
@@ -2,8 +2,6 @@ name: search
|
||||
functions:
|
||||
indexPage:
|
||||
path: search.ts:indexPage
|
||||
# Only enable in client for now
|
||||
# env: client
|
||||
events:
|
||||
- page:index
|
||||
|
||||
|
||||
+14
-6
@@ -4,6 +4,7 @@ import { applyQuery } from "$sb/lib/query.ts";
|
||||
import { editor, index, store } from "$sb/syscalls.ts";
|
||||
import { BatchKVStore, SimpleSearchEngine } from "./engine.ts";
|
||||
import { FileMeta } from "$sb/types.ts";
|
||||
import { PromiseQueue } from "$sb/lib/async.ts";
|
||||
|
||||
const searchPrefix = "🔍 ";
|
||||
|
||||
@@ -30,11 +31,16 @@ const ftsRevKvStore = new StoreKVStore("fts_rev:");
|
||||
|
||||
const engine = new SimpleSearchEngine(ftsKvStore, ftsRevKvStore);
|
||||
|
||||
export async function indexPage({ name, tree }: IndexTreeEvent) {
|
||||
// Search indexing is prone to concurrency issues, so we queue all write operations
|
||||
const promiseQueue = new PromiseQueue();
|
||||
|
||||
export function indexPage({ name, tree }: IndexTreeEvent) {
|
||||
const text = renderToText(tree);
|
||||
// console.log("Now FTS indexing", name);
|
||||
await engine.deleteDocument(name);
|
||||
await engine.indexDocument({ id: name, text });
|
||||
return promiseQueue.runInQueue(async () => {
|
||||
// console.log("Now FTS indexing", name);
|
||||
await engine.deleteDocument(name);
|
||||
await engine.indexDocument({ id: name, text });
|
||||
});
|
||||
}
|
||||
|
||||
export async function clearIndex() {
|
||||
@@ -42,8 +48,10 @@ export async function clearIndex() {
|
||||
await store.deletePrefix("fts_rev:");
|
||||
}
|
||||
|
||||
export async function pageUnindex(pageName: string) {
|
||||
await engine.deleteDocument(pageName);
|
||||
export function pageUnindex(pageName: string) {
|
||||
return promiseQueue.runInQueue(() => {
|
||||
return engine.deleteDocument(pageName);
|
||||
});
|
||||
}
|
||||
|
||||
export async function queryProvider({
|
||||
|
||||
Reference in New Issue
Block a user