voila-dashboards / voici

Voici turns any Jupyter Notebook into a static web application
https://voici.readthedocs.io/
Other
145 stars 8 forks source link

Fix handling of the base url to enable the Service Worker #59

Closed jtpio closed 1 year ago

jtpio commented 1 year ago

References

Fixes https://github.com/voila-dashboards/voici/issues/3 Fixes https://github.com/voila-dashboards/voici/issues/40

Code changes

See https://github.com/voila-dashboards/voici/issues/3 for more details and investigation.

TLDR: Voila seems to be updating the page config baseUrl with the one from the resources in the template: https://github.com/voila-dashboards/voila/blob/0f4cc5360ff387eeaf7e647cee712b2ce08d573a/share/jupyter/voila/templates/lab/index.html.j2#L81

{# Set a dummy variable - we just want the side effect of the update. #}
{% set _ = page_config_full.update(baseUrl=resources.base_url, kernelId=kernel_id) %}

User-facing changes

Reading from a file should work in a notebook like in JupyterLite.

https://user-images.githubusercontent.com/591645/231544815-7ebc7f04-9046-4c01-a2eb-f76615b3a77f.mp4

Backwards-incompatible changes

None

jtpio commented 1 year ago

Add a UI test to cover this? The test could read a csv file with pd.read_csv()

The existing voici.ipynb example notebook has been updated to read the CSV file directly instead of generating a DataFrame. But happy to create a separate notebook if needed:

image