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

@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Atlas · Soleprint</title> <title>{{ system.title or 'Atlas' }} · Soleprint</title>
<link <link
rel="icon" rel="icon"
type="image/svg+xml" type="image/svg+xml"
@@ -172,7 +172,7 @@
stroke-width="2" stroke-width="2"
/> />
</svg> </svg>
<h1>Album</h1> <h1>{{ system.title or 'Atlas' }}</h1>
{% if soleprint_url %}<a {% if soleprint_url %}<a
href="{{ soleprint_url }}" href="{{ soleprint_url }}"
style=" style="
@@ -187,8 +187,7 @@
>{% endif %} >{% endif %}
</header> </header>
<p class="tagline"> <p class="tagline">
conocimiento y toma de decisiones {{ system.tagline or 'Actionable documentation' }}
<!-- Actionable documentation -->
</p> </p>
<section> <section>

View File

@@ -0,0 +1,3 @@
{
"items": []
}

View File

@@ -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"
}
]
}

View File

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

View File

@@ -3,11 +3,11 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ward · Soleprint</title> <title>{{ system.title or 'Station' }} · Soleprint</title>
<link <link
rel="icon" rel="icon"
type="image/svg+xml" type="image/svg+xml"
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='%231d4ed8'%3E%3Ccircle cx='24' cy='10' r='8'/%3E%3Cellipse cx='24' cy='32' rx='12' ry='14'/%3E%3Ccircle cx='20' cy='8' r='1.5' fill='white'/%3E%3Ccircle cx='28' cy='8' r='1.5' fill='white'/%3E%3Cellipse cx='24' cy='13' rx='2' ry='1' fill='white'/%3E%3Crect x='18' y='28' width='12' height='8' rx='2' fill='white' opacity='0.5'/%3E%3C/svg%3E" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='%231d4ed8'%3E%3Crect x='4' y='8' width='40' height='28' rx='3' fill='%231d4ed8'/%3E%3Crect x='8' y='12' width='32' height='20' rx='2' fill='%230a0a0a'/%3E%3Crect x='16' y='36' width='16' height='4' fill='%231d4ed8'/%3E%3Crect x='12' y='40' width='24' height='3' rx='1' fill='%231d4ed8'/%3E%3C/svg%3E"
/> />
<style> <style>
* { * {
@@ -160,26 +160,23 @@
</head> </head>
<body> <body>
<header style="position: relative"> <header style="position: relative">
<!-- Operation game patient --> <!-- Control station / monitor -->
<svg class="logo" viewBox="0 0 48 48" fill="currentColor"> <svg class="logo" viewBox="0 0 48 48" fill="currentColor">
<circle cx="24" cy="10" r="8" /> <rect x="4" y="8" width="40" height="28" rx="3" />
<ellipse cx="24" cy="32" rx="12" ry="14" />
<circle cx="20" cy="8" r="1.5" fill="#1d4ed8" />
<circle cx="28" cy="8" r="1.5" fill="#1d4ed8" />
<ellipse cx="24" cy="13" rx="2" ry="1" fill="#1d4ed8" />
<rect <rect
x="18" x="8"
y="28" y="12"
width="12" width="32"
height="8" height="20"
rx="2" rx="2"
fill="#1d4ed8" fill="#1d4ed8"
opacity="0.5"
/> />
<rect x="16" y="36" width="16" height="4" />
<rect x="12" y="40" width="24" height="3" rx="1" />
</svg> </svg>
<h1>Ward</h1> <h1>{{ system.title or 'Station' }}</h1>
{% if pawprint_url %}<a {% if soleprint_url %}<a
href="{{ pawprint_url }}" href="{{ soleprint_url }}"
style=" style="
position: absolute; position: absolute;
right: 0; right: 0;
@@ -191,61 +188,28 @@
>← Soleprint</a >← Soleprint</a
>{% endif %} >{% endif %}
</header> </header>
<p class="tagline"> <p class="tagline">{{ system.tagline or 'Monitors & Tools' }}</p>
Monitores, herramientas y pruebas<!-- Monitors & Tools -->
</p>
<section> <section>
<div class="composition"> <div class="composition">
<h3>Table</h3> <h3>
<div class="components"> {{ components.composed.title or 'Desk' }} = {{
<div components.composed.formula or 'Tools + Room + Depots' }}
class="component" </h3>
style=" <p>
display: flex; {{ components.composed.description or 'A configured
flex-direction: column; workspace' }}
gap: 0.5rem; </p>
"
>
<h4 style="margin-bottom: 0.25rem">Cabinet</h4>
<div
style="
background: #1a1a1a;
border: 1px solid #3f3f3f;
padding: 0.5rem;
border-radius: 6px;
font-size: 0.85rem;
color: #93c5fd;
"
>
Monitor
</div>
<div
style="
background: #1a1a1a;
border: 1px solid #3f3f3f;
padding: 0.5rem;
border-radius: 6px;
font-size: 0.85rem;
color: #93c5fd;
"
>
Tool
</div>
</div>
<div class="component"><h4>Room</h4></div>
<div class="component"><h4>Depot</h4></div>
</div>
</div> </div>
</section> </section>
<section> <section>
<h2>Tables</h2> <h2>{{ (components.composed.plural or 'desks')|title }}</h2>
<ul class="tables"> <ul class="tables">
{% for table in tables %} {% for desk in desks %}
<li> <li>
<span class="name">{{ table.title }}</span <span class="name">{{ desk.title }}</span
><span class="status">{{ table.status }}</span> ><span class="status">{{ desk.status }}</span>
</li> </li>
{% else %} {% else %}
<li><span class="name">--</span></li> <li><span class="name">--</span></li>
@@ -254,21 +218,7 @@
</section> </section>
<section> <section>
<h2>Cabinets</h2> <h2>{{ (components.watcher.plural or 'monitors')|title }}</h2>
<ul class="tables">
{% for cabinet in cabinets %}
<li>
<span class="name">{{ cabinet.title }}</span
><span class="status">{{ cabinet.status }}</span>
</li>
{% else %}
<li><span class="name">--</span></li>
{% endfor %}
</ul>
</section>
<section>
<h2>Monitors</h2>
<ul class="tables"> <ul class="tables">
{% for monitor in monitors %} {% for monitor in monitors %}
<li> <li>
@@ -283,7 +233,7 @@
</section> </section>
<section> <section>
<h2>Tools</h2> <h2>{{ (components.utility.plural or 'tools')|title }}</h2>
<ul class="tables"> <ul class="tables">
{% for tool in tools %} {% for tool in tools %}
<li> <li>
@@ -310,8 +260,8 @@
<a href="/health" class="health">/health</a> <a href="/health" class="health">/health</a>
<footer> <footer>
{% if pawprint_url %}<a href="{{ pawprint_url }}">← Soleprint</a>{% {% if soleprint_url %}<a href="{{ soleprint_url }}">← Soleprint</a
else %}<span class="disabled">← Soleprint</span>{% endif %} >{% else %}<span class="disabled">← Soleprint</span>{% endif %}
</footer> </footer>
</body> </body>
</html> </html>