feat: scaffold webinar-dash plugin with config block
This commit is contained in:
48
.obsidian/plugins/webinar-dash/main.js
vendored
Normal file
48
.obsidian/plugins/webinar-dash/main.js
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Obsidian injects its own module resolver. Under plain `node --test` it is
|
||||||
|
// absent, so guard the require and fall back to an empty base class. This is
|
||||||
|
// what keeps the pure helpers below unit-testable without an Obsidian runtime.
|
||||||
|
let OB = null;
|
||||||
|
try {
|
||||||
|
OB = require("obsidian");
|
||||||
|
} catch (_) {
|
||||||
|
OB = null;
|
||||||
|
}
|
||||||
|
const PluginBase = OB ? OB.Plugin : class {};
|
||||||
|
|
||||||
|
const STATIONS = ["Chat box", "ReAct", "Tools", "Memory", "Skills", "Process", "OS"];
|
||||||
|
|
||||||
|
const DEFAULTS = {
|
||||||
|
script: "raw/sources/Webinar script.md",
|
||||||
|
coverage: "wiki/script-coverage.md",
|
||||||
|
rawDir: "raw/sources",
|
||||||
|
wikiSourceDir: "wiki/sources",
|
||||||
|
conceptDir: "wiki/concepts",
|
||||||
|
};
|
||||||
|
|
||||||
|
function parseConfig(source) {
|
||||||
|
const cfg = Object.assign({}, DEFAULTS);
|
||||||
|
for (const line of String(source).split(/\r?\n/)) {
|
||||||
|
const m = line.match(/^\s*([A-Za-z][A-Za-z0-9_]*)\s*:\s*(.+?)\s*$/);
|
||||||
|
if (m && Object.prototype.hasOwnProperty.call(DEFAULTS, m[1])) {
|
||||||
|
cfg[m[1]] = m[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
class WebinarDashPlugin extends PluginBase {
|
||||||
|
async onload() {
|
||||||
|
this.registerMarkdownCodeBlockProcessor("webinar-dash", (source, el, ctx) => {
|
||||||
|
const cfg = parseConfig(source);
|
||||||
|
const root = el.createDiv({ cls: "webinar-dash" });
|
||||||
|
root.createDiv({ cls: "wd-eyebrow", text: "Webinar dashboard" });
|
||||||
|
root.createEl("p", { text: `Reading coverage from ${cfg.coverage}` });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = WebinarDashPlugin;
|
||||||
|
module.exports.default = WebinarDashPlugin;
|
||||||
|
module.exports.__test__ = { parseConfig, STATIONS, DEFAULTS };
|
||||||
9
.obsidian/plugins/webinar-dash/manifest.json
vendored
Normal file
9
.obsidian/plugins/webinar-dash/manifest.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"id": "webinar-dash",
|
||||||
|
"name": "Webinar dashboard",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"minAppVersion": "1.5.0",
|
||||||
|
"description": "Source pipeline and script coverage for the webinar vault.",
|
||||||
|
"author": "meels",
|
||||||
|
"isDesktopOnly": true
|
||||||
|
}
|
||||||
6
dashboard.md
Normal file
6
dashboard.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Webinar dashboard
|
||||||
|
|
||||||
|
```webinar-dash
|
||||||
|
script: raw/sources/Webinar script.md
|
||||||
|
coverage: wiki/script-coverage.md
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user