Skip to content

Conversation

rgaiacs
Copy link
Contributor

@rgaiacs rgaiacs commented Jan 30, 2025

Closes #1907

We might want to make add a new traitlets for users to provide their own Jinja template that will be used in

"page.html",
from
self.render_template(
"page.html",
page_config=self.page_config,
extra_footer_scripts=self.settings["extra_footer_scripts"],
opengraph_title=self.opengraph_title,
)

@rgaiacs rgaiacs requested a review from yuvipanda January 30, 2025 13:37
@rgaiacs rgaiacs self-assigned this Jan 30, 2025
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

BinderHub uses `Jinja <https://jinja.palletsprojects.com/en/stable/>`_ as template engine
to process the page template `binderhub/templates/page.html <https://github.com/jupyterhub/binderhub/blob/main/binderhub/templates/page.html>`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be helpful to also highlight the important parts of the template- is <div id="root"></div> the critical bit?

release: {{ .Release.Name }}
data:
{{- (.Files.Glob "files/*").AsConfig | nindent 2 }}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is additional Helm configuration needed to mount the file in the ConfigMap into the BinderHub pod?

@rgaiacs
Copy link
Contributor Author

rgaiacs commented Feb 5, 2025

I will address the comments in a couple of weeks.

@rgaiacs rgaiacs requested a review from manics March 28, 2025 16:35
@rgaiacs
Copy link
Contributor Author

rgaiacs commented Mar 28, 2025

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!

@agahkarakuzu
Copy link

@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

image

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.

@rgaiacs
Copy link
Contributor Author

rgaiacs commented Apr 28, 2025

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

<script src="{{static_url("dist/bundle.js")}}"></script>

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

  1. re-run webpack to create a new bundle.js.
  2. create a new volume that overwrite the default bundle.js with the one that you created.

@agahkarakuzu
Copy link

Thanks @rgaiacs ! I actually created a new bundle.js. Would simply mounting the new distribution override the existing one?

@rgaiacs
Copy link
Contributor Author

rgaiacs commented Apr 28, 2025

Would simply mounting the new distribution override the existing one?

It should.

@agahkarakuzu
Copy link

agahkarakuzu commented Apr 28, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

Document how to customise index / root page
3 participants