@@ -1,6 +0,0 @@
|
||||
This page contains settings for configuring SilverBullet and its plugs. Any
|
||||
changes outside of the yaml block will be overwritten.
|
||||
|
||||
```yaml
|
||||
indexPage: index
|
||||
```
|
||||
@@ -12,7 +12,7 @@ export class PlugSpacePrimitives implements SpacePrimitives {
|
||||
constructor(
|
||||
private wrapped: SpacePrimitives,
|
||||
private hook: PageNamespaceHook,
|
||||
private env: string,
|
||||
private env?: string,
|
||||
) {}
|
||||
|
||||
performOperation(
|
||||
@@ -25,7 +25,7 @@ export class PlugSpacePrimitives implements SpacePrimitives {
|
||||
) {
|
||||
if (
|
||||
operation === type && pageName.match(pattern) &&
|
||||
(env ? env === this.env : true)
|
||||
(!this.env || (env && env === this.env))
|
||||
) {
|
||||
return plug.invoke(name, [pageName, ...args]);
|
||||
}
|
||||
|
||||
+2
-30
@@ -4,7 +4,7 @@ import { SpacePrimitives } from "../common/spaces/space_primitives.ts";
|
||||
import { EndpointHook } from "../plugos/hooks/endpoint.ts";
|
||||
import { AssetBundle } from "../plugos/asset_bundle/bundle.ts";
|
||||
import { SpaceSystem } from "./space_system.ts";
|
||||
import { parseYamlSettings } from "../common/util.ts";
|
||||
import { ensureAndLoadSettings } from "../common/util.ts";
|
||||
|
||||
export type ServerOptions = {
|
||||
hostname: string;
|
||||
@@ -66,7 +66,7 @@ export class HttpServer {
|
||||
async start() {
|
||||
await this.systemBoot.start();
|
||||
await this.systemBoot.ensureSpaceIndex();
|
||||
await this.ensureAndLoadSettings();
|
||||
await ensureAndLoadSettings(this.systemBoot.space);
|
||||
|
||||
this.addPasswordAuth(this.app);
|
||||
|
||||
@@ -149,34 +149,6 @@ export class HttpServer {
|
||||
);
|
||||
}
|
||||
|
||||
async ensureAndLoadSettings() {
|
||||
const space = this.systemBoot.space;
|
||||
try {
|
||||
await space.getPageMeta("SETTINGS");
|
||||
} catch {
|
||||
await space.writePage(
|
||||
"SETTINGS",
|
||||
this.systemBoot.assetBundle.readTextFileSync("SETTINGS_template.md"),
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
const { text: settingsText } = await space.readPage("SETTINGS");
|
||||
const settings = parseYamlSettings(settingsText);
|
||||
if (!settings.indexPage) {
|
||||
settings.indexPage = "index";
|
||||
}
|
||||
|
||||
try {
|
||||
await space.getPageMeta(settings.indexPage);
|
||||
} catch {
|
||||
await space.writePage(
|
||||
settings.indexPage,
|
||||
`Welcome to your new space!`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private addPasswordAuth(app: Application) {
|
||||
const excludedPaths = [
|
||||
"/manifest.json",
|
||||
|
||||
@@ -21,7 +21,7 @@ import shellSyscalls from "../plugos/syscalls/shell.deno.ts";
|
||||
import {
|
||||
ensureTable as ensureStoreTable,
|
||||
storeSyscalls,
|
||||
} from "../plugos/syscalls/store.deno.ts";
|
||||
} from "../plugos/syscalls/store.sqlite.ts";
|
||||
import { System } from "../plugos/system.ts";
|
||||
import { PageNamespaceHook } from "./hooks/page_namespace.ts";
|
||||
import { PlugSpacePrimitives } from "./hooks/plug_space_primitives.ts";
|
||||
@@ -36,6 +36,7 @@ import assetSyscalls from "../plugos/syscalls/asset.ts";
|
||||
import { AssetBundle } from "../plugos/asset_bundle/bundle.ts";
|
||||
import { AsyncSQLite } from "../plugos/sqlite/async_sqlite.ts";
|
||||
import { FileMetaSpacePrimitives } from "../common/spaces/file_meta_space_primitives.ts";
|
||||
import { sandboxFetchSyscalls } from "../plugos/syscalls/fetch.ts";
|
||||
export const indexRequiredKey = "$spaceIndexed";
|
||||
|
||||
// A composition of a PlugOS system attached to a Space for server-side use
|
||||
@@ -116,6 +117,7 @@ export class SpaceSystem {
|
||||
systemSyscalls(this.loadPlugsFromSpace.bind(this), this.system),
|
||||
sandboxSyscalls(this.system),
|
||||
assetSyscalls(this.system),
|
||||
sandboxFetchSyscalls(),
|
||||
);
|
||||
|
||||
// Danger zone, these syscalls require requesting specific permissions
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// import { Knex } from "knex";
|
||||
import { SysCallMapping } from "../../plugos/system.ts";
|
||||
import { Query, queryToSql } from "../../plugos/syscalls/store.deno.ts";
|
||||
import { AsyncSQLite } from "../../plugos/sqlite/async_sqlite.ts";
|
||||
import { Query, queryToSql } from "../../plugos/syscalls/store.sqlite.ts";
|
||||
import { ISQLite } from "../../plugos/sqlite/sqlite_interface.ts";
|
||||
|
||||
type Item = {
|
||||
page: string;
|
||||
@@ -16,7 +16,7 @@ export type KV = {
|
||||
|
||||
const tableName = "page_index";
|
||||
|
||||
export async function ensureTable(db: AsyncSQLite): Promise<void> {
|
||||
export async function ensureTable(db: ISQLite): Promise<void> {
|
||||
const result = await db.query(
|
||||
`SELECT name FROM sqlite_master WHERE type='table' AND name=?`,
|
||||
tableName,
|
||||
@@ -32,7 +32,7 @@ export async function ensureTable(db: AsyncSQLite): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export function pageIndexSyscalls(db: AsyncSQLite): SysCallMapping {
|
||||
export function pageIndexSyscalls(db: ISQLite): SysCallMapping {
|
||||
const apiObj: SysCallMapping = {
|
||||
"index.set": async (_ctx, page: string, key: string, value: any) => {
|
||||
await db.execute(
|
||||
|
||||
Reference in New Issue
Block a user