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

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ward · Soleprint</title>
<title>{{ system.title or 'Station' }} · Soleprint</title>
<link
rel="icon"
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>
* {
@@ -160,26 +160,23 @@
</head>
<body>
<header style="position: relative">
<!-- Operation game patient -->
<!-- Control station / monitor -->
<svg class="logo" viewBox="0 0 48 48" fill="currentColor">
<circle cx="24" cy="10" r="8" />
<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 x="4" y="8" width="40" height="28" rx="3" />
<rect
x="18"
y="28"
width="12"
height="8"
x="8"
y="12"
width="32"
height="20"
rx="2"
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>
<h1>Ward</h1>
{% if pawprint_url %}<a
href="{{ pawprint_url }}"
<h1>{{ system.title or 'Station' }}</h1>
{% if soleprint_url %}<a
href="{{ soleprint_url }}"
style="
position: absolute;
right: 0;
@@ -191,61 +188,28 @@
>← Soleprint</a
>{% endif %}
</header>
<p class="tagline">
Monitores, herramientas y pruebas<!-- Monitors & Tools -->
</p>
<p class="tagline">{{ system.tagline or 'Monitors & Tools' }}</p>
<section>
<div class="composition">
<h3>Table</h3>
<div class="components">
<div
class="component"
style="
display: flex;
flex-direction: column;
gap: 0.5rem;
"
>
<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>
<h3>
{{ components.composed.title or 'Desk' }} = {{
components.composed.formula or 'Tools + Room + Depots' }}
</h3>
<p>
{{ components.composed.description or 'A configured
workspace' }}
</p>
</div>
</section>
<section>
<h2>Tables</h2>
<h2>{{ (components.composed.plural or 'desks')|title }}</h2>
<ul class="tables">
{% for table in tables %}
{% for desk in desks %}
<li>
<span class="name">{{ table.title }}</span
><span class="status">{{ table.status }}</span>
<span class="name">{{ desk.title }}</span
><span class="status">{{ desk.status }}</span>
</li>
{% else %}
<li><span class="name">--</span></li>
@@ -254,21 +218,7 @@
</section>
<section>
<h2>Cabinets</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>
<h2>{{ (components.watcher.plural or 'monitors')|title }}</h2>
<ul class="tables">
{% for monitor in monitors %}
<li>
@@ -283,7 +233,7 @@
</section>
<section>
<h2>Tools</h2>
<h2>{{ (components.utility.plural or 'tools')|title }}</h2>
<ul class="tables">
{% for tool in tools %}
<li>
@@ -310,8 +260,8 @@
<a href="/health" class="health">/health</a>
<footer>
{% if pawprint_url %}<a href="{{ pawprint_url }}">← Soleprint</a>{%
else %}<span class="disabled">← Soleprint</span>{% endif %}
{% if soleprint_url %}<a href="{{ soleprint_url }}">← Soleprint</a
>{% else %}<span class="disabled">← Soleprint</span>{% endif %}
</footer>
</body>
</html>