innovationOUtside / nbev3devsim

Ev3DevSim ipywidget in Jupyter notebooks
Apache License 2.0
5 stars 0 forks source link

Hacking a JupyterLab Fix #139

Open psychemedia opened 2 years ago

psychemedia commented 2 years ago

nbev3devsim will display in a sidecar widget in the following circumstances:

Issues:

psychemedia commented 2 years ago

Background image URL of form:

https://hub-binder.mybinder.ovh/user/aaronwatters-jp_proxy_widget-hu222s29/files/nb_backgrounds/_loop.png

Background image URL 404s with the form:

https://hub-binder.mybinder.ovh/nb_backgrounds/_grey_and_black.png

So we need to find the /user/aaronwatters-jp_proxy_widget-hu222s29/files path somewhere. Or find a way to go relative to that?

In the head there is a cript tag w/ config info?

<script id="jupyter-config-data" type="application/json">
    {"allow_hidden_files": false, "appName": "JupyterLab", "appNamespace": "lab", 
"appSettingsDir": "/srv/conda/envs/notebook/share/jupyter/lab/settings", 
"appUrl": "/lab", "appVersion": "3.4.4", "asset_url": "", 
"baseUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/",
 "buildAvailable": true, "buildCheck": true, "cacheFiles": false, "collaborative": false,
 "devMode": false, "disabledExtensions": [], "exposeAppInBrowser": false, 
"extraLabextensionsPath": [], 
"federated_extensions": [{"extension": "./extension", "load": "static/remoteEntry.fc1c31abb754cd005250.js", "name": "jupyterlab_pygments", "style": "./style"}, {"extension": "./extension", "load": "static/remoteEntry.cb73ba563cb859c17504.js", "name": "jupyter-offlinenotebook", "style": "./style"}, {"extension": "./extension", "load": "static/remoteEntry.0f47a9a97e7ce6a3c959.js", "name": "jupyterlab-stickyland", "style": "./style"}, {"extension": "./extension", "load": "static/remoteEntry.3421943a0ce73f10909d.js", "name": "@jupyter-widgets/jupyterlab-manager"}, {"extension": "./extension", "load": "static/remoteEntry.67bb198e0cc8ce904343.js", "name": "@jupyter-widgets/jupyterlab-sidecar"}, {"extension": "./extension", "load": "static/remoteEntry.b4fdbac59195db951ba7.js", "name": "@jupyter-server/resource-usage"}], 
"fullAppUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/lab",
 "fullLabextensionsUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/lab/extensions", "fullLicensesUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/lab/api/licenses", "fullListingsUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/lab/api/listings", "fullMathjaxUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/static/components/MathJax/MathJax.js", "fullSettingsUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/lab/api/settings", "fullStaticUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/static/lab", "fullThemesUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/lab/api/themes", 
"fullTranslationsApiUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/lab/api/translations", 
"fullTreeUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/lab/tree", "fullWorkspacesApiUrl": "/user/aaronwatters-jp_proxy_widget-hu222s29/lab/api/workspaces",
 "ga_code": "", "ignorePlugins": [], "labextensionsPath": ["/home/jovyan/.local/share/jupyter/labextensions", "/srv/conda/envs/notebook/share/jupyter/labextensions", "/usr/local/share/jupyter/labextensions", "/usr/share/jupyter/labextensions"],
 "labextensionsUrl": "/lab/extensions", "licensesUrl": "/lab/api/licenses", "listingsUrl": "/lab/api/listings", "mathjaxConfig": "TeX-AMS-MML_HTMLorMML-full,Safe", "mode": "multiple-document", "notebookStartsKernel": true, "notebookVersion": "[1, 16, 0, \"\", \"\"]",
 "preferredPath": "/", "quitButton": true, "schemasDir": "/srv/conda/envs/notebook/share/jupyter/lab/schemas",
 "serverRoot": "/home/jovyan", "settingsUrl": "/lab/api/settings", "staticDir": "/srv/conda/envs/notebook/share/jupyter/lab/static",
 "store_id": 5, "templatesDir": "/srv/conda/envs/notebook/share/jupyter/lab/static", "terminalsAvailable": true, 
"themesDir": "/srv/conda/envs/notebook/share/jupyter/lab/themes", "themesUrl": "/lab/api/themes", "token": "Ry4eYfOUSSq6lwyciYb53g",
 "translationsApiUrl": "/lab/api/translations", "treePath": "nb_backgrounds/_loop.png", "treeUrl": "/lab/tree",
 "userSettingsDir": "/home/jovyan/.jupyter/lab/user-settings", "workspace": "default", "workspacesApiUrl": "/lab/api/workspaces",
 "workspacesDir": "/home/jovyan/.jupyter/lab/workspaces", "wsUrl": ""}
  </script>

If we can access the baseURL somehow, then we should be able to resolve the image paths.

psychemedia commented 2 years ago

Need to fix the path to the background images here:

https://github.com/innovationOUtside/nbev3devsim/blob/bb9d62dc953e744191344683456d9e9156f226a6/nbev3devsim/templates/studio.js#L882