Skip to content

Commit

Permalink
Merge pull request #17 from 2i2c-org/chooseable-interface
Browse files Browse the repository at this point in the history
Allow choosing default interface with default_url option
  • Loading branch information
yuvipanda authored Dec 13, 2022
2 parents 5d1b14a + 681d9c2 commit 1c3d5bc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
19 changes: 13 additions & 6 deletions jupyterhub_config.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
"""
jupyterhub_config purely used for testing changes to templates.
See README.md for information on how to test this out.
"""
import pathlib
from oauthenticator.generic import GenericOAuthenticator
from jupyterhub.spawner import SimpleLocalProcessSpawner


c.JupyterHub.spawner_class = SimpleLocalProcessSpawner

HERE = pathlib.Path(__file__).parent

# Add templates from our local checkout to the path JupyterHub searches
# This allows us to override any template present in upstream
# jupyterhub (https://github.com/jupyterhub/jupyterhub/tree/main/share/jupyterhub/templates)
# locally
c.JupyterHub.template_paths = [str(HERE / 'templates')]

# We use this so we can get a 'login' button, instead of a username / password
# field.
c.JupyterHub.authenticator_class = GenericOAuthenticator

c.Authenticator.admin_users = [
'yuvipanda'
]

# Variables that are passed through to templates!
c.JupyterHub.template_vars = {
'custom': {
"interface_selector": True,
"default_url": "/rstudio",
'org': {
'name': 'University of Foo',
'logo_url': 'https://jupyter.org/assets/nav_logo.svg',
Expand Down
18 changes: 15 additions & 3 deletions templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,25 @@
<div class="form-group interface-selector">
<label>After logging in, open: </label>
<label class="radio-inline">
<input type="radio" name="interface" value="tree" checked>Jupyter Notebook
<input type="radio" name="interface" value="tree"
{% if "default_url" not in custom or custom["default_url"] == "/tree" %}
checked
{% endif %}
>Jupyter Notebook
</label>
<label class="radio-inline">
<input type="radio" name="interface" value="rstudio">RStudio
<input type="radio" name="interface" value="rstudio"
{% if "default_url" in custom and custom["default_url"] == "/rstudio" %}
checked
{% endif %}
>RStudio
</label>
<label class="radio-inline">
<input type="radio" name="interface" value="lab">JupyterLab
<input type="radio" name="interface" value="lab"
{% if "default_url" in custom and custom["default_url"] == "/lab" %}
checked
{% endif %}
>JupyterLab
</label>
</div>
</form>
Expand Down

0 comments on commit 1c3d5bc

Please sign in to comment.