Pi66

Home | Repos | About | Blog | Gaza

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

About | Files | Commits | Refs | License


api: add API singleton with GlobalStore and expose decorator

Author: pi66
Date: 2026-07-21 10:13
commit: 0e791dde

Stat

A src/api.py 19 +19 -0

Diff

diff --git a/src/api.py b/src/api.py
new file mode 100644
index 0000000..4309730
--- /dev/null
+++ b/src/api.py
@@ -0,0 +1,19 @@
+"""Bridge between merodi core and user plugins"""
+
+class GlobalStore:
+    def __init__(self):
+        self.data = {}
+
+class API:
+    def __init__(self):
+        self.globals = GlobalStore()
+        self.log = None
+        self.config = None
+
+api = API()
+

...
Show all
diff --git a/src/api.py b/src/api.py
new file mode 100644
index 0000000..4309730
--- /dev/null
+++ b/src/api.py
@@ -0,0 +1,19 @@
+"""Bridge between merodi core and user plugins"""
+
+class GlobalStore:
+    def __init__(self):
+        self.data = {}
+
+class API:
+    def __init__(self):
+        self.globals = GlobalStore()
+        self.log = None
+        self.config = None
+
+api = API()
+
+def expose(name):
+    def decorator(fn):
+        setattr(api, name, fn)
+        return fn
+    return decorator

// Created by Pi66

// Copyright ©Pi66 2026