From f5ed53ea86b037adf20a62c08ce6718d1f8c2d1f Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sat, 23 Apr 2022 14:32:26 +0100 Subject: [PATCH] Main page footer can be overridden This allows the footer on the main (index) page to be replaced with custom HTML. Related to https://github.com/jupyterhub/mybinder.org-deploy/issues/2156 --- binderhub/app.py | 11 +++++++++++ binderhub/main.py | 1 + binderhub/templates/index.html | 8 ++++++++ testing/local-binder-local-hub/binderhub_config.py | 1 + 4 files changed, 21 insertions(+) diff --git a/binderhub/app.py b/binderhub/app.py index 47198e60c..e13002bc7 100644 --- a/binderhub/app.py +++ b/binderhub/app.py @@ -145,6 +145,16 @@ def _log_level(self): config=True, ) + main_footer_message = Unicode( + "", + help=""" + Override the footer on the main page. + + The value will be inserted "as is". Raw HTML is supported. + """, + config=True, + ) + extra_footer_scripts = Dict( {}, help=""" @@ -822,6 +832,7 @@ def initialize(self, *args, **kwargs): "google_analytics_domain": self.google_analytics_domain, "about_message": self.about_message, "banner_message": self.banner_message, + "main_footer_message": self.main_footer_message, "extra_footer_scripts": self.extra_footer_scripts, "jinja2_env": jinja_env, "build_memory_limit": self.build_memory_limit, diff --git a/binderhub/main.py b/binderhub/main.py index 6d302972e..c5361f253 100644 --- a/binderhub/main.py +++ b/binderhub/main.py @@ -36,6 +36,7 @@ def get(self): submit=False, google_analytics_code=self.settings["google_analytics_code"], google_analytics_domain=self.settings["google_analytics_domain"], + main_footer_message=self.settings["main_footer_message"], extra_footer_scripts=self.settings["extra_footer_scripts"], repo_providers=self.settings["repo_providers"], ) diff --git a/binderhub/templates/index.html b/binderhub/templates/index.html index 0e9b5134c..02bffabee 100644 --- a/binderhub/templates/index.html +++ b/binderhub/templates/index.html @@ -195,7 +195,15 @@

How it works

{% endblock main %} {% block footer %} + +{% if main_footer_message %} +
+ {{ main_footer_message | safe }} +
+{% else %} {{ super () }} +{% endif %} + diff --git a/testing/local-binder-local-hub/binderhub_config.py b/testing/local-binder-local-hub/binderhub_config.py index 54d7395b7..04ef56e0f 100644 --- a/testing/local-binder-local-hub/binderhub_config.py +++ b/testing/local-binder-local-hub/binderhub_config.py @@ -29,6 +29,7 @@ c.BinderHub.banner_message = ( 'See BinderHub on GitHub' ) +c.BinderHub.main_footer_message = '

This is a custom footer message.

' c.BinderHub.hub_url_local = "http://localhost:8000"