From e08862b81dc2f82466b48dd44c41676b70dc9f1c Mon Sep 17 00:00:00 2001 From: sjat Date: Wed, 24 Jun 2026 17:49:49 +0200 Subject: [PATCH] fix(rack): draw shelves after rails (match spec placement) --- scripts/gen_rack.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/scripts/gen_rack.py b/scripts/gen_rack.py index 9996e8e..a43a17b 100644 --- a/scripts/gen_rack.py +++ b/scripts/gen_rack.py @@ -384,6 +384,25 @@ def render_svg(rack: str, items: list[dict]) -> str: if face in ("rear", "both"): draw_device(fm, rear_x) + def draw_rail(fm: dict, x: int) -> None: + color = KIND_COLORS.get(fm.get("kind", ""), DEFAULT_COLOR) + name = fm.get("hostname", "?") + cx = x + RAIL_W // 2 + cy = top + body_h // 2 + p.append( + f'' + ) + p.append( + f'{_esc(name)}' + ) + + for idx, fm in enumerate(left_items): + draw_rail(fm, PAD + idx * RAIL_W) + for idx, fm in enumerate(right_items): + draw_rail(fm, rear_x + COL_W + idx * RAIL_W) + SHELF_STRIP_H = 6 shelves = [i for i in items if i.get("kind") == "shelf"] mounted = [i for i in items if "mounted_on" in i] @@ -431,25 +450,6 @@ def render_svg(rack: str, items: list[dict]) -> str: for fm in sorted(shelves, key=lambda s: s.get("hostname", "")): draw_shelf(fm) - def draw_rail(fm: dict, x: int) -> None: - color = KIND_COLORS.get(fm.get("kind", ""), DEFAULT_COLOR) - name = fm.get("hostname", "?") - cx = x + RAIL_W // 2 - cy = top + body_h // 2 - p.append( - f'' - ) - p.append( - f'{_esc(name)}' - ) - - for idx, fm in enumerate(left_items): - draw_rail(fm, PAD + idx * RAIL_W) - for idx, fm in enumerate(right_items): - draw_rail(fm, rear_x + COL_W + idx * RAIL_W) - p.append("") return "\n".join(p) + "\n"