Skip to content

Commit 1c3d5bc

Browse files
authored
Merge pull request #17 from 2i2c-org/chooseable-interface
Allow choosing default interface with default_url option
2 parents 5d1b14a + 681d9c2 commit 1c3d5bc

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

jupyterhub_config.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1+
"""
2+
jupyterhub_config purely used for testing changes to templates.
3+
4+
See README.md for information on how to test this out.
5+
"""
16
import pathlib
27
from oauthenticator.generic import GenericOAuthenticator
38
from jupyterhub.spawner import SimpleLocalProcessSpawner
49

510

6-
c.JupyterHub.spawner_class = SimpleLocalProcessSpawner
7-
811
HERE = pathlib.Path(__file__).parent
912

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

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

14-
c.Authenticator.admin_users = [
15-
'yuvipanda'
16-
]
17-
23+
# Variables that are passed through to templates!
1824
c.JupyterHub.template_vars = {
1925
'custom': {
2026
"interface_selector": True,
27+
"default_url": "/rstudio",
2128
'org': {
2229
'name': 'University of Foo',
2330
'logo_url': 'https://jupyter.org/assets/nav_logo.svg',

templates/login.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,25 @@
3434
<div class="form-group interface-selector">
3535
<label>After logging in, open: </label>
3636
<label class="radio-inline">
37-
<input type="radio" name="interface" value="tree" checked>Jupyter Notebook
37+
<input type="radio" name="interface" value="tree"
38+
{% if "default_url" not in custom or custom["default_url"] == "/tree" %}
39+
checked
40+
{% endif %}
41+
>Jupyter Notebook
3842
</label>
3943
<label class="radio-inline">
40-
<input type="radio" name="interface" value="rstudio">RStudio
44+
<input type="radio" name="interface" value="rstudio"
45+
{% if "default_url" in custom and custom["default_url"] == "/rstudio" %}
46+
checked
47+
{% endif %}
48+
>RStudio
4149
</label>
4250
<label class="radio-inline">
43-
<input type="radio" name="interface" value="lab">JupyterLab
51+
<input type="radio" name="interface" value="lab"
52+
{% if "default_url" in custom and custom["default_url"] == "/lab" %}
53+
checked
54+
{% endif %}
55+
>JupyterLab
4456
</label>
4557
</div>
4658
</form>

0 commit comments

Comments
 (0)