From cd7195b3aaada653c7f96f2e9e713ce3147098cf Mon Sep 17 00:00:00 2001 From: "Adrian A. Baumann" Date: Thu, 23 Oct 2025 22:05:13 +0000 Subject: [PATCH] Update diagram rendering to use POST with caching - Replace URL-encoded GET approach with POST requests - Use local filesystem cache for generated diagrams - Add error handling with fallback message - Serve diagrams from MEDIA_URL instead of proxy --- abschnitte/utils.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/abschnitte/utils.py b/abschnitte/utils.py index 6194727..6d13cf4 100644 --- a/abschnitte/utils.py +++ b/abschnitte/utils.py @@ -3,6 +3,10 @@ import base64 import zlib import re from textwrap import dedent +from django.conf import settings + +# Import the caching function +from diagramm_proxy.diagram_cache import get_cached_diagram DIAGRAMMSERVER="/diagramm" @@ -25,15 +29,23 @@ def render_textabschnitte(queryset): elif typ == "tabelle": html = md_table_to_html(inhalt) elif typ == "diagramm": - temp=inhalt.splitlines() - diagramtype=temp.pop(0) - diagramoptions='width="100%"' - if temp[0][0:6].lower() == "option": - diagramoptions=temp.pop(0).split(":",1)[1] - rest="\n".join(temp) - html = '

' + except Exception as e: + # Fallback to error message + html = f'

Error generating diagram: {str(e)}

' + elif typ == "code": html = "
"
             html += markdown(inhalt, extensions=['tables', 'attr_list'])