diff --git a/capella_model_explorer/backend/__main__.py b/capella_model_explorer/backend/__main__.py index 8c8ca42..b6a5ccf 100644 --- a/capella_model_explorer/backend/__main__.py +++ b/capella_model_explorer/backend/__main__.py @@ -13,7 +13,7 @@ HOST = os.getenv("CAPELLA_MODEL_EXPLORER_HOST_IP", "0.0.0.0") PORT = os.getenv("CAPELLA_MODEL_EXPLORER_PORT", "8000") -PATH_TO_TEMPLATES = Path(__file__).parent.parent.parent / "templates" +PATH_TO_TEMPLATES = Path("./templates") @click.command() diff --git a/capella_model_explorer/backend/explorer.py b/capella_model_explorer/backend/explorer.py index 67706f2..537abc7 100644 --- a/capella_model_explorer/backend/explorer.py +++ b/capella_model_explorer/backend/explorer.py @@ -103,7 +103,7 @@ def __make_href( if obj.__class__.__name__ == clsname: return f"/{idx}/{obj.uuid}" - return f"/__generic__/{obj.uuid}" + return f"{ROUTE_PREFIX}/__generic__/{obj.uuid}" def render_instance_page(self, template_text, object=None): try: @@ -167,15 +167,16 @@ def read_template(template_name: str): base["single"] = base.get("single", False) filters = base.get("filters") variable = base["variable"] - below = variable.get("below") or None - attr = variable.get("attr") or None + below = variable.get("below") + attr = variable.get("attr") + obj_type = variable.get("type") if base["single"]: base["objects"] = [] return base try: objects = find_objects( self.model, - variable["type"], + obj_type, below=below, attr=attr, filters=filters, @@ -254,6 +255,7 @@ async def catch_all(request: Request, rest_of_path: str): "index.html", {"request": request} ) + def index_template(template, templates, templates_grouped, filename=None): idx = filename if filename else template["idx"] record = {"idx": idx, **template} @@ -279,7 +281,9 @@ def index_templates( index_template(template_def, templates, templates_grouped) else: idx = urlparse.quote(template_file.name.replace(".yaml", "")) - index_template(template, templates, templates_grouped, filename=idx) + index_template( + template, templates, templates_grouped, filename=idx + ) return templates_grouped, templates diff --git a/templates/cross-cutting/index.yaml b/templates/cross-cutting/index.yaml index 7d4e476..c83360b 100644 --- a/templates/cross-cutting/index.yaml +++ b/templates/cross-cutting/index.yaml @@ -2,30 +2,30 @@ # SPDX-License-Identifier: Apache-2.0 templates: -- template: xc/classes.html.j2 - idx: class - name: Data Class - description: Specifies structure of a data class. A class may be used to describe anything from a simple object relationship to a message on a bus. - category: xc - variable: - name: object - type: Class + - template: cross-cutting/classes.html.j2 + idx: class + name: Data Class + description: Specifies structure of a data class. A class may be used to describe anything from a simple object relationship to a message on a bus. + category: xc + variable: + name: object + type: Class -- template: xc/diagrams.html.j2 - name: Diagrams - idx: diagram - description: Provides access to all human-made diagrams inside the model - category: xc - variable: - name: object - type: AbstractDiagram - attr: diagrams + - template: cross-cutting/diagrams.html.j2 + name: Diagrams + idx: diagram + description: Provides access to all human-made diagrams inside the model + category: xc + variable: + name: object + type: AbstractDiagram + attr: diagrams -- template: xc/exchange-item.html.j2 - name: Exchange Item - idx: exchange-item - description: Specifies an exchange item, i.e. energy / material / information. - category: xc - variable: - name: object - type: ExchangeItem + - template: cross-cutting/exchange-item.html.j2 + name: Exchange Item + idx: exchange-item + description: Specifies an exchange item, i.e. energy / material / information. + category: xc + variable: + name: object + type: ExchangeItem