From 73cca04b0a20e763f423fbd71655b267c1efc425 Mon Sep 17 00:00:00 2001 From: flosch62 Date: Fri, 20 Dec 2024 19:47:45 +0100 Subject: [PATCH] allow css override of svg --- core/config/theme_manager.py | 300 +++++++++++++++++++++++++++++------ styles/example.yaml | 72 +++++++++ 2 files changed, 323 insertions(+), 49 deletions(-) create mode 100644 styles/example.yaml diff --git a/core/config/theme_manager.py b/core/config/theme_manager.py index e57394e..cac9ef3 100644 --- a/core/config/theme_manager.py +++ b/core/config/theme_manager.py @@ -1,77 +1,279 @@ import yaml -import sys +import base64 +import re import logging +from typing import Dict, Any logger = logging.getLogger(__name__) class ThemeManagerError(Exception): - """Raised when loading the theme fails.""" + """Raised when loading the theme fails due to invalid style strings or configuration.""" + pass class ThemeManager: """ - Loads and merges theme configuration from a YAML file. + ThemeManager is responsible for: + - Loading a theme configuration from a YAML file. + - Validating style strings for nodes and links. + - Optionally modifying embedded SVG images by injecting custom CSS overrides. + + CSS overrides can be specified in the theme YAML and allow changing properties + of classes defined in the embedded SVG ", style_start) + if style_close != -1: + start_tag_end = svg_data.find('>', style_start) + if start_tag_end != -1 and start_tag_end < style_close: + style_end = style_close + len("") + style_content = svg_data[start_tag_end+1:style_close] + + # Split by ' ' to preserve formatting of original style lines + style_lines = style_content.split(" ") if style_content else [] + + # Parse existing classes from the style block + class_rules = {} + class_line_map = {} + for i, line in enumerate(style_lines): + m = re.match(r'(\s*)(\.[A-Za-z0-9_-]+)\{([^}]*)\}', line.strip()) + if m: + indentation = m.group(1) or "" + full_cls = m.group(2) + cls_name = full_cls.lstrip('.') + props_str = m.group(3) + props = self._parse_properties(props_str) + class_rules[cls_name] = props + class_line_map[cls_name] = (i, indentation) + + # Apply overrides + changed_classes = set() + for key, val in style_overrides.items(): + parts = key.split('_', 1) + if len(parts) != 2: + logger.debug(f"Skipping invalid override key '{key}'. Expected '_'.") + continue + class_name, prop_name = parts + if class_name not in class_rules: + # If class doesn't exist, create it + class_rules[class_name] = {} + class_line_map[class_name] = (None, " ") + class_rules[class_name][prop_name] = val + changed_classes.add(class_name) + + # Rebuild changed or newly added class lines + for cls_n in changed_classes: + i, indent = class_line_map[cls_n] + new_line = self._build_class_line(indent, cls_n, class_rules[cls_n]) + if i is not None: + # Modify existing line + style_lines[i] = new_line + else: + # Append a new class line + style_lines.append(new_line) + + new_style_content = " ".join(style_lines) + if new_style_content and not new_style_content.endswith(" "): + new_style_content += " " + + # If there was no style block, create one before + if style_start == -1: + insert_pos = svg_data.rfind("") + if insert_pos == -1: + # No closing svg? Just append the style at the end. + return svg_data + "" + else: + return svg_data[:insert_pos] + "" + svg_data[insert_pos:] + else: + # Replace existing style content + return self._replace_style_block(svg_data, style_start, style_end, new_style_content) + + def _replace_style_block(self, svg_data: str, style_start: int, style_end: int, new_content: str) -> str: + """ + Replace the content of the existing tag. + :param new_content: The new CSS content to insert. + :return: The updated SVG string with replaced style content. + """ + start_tag_end = svg_data.find('>', style_start) + if start_tag_end == -1 or style_end == -1: + logger.debug("Could not properly find the style block boundaries; returning unchanged SVG.") + return svg_data + + style_open_tag = svg_data[style_start:start_tag_end+1] + return svg_data[:style_start] + style_open_tag + new_content + "" + svg_data[style_end:] + + def _parse_properties(self, props_str: str) -> Dict[str, str]: + """ + Parse CSS properties from a string like "fill:#001135;stroke:#FFF". + + :param props_str: The CSS properties string inside a single class definition. + :return: A dict of {property_name: property_value}. + """ + props = {} + segments = props_str.split(';') + for seg in segments: + seg = seg.strip() + if '=' in seg: # skip invalid or unexpected segments + continue + if seg: + kv = seg.split(':',1) + if len(kv) == 2: + prop = kv[0].strip() + val = kv[1].strip() + props[prop] = val + return props + + def _build_class_line(self, indent: str, cls_name: str, props: Dict[str,str]) -> str: + """ + Rebuild a single CSS class line for the style block. + + :param indent: The indentation originally used for this line. + :param cls_name: The class name (e.g. "st0"). + :param props: A dict of CSS properties to apply to this class. + :return: A string like " .st0{fill:#FF0000;stroke:#FFFFFF;}" + """ + prop_segs = [f"{p}:{v}" for p, v in props.items()] + prop_str = ";".join(prop_segs) + ";" if prop_segs else "" + return f"{indent}.{cls_name}{{{prop_str}}}" + + def _validate_style_string(self, style_str: str): + """ + Validate that the style string follows "key=value" pairs separated by semicolons. + Known exception: 'points=[]' patterns are allowed. + + :param style_str: The style string to validate. + :raises ThemeManagerError: If invalid segments are found. + """ + if style_str.strip() == "": + return + segments = style_str.split(';') + segments = [seg for seg in segments if seg.strip() != ""] + + for seg in segments: + if '=' not in seg: + if 'points=[' in seg: + continue + raise ThemeManagerError(f"Invalid style segment '{seg}' in style string.") + parts = seg.split('=', 1) + if len(parts) != 2: + raise ThemeManagerError(f"Invalid style segment '{seg}' in style string.") diff --git a/styles/example.yaml b/styles/example.yaml new file mode 100644 index 0000000..7244b67 --- /dev/null +++ b/styles/example.yaml @@ -0,0 +1,72 @@ +#General Diagram settings: +background: "#4D5766" +shadow: "0" +grid: "0" +pagew: "auto" +pageh: "auto" + +node_width: 75 +node_height: 75 + +padding_x: 150 +padding_y: 175 + +# Base style for nodes; defines the general appearance for all nodes. +base_style: "shape=image;imageAlign=center;imageVerticalAlign=middle;labelPosition=left;align=right;verticalLabelPosition=top;spacingLeft=0;verticalAlign=bottom;spacingTop=0;spacing=0;fontColor=#F0F0F0;" + +#Nodes with ports if ports:true (-g option for grafana will set always to true) +ports: true +port_style: "ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontColor=#FFFFFF;fontSize=6;strokeColor=#98A2AE;fillColor=#BEC8D2;" +connector_style: "ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontColor=#FFFFFF;fontSize=6;fillColor=#BEC8D2;strokeColor=none;noLabel=1;" + +port_width: 12 +port_height: 12 + +connector_width: 4 +connector_height: 4 + +# Style for links between nodes +link_style: "rounded=0;orthogonalLoop=1;html=1;startSize=6;endArrow=classicThin;endFill=1;endSize=2;fontSize=14;strokeColor=#98A2AE;fontColor=#FFFFFF;textOpacity=60;labelBackgroundColor=#4D5766;jumpStyle=gap;strokeWidth=3;" + +# Styles for labels on the source and target ends of a link +src_label_style: "edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fontSize=6;fontColor=#FFFFFF;textOpacity=60;labelBackgroundColor=#4D5766;" +trgt_label_style: "edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fontSize=6;fontColor=#FFFFFF;textOpacity=60;labelBackgroundColor=#4D5766;" + +default_labels: true +label_offset: 20 +label_height: 10 +label_width: 20 +label_alignment: center + +# Custom styles for different types of nodes, allowing for unique visual representation based on node role or function +custom_styles: + default: "shape=image;editableCssRules=\\.st[0-2]$;verticalLabelPosition=top;labelBackgroundColor=none;verticalAlign=bottom;aspect=fixed;imageAspect=0;image=data:image/svg+xml,PHN2ZyB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWw6c3BhY2U9InByZXNlcnZlIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAxMjAgMTIwO2VkaXRhYmxlQ3NzUnVsZXM9Lio7IiB2aWV3Qm94PSIwIDAgMTIwIDEyMCIgeT0iMHB4IiB4PSIwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiPiYjeGE7PHN0eWxlIHR5cGU9InRleHQvY3NzIj4mI3hhOwkuc3Qwe2ZpbGw6IzAwMTEzNTt9JiN4YTsJLnN0MXtmaWxsOm5vbmU7c3Ryb2tlOiNGRkZGRkY7c3Ryb2tlLXdpZHRoOjQ7c3Ryb2tlLWxpbmVjYXA6cm91bmQ7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjEwO30mI3hhOwkuc3Qye2ZpbGw6I0ZGRkZGRjt9JiN4YTsJLnN0M3tmaWxsOm5vbmU7c3Ryb2tlOiNGRkZGRkY7c3Ryb2tlLXdpZHRoOjQ7c3Ryb2tlLW1pdGVybGltaXQ6MTA7fSYjeGE7CS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NzPSJzdDEiLz4mI3hhOwkJPHBhdGggZD0iTTM4LjgsMjguM2w3LjYtNy41YzEuMy0xLjMsMy4xLTEuMyw0LjMsMGw3LjcsNy42IiBjbGFzcz0ic3QxIi8+JiN4YTsJPC9nPiYjeGE7CTxnPiYjeGE7CQk8cGF0aCBkPSJNNDgsMTAwLjNWNzJIMjAiIGNsYXNzPSJzdDEiLz4mI3hhOwkJPHBhdGggZD0iTTI4LjUsODEuNUwyMSw3My45Yy0xLjMtMS4zLTEuMy0zLjEsMC00LjNsNy42LTcuNyIgY2xhc3M9InN0MSIvPiYjeGE7CTwvZz4mI3hhOwk8Zz4mI3hhOwkJPHBhdGggZD0iTTEwMCw3MS45SDcxLjZ2MjgiIGNsYXNzPSJzdDEiLz4mI3hhOwkJPHBhdGggZD0iTTgxLjIsOTEuNGwtNy42LDcuNWMtMS4zLDEuMy0zLjEsMS4zLTQuMywwbC03LjctNy42IiBjbGFzcz0ic3QxIi8+JiN4YTsJPC9nPiYjeGE7PC9nPiYjeGE7PC9zdmc+;" + spine: "shape=image;editableCssRules=\\.st[0-2]$;verticalLabelPosition=top;labelBackgroundColor=none;verticalAlign=bottom;aspect=fixed;imageAspect=0;image=data:image/svg+xml,PHN2ZyB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWw6c3BhY2U9InByZXNlcnZlIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAxMjAgMTIwO2VkaXRhYmxlQ3NzUnVsZXM9Lio7IiB2aWV3Qm94PSIwIDAgMTIwIDEyMCIgeT0iMHB4IiB4PSIwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiPiYjeGE7PHN0eWxlIHR5cGU9InRleHQvY3NzIj4mI3hhOwkuc3Qwe2ZpbGw6IzAwMTEzNTt9JiN4YTsJLnN0MXtmaWxsOm5vbmU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SJzdDAiLz4mI3hhOzxnPiYjeGE7CTxnPiYjeGE7CQk8cGF0aCBkPSJNNzEuNywxOS43VjQ4aDI4IiBjbGFzcz0ic3QxIi8+JiN4YTsJCTxwYXRoIGQ9Ik05MS4yLDM4LjVsNy41LDcuNmMxLjMsMS4zLDEuMywzLjEsMCw0LjNMOTEuMSw1OCIgY2xhc3M9InN0MSIvPiYjeGE7CTwvZz4mI3hhOwk8Zz4mI3hhOwkJPHBhdGggZD0iTTIwLDQ3LjhoMjguNHYtMjgiIGNsYXNzPSJzdDEiLz4mI3hhOwkJPHBhdGggZD0iTTM4LjgsMjguM2w3LjYtNy41YzEuMy0xLjMsMy4xLTEuMyw0LjMsMGw3LjcsNy42IiBjbGFzcz0ic3QxIi8+JiN4YTsJPC9nPiYjeGE7CTxnPiYjeGE7CQk8cGF0aCBkPSJNNDgsMTAwLjNWNzJIMjAiIGNsYXNzPSJzdDEiLz4mI3hhOwkJPHBhdGggZD0iTTI4LjUsODEuNUwyMSw3My45Yy0xLjMtMS4zLTEuMy0zLjEsMC00LjNsNy42LTcuNyIgY2xhc3M9InN0MSIvPiYjeGE7CTwvZz4mI3hhOwk8Zz4mI3hhOwkJPHBhdGggZD0iTTEwMCw3MS45SDcxLjZ2MjgiIGNsYXNzPSJzdDEiLz4mI3hhOwkJPHBhdGggZD0iTTgxLjIsOTEuNGwtNy42LDcuNWMtMS4zLDEuMy0zLjEsMS4zLTQuMywwbC03LjctNy42IiBjbGFzcz0ic3QxIi8+JiN4YTsJPC9nPiYjeGE7PC9nPiYjeGE7PC9zdmc+;" + leaf: "shape=image;editableCssRules=\\.st[0-2]$;verticalLabelPosition=top;labelBackgroundColor=none;verticalAlign=bottom;aspect=fixed;imageAspect=0;image=data:image/svg+xml,PHN2ZyB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWw6c3BhY2U9InByZXNl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iBjbGFzcz0ic3QxIi8+JiN4YTsJPC9nPiYjeGE7PC9nPiYjeGE7PC9zdmc+;" + dcgw: "shape=image;editableCssRules=\\.st[0-2]$;verticalLabelPosition=top;labelBackgroundColor=none;verticalAlign=bottom;aspect=fixed;imageAspect=0;image=data:image/svg+xml,PHN2ZyB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWw6c3BhY2U9InByZXNlcnZlIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAxMjAgMTIwOyIgdmlld0JveD0iMCAwIDEyMCAxMjAiIHk9IjBweCIgeD0iMHB4IiBpZD0iTGF5ZXJfMSIgdmVyc2lvbj0iMS4xIj4mI3hhOzxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+JiN4YTsJLnN0MHtmaWxsOiMwMDExMzU7fSYjeGE7CS5zdDF7ZmlsbDpub25lO3N0cm9rZTojRkZGRkZGO3N0cm9rZS13aWR0aDo0O3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9JiN4YTsJLnN0MntmaWxsOiNGRkZGRkY7fSYjeGE7CS5zdDN7ZmlsbDpub25lO3N0cm9rZTojRkZGRkZGO3N0cm9rZS13aWR0aDo0O3N0cm9rZS1taXRlcmxpbWl0OjEwO30mI3hhOwkuc3Q0e2ZpbGw6bm9uZTtzdHJva2U6I0ZGRkZGRjtzdHJva2Utd2lkdGg6NDtzdHJva2UtbGluZWNhcDpyb3VuZDtzdHJva2UtbGluZWpvaW46cm91bmQ7fSYjeGE7CS5zdDV7ZmlsbDojRkZGRkZGO3N0cm9rZTojRkZGRkZGO3N0cm9rZS13aWR0aDo0O3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2Ut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2xhc3M9InN0MSIvPiYjeGE7CTxwYXRoIGQ9Ik05OS44LDg2LjJsMCwxMC43YzAsMS44LTEuMywzLTMuMSwzLjFsLTEwLjgsMCIgY2xhc3M9InN0MSIvPiYjeGE7CTxwYXRoIGQ9Ik04MS44LDUxLjlsLTEwLjcsMGMtMS44LDAtMy0xLjMtMy4xLTMuMUw2OCwzOCIgY2xhc3M9InN0MSIvPiYjeGE7PC9nPiYjeGE7PC9zdmc+;" + server: "shape=image;editableCssRules=\\.st[0-2]$;verticalLabelPosition=top;labelBackgroundColor=none;verticalAlign=bottom;aspect=fixed;imageAspect=0;image=data:image/svg+xml,PHN2ZyB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWw6c3BhY2U9InByZXNlcnZlIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAxMjAgMTIwOyIgdmlld0JveD0iMCAwIDEyMCAxMjAiIHk9IjBweCIgeD0iMHB4IiBpZD0iTGF5ZXJfMSIgdmVyc2lvbj0iMS4xIj4mI3hhOzxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+JiN4YTsJLnN0MHtmaWxsOiMwMDExMzU7fSYjeGE7CS5zdDF7ZmlsbDpub25lO3N0cm9rZTojRkZGRkZGO3N0cm9rZS13aWR0aDo0O3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9JiN4YTsJLnN0MntmaWxsOiNGRkZGRkY7fSYjeGE7CS5zdDN7ZmlsbDpub25lO3N0cm9rZTojRkZGRkZGO3N0cm9rZS13aWR0aDo0O3N0cm9rZS1taXRlcmxpbWl0OjEwO30mI3hhOwkuc3Q0e2ZpbGw6bm9uZTtzdHJva2U6I0ZGRkZGRjtzdHJva2Utd2lkdGg6NDtzdHJva2UtbGluZ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eiIgY2xhc3M9InN0NCIvPiYjeGE7PC9nPiYjeGE7PC9zdmc+;" + +css_overrides: + default: + st0_fill: "#008000" + spine: + st0_fill: "#008000" + leaf: + st0_fill: "#008000" + dcgw: + st0_fill: "#008000" + server: + st0_fill: "#008000" + +# icon_to_group_mapping defines the mapping between 'graph-icon' labels specified in the Containerlab file and the custom_styles keys. +# 'graph-icon' is used within the Containerlab YAML configuration under 'labels' to visually differentiate nodes by type in the generated diagram. +# For example, a node with 'graph-icon: switch' in its Containerlab file will use the style defined under 'switch' in custom_styles. +icon_to_group_mapping: + router: "dcgw" # Maps 'router' graph-icon to the 'dcgw' style. + switch: "leaf" # Maps 'switch' graph-icon to the 'leaf' style, can be changed to "spine" if needed. + host: "server" # Maps 'host' graph-icon to the 'server' style. + +# To get custom style data from Draw.io: +# 1. Right-click on an element in the Draw.io canvas. +# 2. Select "Edit Style" from the context menu. +# 3. Copy the style string that appears and use it in your custom_styles definition or directly modify it in Draw.io. \ No newline at end of file