Skip to content

Commit

Permalink
fixes issue #855, thanks kszys
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Jun 2, 2024
1 parent f5d494f commit 05bf531
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/showcase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,21 @@ def show(name):
path = name
name = name.rstrip("/0123456789")
data = []
filename = f"apps/showcase/{name}.md"
here = os.path.dirname(__file__)
filename = f"{here}/{name}.md"
if os.path.exists(filename):
with open(filename) as stream:
metadata = stream.read().strip()
data.append({"name": f"{name}.md", "content": metadata, "language": "markdown"})
filename = f"apps/showcase/{name}.py"
filename = f"{here}/{name}.py"
if not os.path.exists(filename):
raise HTTP(404)
with open(filename) as stream:
controller = stream.read().strip()
data.append({"name": f"{name}.py", "content": controller, "language": "python"})
templates = re.compile(r"[/\w]+\.html").findall(controller)
for template in templates:
with open(f"apps/showcase/templates/{template}") as stream:
with open(f"{here}/templates/{template}") as stream:
content = stream.read().strip()
data.append(
{
Expand All @@ -89,7 +90,7 @@ def show(name):
if not other.startswith("."):
continue
filename = other[1:].replace(".", "/") + ".py"
with open(f"apps/showcase/{filename}") as stream:
with open(f"{here}/{filename}") as stream:
content = stream.read().strip()
data.append({"shortname": filename, "content": content, "language": "python"})
# drop the subfolder name
Expand Down

0 comments on commit 05bf531

Please sign in to comment.