damianavila / RISE

RISE: "Live" Reveal.js Jupyter/IPython Slideshow Extension
Other
3.67k stars 416 forks source link

Custom css not found on binder #479

Open sbrunk opened 5 years ago

sbrunk commented 5 years ago

I'm trying to publish RISE enabled runnable slides via binder, and I'm running into an issue with custom css. Seems like it tries to load rise.css from the wrong location (https://hub.gke.mybinder.org/hub/files/examples/rise.css) and gets a 404.

I'm not sure if this is really an issue with RISE or rather caused by binder/jupyterhub because its working perfectly when running a jupyter server locally.

You should be able to reproduce and see the issue by running the binder example in this repo and looking into the browser dev tools.

parmentelat commented 5 years ago

hey

no need to use your repo, the one that we have on binder:
https://rise.readthedocs.io/en/stable/resources.html#github-readthedocs-gitter-youtube
exhibits that issue all right, see examples/README

this being said I cannot be 100% positive that this has worked perfectly in the past, given that the failure can easily go unnoticed - in our case at least (this is because the README on purpose uses a theme very close to the default)


so yes, this clearly has to do with jupyterhub acting less transparently than when running off a local disk; I'm not quite sure how to handle that properly

if such a mechanism was available rise would clearly benefit from using it :)

in the meanwhile, it's be interesting to ask jupyterhub on their thoughts about that behaviour

damianavila commented 5 years ago

Let's ping some JupyterHub/Binder devs here, maybe they have some quick feedback for us.

cc @minrk @choldgraf @betatim

betatim commented 5 years ago

Who/how is the request for https://hub.gke.mybinder.org/hub/files/examples/rise.css generated? It looks like who ever is doing that generates an absolute URL instead of a relative one (and assumes that /hub/ is a good starting value).

If possible you need to generate a URL relative to the notebook or do some (very clever) stuff looking at the URL you are being served from to figure out what the absolute URL should be.

sbrunk commented 5 years ago

Thanks @parmentelat for the explanations.

For anyone running into this until we have a proper fix, here's the workaround I used for publishing my slides on binder:

i.e. in postBuild

JUPYTER_CONFIG_DIR=$(jupyter --config-dir)
mkdir $JUPYTER_CONFIG_DIR/custom
cp rise.css $JUPYTER_CONFIG_DIR/custom/custom.css

Source: https://github.com/sbrunk/scaladays-2019

sbrunk commented 5 years ago

@betatim this seems to be the code generating the link.

https://github.com/damianavila/RISE/blob/e7f0e183f148f89926b004aa2fa36278da8f9a05/rise/static/main.js#L487-L499

betatim commented 5 years ago

I'd say the leading / in line 493 is what is causing the problem. That needs to be a relative path or you need to put a prefix in front of the prefix. I have no idea which of these options is easier/possible though.

damianavila commented 5 years ago

Thanks @betatim for your feedback!

Btw, two PR implemented different solutions: #482 (merged) and #487 (interesting alternative). Some discussions happening on the latest one now.