Support flat event file

This commit is contained in:
tree 2023-01-23 14:25:24 +01:00
rodič 3552be676e
revize d3158e0d52
3 změnil soubory, kde provedl 24 přidání a 9 odebrání

Zobrazit soubor

@ -46,11 +46,13 @@ difficulty = "All Welcome"
# pick 1-4 # pick 1-4
tags = ["Solarpunk"] tags = ["Solarpunk"]
union = "gm-events"
# a color, to group key events visually. use sparingly # a color, to group key events visually. use sparingly
# color="" # color=""
# A small logomark for the corner of the event # A small logomark for the corner of the event
logomark = "/logomarks/coinfeedslm.png" logomark = "./logo.png"
# a description of the event. # a description of the event.
# will show up when the user clicks the event card. # will show up when the user clicks the event card.

Zobrazit soubor

@ -85,8 +85,9 @@ class DeConf_Package {
// load sub-events // load sub-events
pkg.events = []; pkg.events = [];
for await (const ef of Deno.readDir([...specDir, "events"].join("/"))) { for await (const ef of Deno.readDir([...specDir, "events"].join("/"))) {
if (!ef.name.match(/^[\w\d\-]+$/)) continue; const m = ef.name.match(/^([\w\d\-]+)(\.toml|)$/)
const ev = new DeConf_Event(ef.name); if (!m) continue;
const ev = new DeConf_Event(m[1]);
await ev.load([...specDir, "events", ef.name]); await ev.load([...specDir, "events", ef.name]);
pkg.events.push(ev); pkg.events.push(ev);
} }
@ -112,15 +113,24 @@ class DeConf_Event {
this.dir = null; this.dir = null;
} }
async load(dir) { async load(path) {
this.dir = dir.join("/"); let fn;
const efIndex = await _tomlLoad([...dir, "index.toml"].join("/")); if (path[path.length-1].match(/^(.+)\.toml$/)) {
fn = path
} else {
this.dir = path.join("/");
fn = [...path, "index.toml"]
}
const efIndex = await _tomlLoad(fn.join("/"));
const data = { const data = {
index: { id: this.id, ...efIndex }, index: { id: this.id, ...efIndex },
}; };
const syncDataFn = [...dir, "data.json"].join("/"); if (this.dir) {
if (await exists(syncDataFn)) { const syncDataFn = [...this.dir, "data.json"].join("/");
data.sync = await _jsonLoad(syncDataFn); if (await exists(syncDataFn)) {
data.sync = await _jsonLoad(syncDataFn);
}
} }
this.data = data; this.data = data;
} }

Zobrazit soubor

@ -92,6 +92,9 @@ properties:
type: array type: array
items: items:
type: string type: string
union:
type: string
pattern: "^[a-z0-9-]+$"
logomark: logomark:
type: string type: string
description: description: