feat: optional device images in rack elevations, HTML preview in new tab

- New export option "Gerätebilder anzeigen": the SVG is rendered with
  include_images and the /media/ image links are replaced by embedded
  data URIs, since Word, WeasyPrint and SVG-as-image cannot load
  login-protected files. The Pillow PNG renderer draws the front/rear
  images too, with the device name on a dark label.
- Custom rack_svg_renderer adapters receive images=..., older adapters
  without that parameter keep working.
- The HTML preview now opens in a new browser tab.

Bump version to 0.3.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-23 13:56:39 +02:00
co-authored by Claude Opus 5.5
parent f24e42a516
commit 5b2d68356c
8 changed files with 97 additions and 17 deletions
+3 -2
View File
@@ -178,14 +178,15 @@ def racks(scope, opts):
rack_devs = list(
scope.restrict(rack.devices.all()).select_related("device_type", "role")
)
with_images = bool(opts.get("rack_images"))
for face in opts.get("rack_faces") or ["front"]:
caption = "Vorderseite" if face == "front" else "Rückseite"
svg, svg_error = render_rack_svg(rack, face, scope.user)
svg, svg_error = render_rack_svg(rack, face, scope.user, images=with_images, devices=rack_devs)
png = None
# PNG wird für Word gebraucht (falls kein cairosvg) und ersetzt ein fehlgeschlagenes SVG
if opts.get("format") == "docx" or not svg:
try:
png = render_rack_png(rack, face, rack_devs)
png = render_rack_png(rack, face, rack_devs, images=with_images)
except Exception as e: # noqa: BLE001
svg_error = f"{svg_error or ''} / PNG: {type(e).__name__}: {e}".strip(" /")
if svg or png: