Skip to content

Commit

Permalink
fix: Add sub-path to links
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Apr 26, 2024
1 parent 6ced5a6 commit c2e9d6e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion capella_model_explorer/backend/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 9 additions & 5 deletions capella_model_explorer/backend/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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}
Expand All @@ -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


Expand Down
50 changes: 25 additions & 25 deletions templates/cross-cutting/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c2e9d6e

Please sign in to comment.