JuliaLang / IJulia.jl

Julia kernel for Jupyter
MIT License
2.8k stars 413 forks source link

Serving Static Files in IJulia #339

Closed rohitvarkey closed 5 years ago

rohitvarkey commented 9 years ago

Hi,

I've been working on Compose3D and I've kind of run into a roadblock that I'd like your advice on.

The ThreeJS-WebGL backend that I'm using for Compose3D emits custom web component tags that are then use to draw the 3D images. For this to work, I need to do a HTML import and as a result I need to be serving the static files somewhere.

I wrote a build script that would just copy the files to profile_julia/static/components/compose3d/ and this works pretty okay when the user was doing ipython notebook --profile=julia.

But now that just ipython notebook works, should I copy the files to the default profile? This doesn't work on places like JuliaBox, where a different profile is used by default. Should I have to copy the files to every profile or is there a better way of handling this?

Thanks, Rohit.

stevengj commented 9 years ago

Why can't you just emit the HTML directly into the notebook, e.g. with display("text/html", ".....")?

shashi commented 9 years ago

@stevengj the problem is importing the same web component declaration twice is a fatal error. So if you restart the kernel and run using Compose3D again (which loads the dependency through display(...)), your notebook won't work.

This is also one of the reasons stopping Escher from being used inside IJulia.

stevengj commented 9 years ago

@shashi, maybe IJulia should export a display_once function or similar to import web components? Oh, no, that won't work if you restart the kernel.

It seems like this is something that you should report upstream to Jupyter.

shashi commented 9 years ago

Opened an issue on the jupyter notebook repo https://github.com/jupyter/notebook/issues/319

shashi commented 9 years ago

Oh, also, there is another problem I forgot about which Rohit mentions above:

If you are using HTML imports, a file x.html can import y.html so reading in x.html using display will not be sufficient (it will lead to a 404 when it tries to load y.html). One could use a tool to concatenate all of them together though but that is not so ideal when you want to import things as you need them interactively. It would be nice to have them served from disk and loaded as and when required by displaying some Javascript for it.

I think a proper solution to this would involve some way for notebook code to register a directory to be served in a static URL location - again this seems like a feature that Jupyter will need to make possible.

stevengj commented 5 years ago

Closing as a Jupyter/notebook issue, not IJulia.