Work on sync stuff

This commit is contained in:
Zef Hemel
2022-04-05 17:02:17 +02:00
parent 1b0048cdcf
commit 38faf50ab8
51 changed files with 704 additions and 257 deletions
+5 -5
View File
@@ -1,9 +1,9 @@
import {IndexEvent} from "../../webapp/app_event";
import {whiteOutQueries} from "./materialized_queries";
import { IndexEvent } from "../../webapp/app_event";
import { whiteOutQueries } from "./materialized_queries";
import {batchSet} from "plugos-silverbullet-syscall/index";
import {parseMarkdown} from "plugos-silverbullet-syscall/markdown";
import {collectNodesMatching, MarkdownTree, renderMarkdown,} from "../lib/tree";
import { batchSet } from "plugos-silverbullet-syscall/index";
import { parseMarkdown } from "plugos-silverbullet-syscall/markdown";
import { collectNodesMatching, MarkdownTree, renderMarkdown } from "../lib/tree";
type Item = {
item: string;
+9 -5
View File
@@ -1,8 +1,8 @@
import {flashNotification, getCurrentPage, reloadPage, save,} from "plugos-silverbullet-syscall/editor";
import { flashNotification, getCurrentPage, reloadPage, save } from "plugos-silverbullet-syscall/editor";
import {listPages, readPage, writePage,} from "plugos-silverbullet-syscall/space";
import {invokeFunctionOnServer} from "plugos-silverbullet-syscall/system";
import {scanPrefixGlobal} from "plugos-silverbullet-syscall";
import { listPages, readPage, writePage } from "plugos-silverbullet-syscall/space";
import { invokeFunction } from "plugos-silverbullet-syscall/system";
import { scanPrefixGlobal } from "plugos-silverbullet-syscall";
export const queryRegex =
/(<!--\s*#query\s+(?<table>\w+)\s*(filter\s+["'](?<filter>[^"']+)["'])?\s*\s*(order by\s+(?<orderBy>\w+)(?<orderDesc>\s+desc)?)?(group by\s+(?<groupBy>\w+))?\s*(limit\s+(?<limit>\d+))?\s*-->)(.+?)(<!--\s*#end\s*-->)/gs;
@@ -31,7 +31,11 @@ async function replaceAsync(
export async function updateMaterializedQueriesCommand() {
const currentPage = await getCurrentPage();
await save();
await invokeFunctionOnServer("updateMaterializedQueriesOnPage", currentPage);
await invokeFunction(
"server",
"updateMaterializedQueriesOnPage",
currentPage
);
await reloadPage();
await flashNotification("Updated materialized queries");
}
+6 -6
View File
@@ -1,9 +1,9 @@
import {ClickEvent} from "../../webapp/app_event";
import {updateMaterializedQueriesCommand} from "./materialized_queries";
import {getCursor, getText, navigate as navigateTo, openUrl,} from "plugos-silverbullet-syscall/editor";
import {taskToggleAtPos} from "../tasks/task";
import {parseMarkdown} from "plugos-silverbullet-syscall/markdown";
import {MarkdownTree, nodeAtPos} from "../lib/tree";
import { ClickEvent } from "../../webapp/app_event";
import { updateMaterializedQueriesCommand } from "./materialized_queries";
import { getCursor, getText, navigate as navigateTo, openUrl } from "plugos-silverbullet-syscall/editor";
import { taskToggleAtPos } from "../tasks/task";
import { parseMarkdown } from "plugos-silverbullet-syscall/markdown";
import { MarkdownTree, nodeAtPos } from "../lib/tree";
const materializedQueryPrefix = /<!--\s*#query\s+/;
+5 -16
View File
@@ -4,24 +4,13 @@ import {
batchSet,
clearPageIndex as clearPageIndexSyscall,
clearPageIndexForPage,
scanPrefixGlobal,
scanPrefixGlobal
} from "plugos-silverbullet-syscall/index";
import {
flashNotification,
getCurrentPage,
getText,
matchBefore,
navigate,
} from "plugos-silverbullet-syscall/editor";
import { flashNotification, getCurrentPage, getText, matchBefore, navigate } from "plugos-silverbullet-syscall/editor";
import { dispatch } from "plugos-syscall/event";
import {
deletePage as deletePageSyscall,
listPages,
readPage,
writePage,
} from "plugos-silverbullet-syscall/space";
import { invokeFunctionOnServer } from "plugos-silverbullet-syscall/system";
import { deletePage as deletePageSyscall, listPages, readPage, writePage } from "plugos-silverbullet-syscall/space";
import { invokeFunction } from "plugos-silverbullet-syscall/system";
const wikilinkRegex = new RegExp(pageLinkRegex, "g");
@@ -120,7 +109,7 @@ export async function showBackLinks() {
export async function reindexCommand() {
await flashNotification("Reindexing...");
await invokeFunctionOnServer("reindexSpace");
await invokeFunction("server", "reindexSpace");
await flashNotification("Reindexing done");
}
+1 -1
View File
@@ -1,6 +1,6 @@
// @ts-ignore
import emojis from "./emoji.json";
import {matchBefore} from "plugos-silverbullet-syscall/editor";
import { matchBefore } from "plugos-silverbullet-syscall/editor";
const emojiMatcher = /\(([^\)]+)\)\s+(.+)$/;
+3 -3
View File
@@ -1,6 +1,6 @@
import { run } from "plugos-syscall/shell";
import { flashNotification, prompt } from "plugos-silverbullet-syscall/editor";
import { invokeFunctionOnServer } from "plugos-silverbullet-syscall/system";
import { invokeFunction } from "plugos-silverbullet-syscall/system";
export async function commit(message?: string) {
if (!message) {
@@ -25,12 +25,12 @@ export async function snapshotCommand() {
revName = "Snapshot";
}
console.log("Revision name", revName);
await invokeFunctionOnServer("commit", revName);
await invokeFunction("server", "commit", revName);
}
export async function syncCommand() {
await flashNotification("Syncing with git");
await invokeFunctionOnServer("sync");
await invokeFunction("server", "sync");
await flashNotification("Git sync complete!");
}
+3 -3
View File
@@ -1,6 +1,6 @@
import {expect, test} from "@jest/globals";
import {parse} from "../../common/tree";
import {addParentPointers, collectNodesMatching, findParentMatching, nodeAtPos, renderMarkdown,} from "./tree";
import { expect, test } from "@jest/globals";
import { parse } from "../../common/tree";
import { addParentPointers, collectNodesMatching, findParentMatching, nodeAtPos, renderMarkdown } from "./tree";
const mdTest1 = `
# Heading
+3 -3
View File
@@ -1,8 +1,8 @@
import MarkdownIt from "markdown-it";
import {getText, hideRhs, showRhs} from "plugos-silverbullet-syscall/editor";
import { getText, hideRhs, showRhs } from "plugos-silverbullet-syscall/editor";
import * as clientStore from "plugos-silverbullet-syscall/clientStore";
import {parseMarkdown} from "plugos-silverbullet-syscall/markdown";
import {addParentPointers, renderMarkdown, replaceNodesMatching,} from "../lib/tree";
import { parseMarkdown } from "plugos-silverbullet-syscall/markdown";
import { addParentPointers, renderMarkdown, replaceNodesMatching } from "../lib/tree";
var taskLists = require("markdown-it-task-lists");
+8 -8
View File
@@ -1,12 +1,12 @@
import type {ClickEvent} from "../../webapp/app_event";
import {IndexEvent} from "../../webapp/app_event";
import type { ClickEvent } from "../../webapp/app_event";
import { IndexEvent } from "../../webapp/app_event";
import {whiteOutQueries} from "../core/materialized_queries";
import {batchSet} from "plugos-silverbullet-syscall/index";
import {readPage, writePage} from "plugos-silverbullet-syscall/space";
import {parseMarkdown} from "plugos-silverbullet-syscall/markdown";
import {dispatch, getText} from "plugos-silverbullet-syscall/editor";
import {addParentPointers, collectNodesMatching, nodeAtPos, renderMarkdown,} from "../lib/tree";
import { whiteOutQueries } from "../core/materialized_queries";
import { batchSet } from "plugos-silverbullet-syscall/index";
import { readPage, writePage } from "plugos-silverbullet-syscall/space";
import { parseMarkdown } from "plugos-silverbullet-syscall/markdown";
import { dispatch, getText } from "plugos-silverbullet-syscall/editor";
import { addParentPointers, collectNodesMatching, nodeAtPos, renderMarkdown } from "../lib/tree";
type Task = {
task: string;