yuvipanda / notebooksharing.space

BSD 3-Clause "New" or "Revised" License
84 stars 10 forks source link

Integration with JupyterLite #40

Open jtpio opened 2 years ago

jtpio commented 2 years ago

cc @yuvipanda as a follow-up to the conversation started on another channel

It would be nice to have a button to open a notebook in JupyterLite, for example:

image

Listing a couple of ideas here on how this could work. Probably the main challenge would be fetch the content from the nbss storage. The simplest for now might be:

jtpio commented 2 years ago

Looks like the client code does not have access to that header:

image

@yuvipanda probably the nbss server should expose the Access-Control-Expose-Headers header?

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers

yuvipanda commented 2 years ago

@jtpio this has been deployed, can you try again?

jtpio commented 2 years ago

Just tried with the following snippet locally:

<!DOCTYPE html>
<html>
  <body>
    <script>
      (async function () {
        const response = await fetch('https://notebooksharing.space/api/v1/notebook/5533e15101253d29023833f671a3e5c8ecf6a56946ab7e34b19e940eff2cf94d');
        const contentType = response.headers.get('content-type');
        const contentDisposition = response.headers.get('content-disposition');
        console.log({contentType, contentDisposition});
      }())
    </script>
  </body>
</html>

image

Looks like the header is not part of the response headers?

image

ericvd-ucb commented 10 months ago

Hey there - I am fascinated with the possibilities of this integration - and would love to know how hard it would be to make this happen. You guys are amazing!

yuvipanda commented 7 months ago

Apparently today was the day. Who chooses what day what work gets done on? Not me, apparently.

Anyway, there's now an 'open in jupyterlite' button on all notebooks! https://notebooksharing.space/view/39c6004af2056337fe6304f719c3c7c4883551cf89843eafdfe4a52d7d74f9e8#displayOptions= for example, has this:

image

Clicking that will take you to https://notebooksharing.space/jupyterlite/lab/?fromURL=/api/v1/notebook/39c6004af2056337fe6304f719c3c7c4883551cf89843eafdfe4a52d7d74f9e8/hls_applications_example(1).ipynb, which works as you would expect (yay).

It's stuck in JupyterLab 3.x, until https://github.com/jupyterlab-contrib/jupyterlab-open-url-parameter/pull/11 can be merged.

There are no pre-installed python packages though, and I'll probably keep it that way.

Thanks to @jtpio for https://github.com/jupyterlab-contrib/jupyterlab-open-url-parameter, which was an important part of this :)

yuvipanda commented 7 months ago

Once we move to jupyterlab 4.0, I'll have notebook 7 and lab as options, and default to notebook 7.

yuvipanda commented 7 months ago

I'm just adding ipywidgets so they would work. But I don't wanna add too much though.