Use dynamic config for system names and components
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

- Station: Ward -> Station, Cabinet -> Desk, Table -> Desk
- Atlas: Album -> Atlas
- All templates now read from config.json for titles/taglines
- Added shunts.json and plexuses.json data files
- run.py passes system and components to all templates
This commit is contained in:
buenosairesam
2026-01-02 23:52:43 -03:00
parent c4ec112607
commit 27b32deba4
5 changed files with 121 additions and 114 deletions

View File

@@ -31,6 +31,30 @@ templates = Jinja2Templates(directory=Path(__file__).parent)
# Base path for systems (gen/ directory where this runs from)
SPR_ROOT = Path(__file__).parent
DATA_DIR = SPR_ROOT / "data"
CFG_DIR = SPR_ROOT / "cfg"
def load_config() -> dict:
"""Load config.json from cfg/ directory."""
config_path = CFG_DIR / "config.json"
if config_path.exists():
return json.loads(config_path.read_text())
return {}
def get_system_config(system_key: str) -> dict:
"""Get system configuration by key (data_flow, documentation, execution)."""
config = load_config()
for system in config.get("systems", []):
if system.get("key") == system_key:
return system
return {}
def get_components(system_key: str) -> dict:
"""Get component definitions for a system."""
config = load_config()
return config.get("components", {}).get(system_key, {})
def load_data(filename: str) -> list[dict]:
@@ -85,28 +109,29 @@ def artery_index(request: Request):
"""Artery landing page."""
html_path = SPR_ROOT / "artery" / "index.html"
if html_path.exists():
# Get system config and components
system = get_system_config("data_flow")
components = get_components("data_flow")
# Load from data files
veins = load_data("veins.json")
pulses = load_data("pulses.json")
shunts_data = load_data("shunts.json")
plexuses = load_data("plexuses.json")
# Scan directories for items not in data files
shunts = scan_directory(SPR_ROOT / "artery" / "shunts")
# Scan directories for shunts not in data files
shunts = (
shunts_data
if shunts_data
else scan_directory(SPR_ROOT / "artery" / "shunts")
)
for s in shunts:
s["slug"] = s["name"]
s["title"] = s["name"].replace("-", " ").title()
s["status"] = "ready"
depots = scan_directory(SPR_ROOT / "artery" / "depots")
for d in depots:
d["slug"] = d["name"]
d["title"] = d["name"].replace("-", " ").title()
d["status"] = "ready"
rooms = scan_directory(SPR_ROOT / "artery" / "room")
for r in rooms:
r["slug"] = r["name"]
r["title"] = r["name"].replace("-", " ").title()
r["status"] = "ready"
if "slug" not in s:
s["slug"] = s.get("name", "")
if "title" not in s:
s["title"] = s.get("name", "").replace("-", " ").title()
if "status" not in s:
s["status"] = "ready"
from jinja2 import Template
@@ -114,22 +139,22 @@ def artery_index(request: Request):
return HTMLResponse(
template.render(
request=request,
system=system,
components=components,
veins=veins,
rooms=rooms,
pulses=pulses,
shunts=shunts,
depots=depots,
plexuses=[], # Placeholder - whatsapp planned
plexuses=plexuses,
soleprint_url="/",
pawprint_url="/",
)
)
veins_path = SPR_ROOT / "artery" / "veins"
veins = scan_directory(veins_path)
system = get_system_config("data_flow")
return JSONResponse(
{
"system": "artery",
"tagline": "Todo lo vital",
"system": system.get("name", "artery"),
"tagline": system.get("tagline", ""),
"veins": veins,
}
)
@@ -150,6 +175,10 @@ def atlas_index(request: Request):
"""Atlas landing page."""
html_path = SPR_ROOT / "atlas" / "index.html"
if html_path.exists():
# Get system config and components
system = get_system_config("documentation")
components = get_components("documentation")
# Load books from data file (includes template info for templated vs original)
books = load_data("books.json")
templates = load_data("templates.json")
@@ -161,16 +190,19 @@ def atlas_index(request: Request):
return HTMLResponse(
template.render(
request=request,
system=system,
components=components,
books=books,
templates=templates,
depots=depots,
soleprint_url="/",
)
)
system = get_system_config("documentation")
return JSONResponse(
{
"system": "atlas",
"tagline": "Documentacion accionable",
"system": system.get("name", "atlas"),
"tagline": system.get("tagline", ""),
"books": [],
}
)
@@ -191,6 +223,10 @@ def station_index(request: Request):
"""Station landing page."""
html_path = SPR_ROOT / "station" / "index.html"
if html_path.exists():
# Get system config and components
system = get_system_config("execution")
components = get_components("execution")
tools = scan_directory(SPR_ROOT / "station" / "tools")
for t in tools:
t["slug"] = t["name"]
@@ -212,20 +248,21 @@ def station_index(request: Request):
return HTMLResponse(
template.render(
request=request,
system=system,
components=components,
tools=tools,
monitors=monitors,
cabinets=desks,
tables=[],
desks=desks,
soleprint_url="/",
pawprint_url="/",
)
)
tools_path = SPR_ROOT / "station" / "tools"
tools = scan_directory(tools_path)
system = get_system_config("execution")
return JSONResponse(
{
"system": "station",
"tagline": "Monitores, Entornos y Herramientas",
"system": system.get("name", "station"),
"tagline": system.get("tagline", ""),
"tools": tools,
}
)