Add template_file config and document page customization
Closes https://github.com/jupyterhub/binderhub/issues/1907
We might want to make add a new traitlets for users to provide their own Jinja template that will be used in https://github.com/jupyterhub/binderhub/blob/4f0a91ac7a851238d0857e68691edf2ab70c4b3d/binderhub/main.py#L42 from https://github.com/jupyterhub/binderhub/blob/4f0a91ac7a851238d0857e68691edf2ab70c4b3d/binderhub/main.py#L41-L46
I will address the comments in a couple of weeks.
Sorry for the delay to return to this.
I address the comments.
Do I need to add some tests? If yes, can I have some help? Thanks!
@rgaiacs thanks for this PR!
How complicated would it be to customize components like HowItWorks.jsx, and have the template page use the built dist to control what gets rendered inside <div id="root"></div>?
For example, I can easily add header/footer
but I cannot figure out a way to "replace" the binder logo with this design.
Also, I think extra_static_path no longer takes effect, or at least I could not figure out how to link assets I used to mount at /etc/binderhub/custom/static.
Hi @agahkarakuzu,
the challenge to customise any file in binderhub/static/js is due to how the JavaScript works.
We are using webpack to merge all JavaScript files into a single bundle.js file that is we reference in the HTML that we send to the user, see https://github.com/jupyterhub/binderhub/blob/837169dfebf9640c4d3b4f4247240b15fe2278a0/binderhub/templates/page.html#L27
How complicated would it be to customize components like HowItWorks.jsx
If you want to change any of the JavaScript files, for example HowItWorks.jsx, you will have to
- re-run webpack to create a new
bundle.js. - create a new volume that overwrite the default
bundle.jswith the one that you created.
Thanks @rgaiacs ! I actually created a new bundle.js. Would simply mounting the new distribution override the existing one?
Would simply mounting the new distribution override the existing one?
It should.
It did! https://binder.evidencepub.io
- name: custom-templates
mountPath: /usr/local/lib/python3.13/site-packages/binderhub/static/
subPath: static
The mountPath is a bit dependent on the python version, but I was able to build the sources from modified content and have that content rendered.
Build sources are from https://github.com/evidencepub/binder-template/tree/preview. I'll add a github action to this repository to better streamline the builds.
One of the tests are with
FAILED binderhub/tests/test_registry.py::test_get_image_manifest[False] - OSError: [Errno 98] Address already in use
I believe the failure not related with this pull request.
@yuvipanda and @minrk this is blocking https://github.com/jupyterhub/mybinder.org-deploy/pull/3186 and I would like to merge this earlier next week.
Do we need the new template_file property? Can't we already override the template using template_path?
https://github.com/jupyterhub/binderhub/blob/43ecb3a8677ad4a5e0a0a70e1a0ab240f67d52dd/binderhub/app.py#L791-L798