From 155c8f664a33c6aebb7b9fcf9412deb7e80833ed Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 8 Feb 2023 16:12:03 +0100 Subject: [PATCH] singleuser: add some clarifying comments --- .prettierignore | 1 + jupyterhub/singleuser/__init__.py | 2 +- jupyterhub/singleuser/mixins.py | 4 +++- jupyterhub/singleuser/templates/page.html | 23 ++++++++++++++++++++--- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.prettierignore b/.prettierignore index d0730bb6..0bc25361 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,3 @@ share/jupyterhub/templates/ share/jupyterhub/static/js/admin-react.js +jupyterhub/singleuser/templates/ diff --git a/jupyterhub/singleuser/__init__.py b/jupyterhub/singleuser/__init__.py index 97fa3c70..eb46d258 100644 --- a/jupyterhub/singleuser/__init__.py +++ b/jupyterhub/singleuser/__init__.py @@ -7,6 +7,7 @@ import os from .mixins import HubAuthenticatedHandler, make_singleuser_app if os.environ.get("JUPYTERHUB_SINGLEUSER_EXTENSION", "") not in ("", "0"): + _as_extension = True # check for conflict in singleuser entrypoint environment variables if os.environ.get("JUPYTERHUB_SINGLEUSER_APP", "") not in { "", @@ -21,7 +22,6 @@ if os.environ.get("JUPYTERHUB_SINGLEUSER_EXTENSION", "") not in ("", "0"): f"Cannot use JUPYTERHUB_SINGLEUSER_EXTENSION={ext} with JUPYTERHUB_SINGLEUSER_APP={app}." " Please pick one or the other." ) - _as_extension = True from .extension import main else: _as_extension = False diff --git a/jupyterhub/singleuser/mixins.py b/jupyterhub/singleuser/mixins.py index 15059122..66dca263 100755 --- a/jupyterhub/singleuser/mixins.py +++ b/jupyterhub/singleuser/mixins.py @@ -911,12 +911,14 @@ def make_singleuser_app(App): empty_parent_app = App() log = empty_parent_app.log - # detect base classes + # detect base handler classes if not getattr(empty_parent_app, "login_handler_class", None) and hasattr( empty_parent_app, "identity_provider_class" ): + # Jupyter Server 2 moves the login handler classes to the identity provider has_handlers = empty_parent_app.identity_provider_class(parent=empty_parent_app) else: + # prior to Jupyter Server 2, the app itself had handler class config has_handlers = empty_parent_app LoginHandler = has_handlers.login_handler_class LogoutHandler = has_handlers.logout_handler_class diff --git a/jupyterhub/singleuser/templates/page.html b/jupyterhub/singleuser/templates/page.html index 8ce5e8c7..89ab97b4 100644 --- a/jupyterhub/singleuser/templates/page.html +++ b/jupyterhub/singleuser/templates/page.html @@ -1,5 +1,17 @@ -{% extends "templates/page.html" %} {% block header_buttons %} {{super()}} +{# +this template customizes all pages (classic notebook, not jupyterlab) served by the single-user server +It makes the following modifications: + +- add jupyterhub control panel link to the header +- update logo url to jupyterhub +- remove `?redirects` url param that may be added by jupyterhub +#} + +{% extends "templates/page.html" %} + +{% block header_buttons %} +{{ super() }} -{% endblock %} {% block logo %} +{% endblock %} + +{% block logo %} Jupyter Notebook -{% endblock logo %} {% block script %} {{ super() }} +{% endblock logo %} + +{% block script %} +{{ super() }}