Refactor all the things
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { editor, markdown, space, sync } from "$sb/silverbullet-syscall/mod.ts";
|
||||
import { editor, markdown, mq, space, sync } from "$sb/syscalls.ts";
|
||||
import {
|
||||
ParseTree,
|
||||
removeParentPointers,
|
||||
@@ -7,10 +7,9 @@ import {
|
||||
} from "$sb/lib/tree.ts";
|
||||
import { renderDirectives } from "./directives.ts";
|
||||
import { extractFrontmatter } from "$sb/lib/frontmatter.ts";
|
||||
import { PageMeta } from "../../web/types.ts";
|
||||
import type { PageMeta } from "../../web/types.ts";
|
||||
import { isFederationPath } from "$sb/lib/resolve.ts";
|
||||
import { mq } from "$sb/plugos-syscall/mod.ts";
|
||||
import { Message } from "$sb/types.ts";
|
||||
import { MQMessage } from "$sb/types.ts";
|
||||
import { sleep } from "../../common/async_util.ts";
|
||||
|
||||
const directiveUpdateQueueName = "directiveUpdateQueue";
|
||||
@@ -92,7 +91,7 @@ export async function updateDirectivesInSpaceCommand() {
|
||||
await editor.flashNotification("Updating of all directives completed!");
|
||||
}
|
||||
|
||||
export async function processUpdateQueue(messages: Message[]) {
|
||||
export async function processUpdateQueue(messages: MQMessage[]) {
|
||||
for (const message of messages) {
|
||||
const pageName: string = message.body;
|
||||
console.log("Updating directives in page", pageName);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { events } from "$sb/plugos-syscall/mod.ts";
|
||||
import { events } from "$sb/syscalls.ts";
|
||||
import { CompleteEvent } from "$sb/app_event.ts";
|
||||
import { buildHandebarOptions } from "./util.ts";
|
||||
import type { PageMeta } from "../../web/types.ts";
|
||||
import {
|
||||
import type {
|
||||
AttributeCompleteEvent,
|
||||
AttributeCompletion,
|
||||
} from "../core/attributes.ts";
|
||||
} from "../index/attributes.ts";
|
||||
|
||||
export async function queryComplete(completeEvent: CompleteEvent) {
|
||||
const querySourceMatch = /#query\s+([\w\-_]*)$/.exec(
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
// data:page@pos
|
||||
|
||||
import type { IndexTreeEvent, QueryProviderEvent } from "$sb/app_event.ts";
|
||||
import { index } from "$sb/silverbullet-syscall/mod.ts";
|
||||
import { index, YAML } from "$sb/syscalls.ts";
|
||||
import { collectNodesOfType, findNodeOfType } from "$sb/lib/tree.ts";
|
||||
import { applyQuery, removeQueries } from "$sb/lib/query.ts";
|
||||
import { YAML } from "$sb/plugos-syscall/mod.ts";
|
||||
|
||||
export async function indexData({ name, tree }: IndexTreeEvent) {
|
||||
const dataObjects: { key: string; value: any }[] = [];
|
||||
|
||||
@@ -39,7 +39,7 @@ functions:
|
||||
|
||||
# Templates
|
||||
insertQuery:
|
||||
redirect: core.insertTemplateText
|
||||
redirect: template.insertTemplateText
|
||||
slashCommand:
|
||||
name: query
|
||||
description: Insert a query
|
||||
@@ -48,7 +48,7 @@ functions:
|
||||
|
||||
<!-- /query -->
|
||||
insertInclude:
|
||||
redirect: core.insertTemplateText
|
||||
redirect: template.insertTemplateText
|
||||
slashCommand:
|
||||
name: include
|
||||
description: Include another page
|
||||
@@ -57,7 +57,7 @@ functions:
|
||||
|
||||
<!-- /include -->
|
||||
insertUseTemplate:
|
||||
redirect: core.insertTemplateText
|
||||
redirect: template.insertTemplateText
|
||||
slashCommand:
|
||||
name: use
|
||||
description: Use a template
|
||||
@@ -66,7 +66,7 @@ functions:
|
||||
|
||||
<!-- /use -->
|
||||
insertUseVerboseTemplate:
|
||||
redirect: core.insertTemplateText
|
||||
redirect: template.insertTemplateText
|
||||
slashCommand:
|
||||
name: use-verbose
|
||||
description: Use a template (verbose mode)
|
||||
@@ -75,7 +75,7 @@ functions:
|
||||
|
||||
<!-- /use-verbose -->
|
||||
insertEvalTemplate:
|
||||
redirect: core.insertTemplateText
|
||||
redirect: template.insertTemplateText
|
||||
slashCommand:
|
||||
name: eval
|
||||
description: Evaluate a JavaScript expression
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// This is some shocking stuff. My profession would kill me for this.
|
||||
|
||||
import { YAML } from "$sb/plugos-syscall/mod.ts";
|
||||
import { YAML } from "$sb/syscalls.ts";
|
||||
import { ParseTree } from "$sb/lib/tree.ts";
|
||||
import { jsonToMDTable, renderTemplate } from "./util.ts";
|
||||
import { PageMeta } from "../../web/types.ts";
|
||||
import { replaceTemplateVars } from "../core/template.ts";
|
||||
import type { PageMeta } from "../../web/types.ts";
|
||||
import { replaceTemplateVars } from "../template/template.ts";
|
||||
|
||||
// Enables plugName.functionName(arg1, arg2) syntax in JS expressions
|
||||
function translateJs(js: string): string {
|
||||
@@ -44,7 +44,7 @@ export async function evalDirectiveRenderer(
|
||||
const result = await (0, eval)(
|
||||
`(async () => {
|
||||
function invokeFunction(name, ...args) {
|
||||
return syscall("system.invoke", name, ...args);
|
||||
return syscall("system.invokeFunction", name, ...args);
|
||||
}
|
||||
return ${replaceTemplateVars(translateJs(expression), pageMeta)};
|
||||
})()`,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { events } from "$sb/plugos-syscall/mod.ts";
|
||||
import { events } from "$sb/syscalls.ts";
|
||||
|
||||
import { replaceTemplateVars } from "../core/template.ts";
|
||||
import { replaceTemplateVars } from "../template/template.ts";
|
||||
import { renderTemplate } from "./util.ts";
|
||||
import { parseQuery } from "./parser.ts";
|
||||
import { jsonToMDTable } from "./util.ts";
|
||||
import { ParseTree } from "$sb/lib/tree.ts";
|
||||
import { PageMeta } from "../../web/types.ts";
|
||||
import type { PageMeta } from "../../web/types.ts";
|
||||
|
||||
export async function queryDirectiveRenderer(
|
||||
_directive: string,
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
import { queryRegex } from "$sb/lib/query.ts";
|
||||
import {
|
||||
findNodeOfType,
|
||||
ParseTree,
|
||||
renderToText,
|
||||
traverseTree,
|
||||
} from "$sb/lib/tree.ts";
|
||||
import { markdown, space } from "$sb/silverbullet-syscall/mod.ts";
|
||||
import { ParseTree, renderToText } from "$sb/lib/tree.ts";
|
||||
import { markdown, space } from "$sb/syscalls.ts";
|
||||
import Handlebars from "handlebars";
|
||||
|
||||
import { replaceTemplateVars } from "../core/template.ts";
|
||||
import { replaceTemplateVars } from "../template/template.ts";
|
||||
import { extractFrontmatter } from "$sb/lib/frontmatter.ts";
|
||||
import { directiveRegex } from "./directives.ts";
|
||||
import { updateDirectives } from "./command.ts";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Handlebars from "handlebars";
|
||||
|
||||
import { space } from "$sb/silverbullet-syscall/mod.ts";
|
||||
import { PageMeta } from "../../web/types.ts";
|
||||
import { space } from "$sb/syscalls.ts";
|
||||
import type { PageMeta } from "../../web/types.ts";
|
||||
import { handlebarHelpers } from "./handlebar_helpers.ts";
|
||||
|
||||
const maxWidth = 70;
|
||||
|
||||
Reference in New Issue
Block a user