Skip to content

Correct root path for examples #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/psc/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ async def example(request: Request) -> _TemplateResponse:
example_path = PurePath(request.path_params["example_name"])
resources: Resources = request.app.state.resources
this_example = resources.examples[example_path]
root_path = "../../.."

return templates.TemplateResponse(
"example.jinja2",
Expand All @@ -75,6 +76,7 @@ async def example(request: Request) -> _TemplateResponse:
extra_head=this_example.extra_head,
body=this_example.body,
request=request,
root_path=root_path,
),
)

Expand Down Expand Up @@ -109,8 +111,8 @@ async def content_page(request: Request) -> _TemplateResponse:
Mount("/static", StaticFiles(directory=HERE / "static")),
]
if PYODIDE.exists():
Mount("/pyscript", StaticFiles(directory=PYSCRIPT)),
Mount("/pyodide", StaticFiles(directory=PYODIDE)),
routes.append(Mount("/pyscript", StaticFiles(directory=PYSCRIPT)))
routes.append(Mount("/pyodide", StaticFiles(directory=PYODIDE)))


@contextlib.asynccontextmanager # type: ignore
Expand Down
Binary file added src/psc/gallery/examples/altair/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/psc/templates/homepage.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="card">
<div class="card-image">
<figure class="image is-square">
<img alt="placeholder" src="{{ root_path }}/gallery/examples/hello_world/screenshot.png">
<img alt="placeholder" src="{{ root_path }}/gallery/examples/altair/screenshot.png">
</figure>
</div>
<div class="card-content">
Expand Down