Mobile app PoC (#281)

Initial checkin of mobile "native" app
This commit is contained in:
Zef Hemel
2023-01-08 12:24:12 +01:00
committed by GitHub
parent dc7de9d8f9
commit 0365673c41
61 changed files with 5190 additions and 155 deletions
+31
View File
@@ -1,4 +1,6 @@
import { SETTINGS_TEMPLATE } from "./settings_template.ts";
import { YAML } from "./deps.ts";
import { Space } from "./spaces/space.ts";
export function safeRun(fn: () => Promise<void>) {
fn().catch((e) => {
@@ -42,3 +44,32 @@ export function parseYamlSettings(settingsMarkdown: string): {
return {};
}
}
export async function ensureAndLoadSettings(space: Space) {
try {
await space.getPageMeta("SETTINGS");
} catch {
await space.writePage(
"SETTINGS",
SETTINGS_TEMPLATE,
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!`,
);
}
return settings;
}