Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Adding test documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
costrouc committed Oct 26, 2020
1 parent 048bdad commit e0d8cd8
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eval "$(lorri direnv)"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# exclude jupyterhub created assets
share
jupyterhub-proxy.pid
jupyterhub.sqlite
jupyterhub_cookie_secret
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ c.JupyterHub.logo_file = '/usr/local/share/jupyter/hub/static/custom/images/logo
c.JupyterHub.template_paths = ['/usr/local/share/jupyter/hub/custom_templates/',
'/usr/local/share/jupyter/hub/templates/']
```

## Testing

Install the development environment

```shell
conda env install -f environment.yaml
```

Anytime you make changes to `extra-assets` you will need to restart
jupyterhub but any changes to `templates` will not require a restart.

Run jupyterhub via the test script

```shell
./test.sh
```
4 changes: 4 additions & 0 deletions environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: jupyterhub-theme
dependencies:
- jupyterhub
- jupyterlab
10 changes: 10 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ pkgs ? import <nixpkgs> {}, pythonPackages ? pkgs.python3Packages }:

pkgs.mkShell {
buildInputs = [
pythonPackages.jupyterhub

# keep this line if you use bash
pkgs.bashInteractive
];
}
5 changes: 3 additions & 2 deletions templates/page.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{% extends "templates/page.html" %}

{% block stylesheet %}
<link rel="stylesheet" href="{{ static_url("extra-assets/css/pangeo-style.css") }}" type="text/css"/>
<link rel="stylesheet" href="{{ static_url("custom/css/pangeo-style.css") }}" type="text/css"/>
<link rel="stylesheet" href="{{ static_url("css/style.min.css") }}" type="text/css"/>
{% endblock %}

{# requires jupyerhub > 0.9.4 https://github.com/jupyterhub/jupyterhub/pull/2296 #}
{% block logo %}
<span id="jupyterhub-logo" class="pull-left">
<a href="{{logo_url or base_url}}"><img src="{{static_url("extra-assets/images/jupyter_qhub_logo.svg") }}" alt='JupyterHub' class='jpy-logo' title='Home'/></a>
<a href="{{logo_url or base_url}}"><img src="{{static_url("custom/images/jupyter_qhub_logo.svg") }}" alt='JupyterHub' class='jpy-logo' title='Home'/></a>
</span>
{% endblock %}
and
9 changes: 9 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

mkdir -p share
cp -r $(python -c "import jupyterhub.app; print(jupyterhub.app.DATA_FILES_PATH)") share
chmod -R 755 share
# we have to copy assets since jupyterhub does not have an easy way to add static paths...
cp -r extra-assets/css extra-assets/images share/jupyterhub/static/custom

jupyterhub --config test_jupyterhub_config.py
20 changes: 20 additions & 0 deletions test_jupyterhub_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
c.JupyterHub.authenticator_class = 'jupyterhub.auth.DummyAuthenticator'
c.DummyAuthenticator.password = 'test'

# since we accept any username for launching we cannot use the default pam spawner
c.JupyterHub.spawner_class = 'jupyterhub.spawner.SimpleLocalProcessSpawner'

c.JupyterHub.logo_file = 'share/jupyterhub/static/custom/images/jupyter_qhub_logo_small.png'
# we have to manually set the data file path to include custom assets...
c.JupyterHub.data_files_path = './share/jupyterhub'
c.JupyterHub.template_paths = [
'./templates',
'./share/jupyterhub/templates/'
]

# QHUB will control these as ways to customize the template
c.JupyterHub.template_vars = {
'pangeo_hub_title': 'this is a test title',
'pangeo_hub_subtitle': 'this is a subtitle',
'pangeo_welcome': 'this is a message to login page',
}

0 comments on commit e0d8cd8

Please sign in to comment.