Moved bold and italics to plug, new file: plug protocol

This commit is contained in:
Zef Hemel
2022-06-23 17:08:42 +02:00
parent 94d0e31b30
commit b22775fcc4
10 changed files with 162 additions and 17 deletions
+20 -1
View File
@@ -134,7 +134,6 @@ export class ExpressServer {
this.eventHook.addLocalListener(
"get-plug:builtin",
async (plugName: string): Promise<Manifest> => {
// console.log("Ok, resovling a plugin", plugName);
if (!safeFilename.test(plugName)) {
throw new Error(`Invalid plug name: ${plugName}`);
}
@@ -150,6 +149,26 @@ export class ExpressServer {
}
);
this.eventHook.addLocalListener(
"get-plug:file",
async (plugPath: string): Promise<Manifest> => {
let resolvedPath = path.resolve(plugPath);
if (!resolvedPath.startsWith(process.cwd())) {
throw new Error(
`Plugin path outside working directory, this is disallowed: ${resolvedPath}`
);
}
try {
let manifestJson = await readFile(resolvedPath, "utf8");
return JSON.parse(manifestJson);
} catch (e) {
throw new Error(
`No such file: ${resolvedPath} or could not parse as JSON`
);
}
}
);
setInterval(() => {
this.space.updatePageList().catch(console.error);
}, 5000);
-1
View File
@@ -10,7 +10,6 @@
"silverbullet": "./dist/server/server.js"
},
"scripts": {
"start": "nodemon -w dist --exec 'silverbullet ../../pages'",
"test": "jest dist/test"
},
"targets": {