Open jtpio opened 4 years ago
It's probably related to the way nbviewer
handles files.
This does seem a bit weird (at the very least). When we added the nbviewer preview it was to give us an easy, low maintenance way to have a preview.
I don't think we can change the way nbviewer.jupyter.org is configured and we decided against including a nbviewer instance in BinderHub to generate previews. Maybe there is a way we can prevent the download popup via URL parameters when generating the iframe link?
Longer term I've been wondering what a "second generation" launch page would look like. For example is the a lightweight JS library that can render ipynb, md, Rmd and "source code" in a pretty way? Maybe we could use that to show a more prominent preview (and one day implement something like edit before launch). Maybe something for a new issue?
It seems that the download comes from nbviewer directly when it is passed the URL to the Python file, by pasting the following link into the search box: https://github.com/jupyterlab/jupyterlab-demo/blob/master/notebooks/lorenz.py
This would explain why we get it on BinderHub too.
Maybe there is a way we can prevent the download popup via URL parameters when generating the iframe link?
Maybe by only showing the IFrame if the file is a notebook file ending with .ipynb
?
Longer term I've been wondering what a "second generation" launch page would look like. For example is the a lightweight JS library that can render ipynb, md, Rmd and "source code" in a pretty way? Maybe we could use that to show a more prominent preview (and one day implement something like edit before launch). Maybe something for a new issue?
And then yes this sounds good (and indeed it can be tracked in a separate issue).
I'd be Ok with either not showing the nbviewer iframe if the "thing" it would show is a file that would trigger a download or reading the nbviewer docs/asking Min if there is a way to prevent the download and get a preview instead.
Proposed change
It would be nice if we could show a preview for other files too, for example Python files.
For now opening the jupyterlab-demo Binder automatically downloads the file:
https://mybinder.org/v2/gh/jupyterlab/jupyterlab-demo/master?urlpath=lab/tree/notebooks/lorenz.py
Alternative options
An alternative is to not have the file in the url, or to create a notebook with a link to the file to open.
Who would use this feature?
To show a preview for other files (just like for notebooks). The preview for a Python file would be its content (or part of its content).
(Optional): Suggest a solution
Or only show the preview for notebook files to prevent the file download popup.