Location of Jupyterhub css for customization?

1,947 views
Skip to first unread message

Ted Liefeld

unread,
Aug 3, 2016, 1:25:35 PM8/3/16
to Project Jupyter
I am installing a jupyterhub (using custom auth and dockerspawner) for a project and we would like to customize the css for the hub and the notebooks.  I can't seem to find any docs that indicate where I can find the css and there are ~30 different files matching style.min.css on my installation.  Can someone point me to a doc on customizing the jupyterhub appearance or suggest what the right path is for the css?

Running jupyterhub 0.6.1 fwiw

Thanks

Ted

Ted Liefeld

unread,
Aug 3, 2016, 2:02:20 PM8/3/16
to Project Jupyter
Answering my own post (partially) for anyone who comes later

The hub seems to use this version of the file

    /usr/local/share/jupyter/hub/static/css/style.min.css

on my AWS instance (deployed following these instructions https://github.com/jupyterhub/jupyterhub/wiki/Deploying-JupyterHub-on-AWS) but you do need to restart to have changes reflected.  Also need to still figure out how to customize the docker-spawned single user notebooks that seem to be using a drive mounted from somewhere still TBD

MinRK

unread,
Aug 4, 2016, 7:04:48 AM8/4/16
to Project Jupyter
On Wed, Aug 3, 2016 at 8:02 PM, Ted Liefeld <lie...@broadinstitute.org> wrote:
Answering my own post (partially) for anyone who comes later

The hub seems to use this version of the file

    /usr/local/share/jupyter/hub/static/css/style.min.css

That's the default installation location, yes. For customization, one option is to edit the LESS files in the JupyterHub repo prior to installation, then run:

    python setup.py css
 

on my AWS instance (deployed following these instructions https://github.com/jupyterhub/jupyterhub/wiki/Deploying-JupyterHub-on-AWS) but you do need to restart to have changes reflected.  Also need to still figure out how to customize the docker-spawned single user notebooks that seem to be using a drive mounted from somewhere still TBD

The default spawner doesn't mount any volumes, but you can ask it to via configuration.
 




On Wednesday, August 3, 2016 at 10:25:35 AM UTC-7, Ted Liefeld wrote:
I am installing a jupyterhub (using custom auth and dockerspawner) for a project and we would like to customize the css for the hub and the notebooks.  I can't seem to find any docs that indicate where I can find the css and there are ~30 different files matching style.min.css on my installation.  Can someone point me to a doc on customizing the jupyterhub appearance or suggest what the right path is for the css?

Running jupyterhub 0.6.1 fwiw

Thanks

Ted

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/3ce01808-6fe9-4902-8d26-39136107511f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ted Liefeld

unread,
Aug 4, 2016, 2:08:39 PM8/4/16
to Project Jupyter
On a related note,

how can I access the current username so that I can change the logout button to be "Logout {username}" (a feature requested for my server by the management...

Thanks


On Thursday, August 4, 2016 at 4:04:48 AM UTC-7, Min RK wrote:
On Wed, Aug 3, 2016 at 8:02 PM, Ted Liefeld <lie...@broadinstitute.org> wrote:
Answering my own post (partially) for anyone who comes later

The hub seems to use this version of the file

    /usr/local/share/jupyter/hub/static/css/style.min.css

That's the default installation location, yes. For customization, one option is to edit the LESS files in the JupyterHub repo prior to installation, then run:

    python setup.py css
 

on my AWS instance (deployed following these instructions https://github.com/jupyterhub/jupyterhub/wiki/Deploying-JupyterHub-on-AWS) but you do need to restart to have changes reflected.  Also need to still figure out how to customize the docker-spawned single user notebooks that seem to be using a drive mounted from somewhere still TBD

The default spawner doesn't mount any volumes, but you can ask it to via configuration.
 




On Wednesday, August 3, 2016 at 10:25:35 AM UTC-7, Ted Liefeld wrote:
I am installing a jupyterhub (using custom auth and dockerspawner) for a project and we would like to customize the css for the hub and the notebooks.  I can't seem to find any docs that indicate where I can find the css and there are ~30 different files matching style.min.css on my installation.  Can someone point me to a doc on customizing the jupyterhub appearance or suggest what the right path is for the css?

Running jupyterhub 0.6.1 fwiw

Thanks

Ted

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Ted Liefeld

unread,
Aug 4, 2016, 3:17:43 PM8/4/16
to Project Jupyter
Answering myself again...

in the hub you can add this to the logout button of the template

{{user.orm_user.name}}


Still working on the docker image to see if it will work there too

MinRK

unread,
Aug 5, 2016, 4:33:26 AM8/5/16
to Project Jupyter
On Thu, Aug 4, 2016 at 9:17 PM, Ted Liefeld <lie...@broadinstitute.org> wrote:
Answering myself again...

in the hub you can add this to the logout button of the template

{{user.orm_user.name}}

{{user.name}} works, too.
 
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Ted Liefeld

unread,
Aug 5, 2016, 12:48:18 PM8/5/16
to Project Jupyter
Any suggestion for how to get the username in the singleuser image launched by dockerspawner?  I don't seem to have the user there and (as intended) its running as jovyan

Ted

MinRK

unread,
Aug 8, 2016, 5:06:50 AM8/8/16
to Project Jupyter
The server has the user's name, but it's not the name of the user in the container. To do that, you would need to run

    usermod -l newname jovyan

in the container *on startup*, which means that the container must initially start as root, and then switch to the user after modifying the system. This is what the SystemUserSpawner does, and one of the reasons I recommend against using the SystemUserSpawner if it can be avoided.

Is it important to you for the shell username to be your user's name?

-MinRK


To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Ted Liefeld

unread,
Aug 8, 2016, 5:27:29 PM8/8/16
to Project Jupyter
I don't need the shell name to be the username, I just want access to the username (whatever was passed from the hub) so that I can customize the UI logout button to say

    "Logout <username>"

instead of just "logout" to meet a local requirement.  I believe I can make the UI change from the custom.css or custom.js but first I have to figure out how to get the username that the hub has for a particular single user instance

Ted

Ted Liefeld

unread,
Aug 8, 2016, 6:23:50 PM8/8/16
to Project Jupyter
FYI here is my first pass attempt.  It works but relies on parsing the URL in the notebook to get the username.  I think this might be a bit brittle but it works for a first pass

1. On the hub server, create a custom.js file with the following in its contents

    var username =  (""+ window.location).split('/')[4];

    $('#logout').html( "Logout " + username)


2. Mount the directory containing it to the appropriate location for it to be picked up by the single-user jupyter server running in the docker container

    c.DockerSpawner.volumes = {

       '<PATH TO DIRECTORY WITH custom.js ON HUB SERVER>':'/opt/conda/lib/python3.5/site-packages/notebook/static/custom',

     }


3. Restart your docker container and/or hub if necessary (i.e. it reuses old docker containers so if you did not have the volumes param when it was created you have to remove it to have it added in.  Also the spawner only reads the config at startup so the same applies there.






Reply all
Reply to author
Forward
0 new messages