From 27b32deba498a93bf4432172d4e98e82a74b2d96 Mon Sep 17 00:00:00 2001 From: buenosairesam Date: Fri, 2 Jan 2026 23:52:43 -0300 Subject: [PATCH] Use dynamic config for system names and components - 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 --- atlas/index.html | 7 +- cfg/standalone/data/plexuses.json | 3 + cfg/standalone/data/shunts.json | 18 +++++ soleprint/run.py | 97 ++++++++++++++++++-------- station/index.html | 110 ++++++++---------------------- 5 files changed, 121 insertions(+), 114 deletions(-) create mode 100644 cfg/standalone/data/plexuses.json create mode 100644 cfg/standalone/data/shunts.json diff --git a/atlas/index.html b/atlas/index.html index f36f3cf..95da078 100644 --- a/atlas/index.html +++ b/atlas/index.html @@ -3,7 +3,7 @@ - Atlas · Soleprint + {{ system.title or 'Atlas' }} · Soleprint -

Album

+

{{ system.title or 'Atlas' }}

{% if soleprint_url %} - conocimiento y toma de decisiones - + {{ system.tagline or 'Actionable documentation' }}

diff --git a/cfg/standalone/data/plexuses.json b/cfg/standalone/data/plexuses.json new file mode 100644 index 0000000..2feb210 --- /dev/null +++ b/cfg/standalone/data/plexuses.json @@ -0,0 +1,3 @@ +{ + "items": [] +} diff --git a/cfg/standalone/data/shunts.json b/cfg/standalone/data/shunts.json new file mode 100644 index 0000000..bff7fcf --- /dev/null +++ b/cfg/standalone/data/shunts.json @@ -0,0 +1,18 @@ +{ + "items": [ + { + "name": "mercadopago", + "slug": "mercadopago", + "title": "MercadoPago", + "status": "ready", + "description": "Mock payment API for testing" + }, + { + "name": "example", + "slug": "example", + "title": "Example", + "status": "ready", + "description": "Example shunt template" + } + ] +} diff --git a/soleprint/run.py b/soleprint/run.py index 1ea0cd3..01710d1 100644 --- a/soleprint/run.py +++ b/soleprint/run.py @@ -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, } ) diff --git a/station/index.html b/station/index.html index d0c3075..ae7a693 100644 --- a/station/index.html +++ b/station/index.html @@ -3,11 +3,11 @@ - Ward · Soleprint + {{ system.title or 'Station' }} · Soleprint