diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3d5e2a81..6ec95d00 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,6 +33,15 @@ repos: rev: v4.0.0-alpha.8 hooks: - id: prettier + exclude: .*/templates/.* + + # autoformat HTML templates + - repo: https://github.com/djlint/djLint + rev: v1.34.1 + hooks: + - id: djlint-reformat-jinja + files: ".*templates/.*.html" + types_or: ["html"] # Autoformat and linting, misc. details - repo: https://github.com/pre-commit/pre-commit-hooks diff --git a/docs/source/_templates/redoc.html b/docs/source/_templates/redoc.html index 8aafd0be..bf764d11 100644 --- a/docs/source/_templates/redoc.html +++ b/docs/source/_templates/redoc.html @@ -1,26 +1,24 @@ {%- extends "!layout.html" %} - {# not sure why, but theme CSS prevents scrolling within redoc content # If this were fixed, we could keep the navbar and footer #} -{%- block css %}{%- endblock %} -{%- block docs_navbar %}{%- endblock %} -{%- block footer %}{% endblock %} -{%- block body_tag %} - -{%- endblock %} - +{% block css %} +{% endblock css %} +{% block docs_navbar %} +{% endblock docs_navbar %} +{% block footer %} +{% endblock footer %} +{# djlint: off #} +{%- block body_tag -%}{%- endblock body_tag %} +{# djlint: on #} {%- block extrahead %} -{{ super() }} - - -{%- endblock %} - + {{ super() }} + + +{%- endblock extrahead %} {%- block content %} - - -{%- endblock %} + +{%- endblock content %} diff --git a/examples/service-announcement/templates/page.html b/examples/service-announcement/templates/page.html index 42c976ab..de980f51 100644 --- a/examples/service-announcement/templates/page.html +++ b/examples/service-announcement/templates/page.html @@ -1,9 +1,10 @@ -{% extends "templates/page.html" %} {% block announcement %} -
-{% endblock %} {% block script %} {{ super() }} - + {% endblock %} diff --git a/jsx/testing/index.html b/jsx/testing/index.html index 120145d2..3b8db5aa 100644 --- a/jsx/testing/index.html +++ b/jsx/testing/index.html @@ -2,11 +2,9 @@ - JupyterHub - diff --git a/jupyterhub/singleuser/templates/page.html b/jupyterhub/singleuser/templates/page.html index 89ab97b4..6dd57ca3 100644 --- a/jupyterhub/singleuser/templates/page.html +++ b/jupyterhub/singleuser/templates/page.html @@ -7,30 +7,23 @@ It makes the following modifications: - update logo url to jupyterhub - remove `?redirects` url param that may be added by jupyterhub #} - {% extends "templates/page.html" %} - {% block header_buttons %} -{{ super() }} - - - Control Panel - - + {{ super() }} + + Control Panel + {% endblock %} - {% block logo %} -Jupyter Notebook + Jupyter Notebook {% endblock logo %} - {% block script %} -{{ super() }} - + {% endblock script %} diff --git a/pyproject.toml b/pyproject.toml index fd072342..e5c8c5f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,6 +120,11 @@ select = [ "F", # flake8 ] +# djlint lints/formats our jinja templates +# https://djlint.com/docs/configuration/ +[tool.djlint] +indent = 2 + # tbump is used to simplify and standardize the release process when updating # the version, making a git commit and tag, and pushing changes. # diff --git a/share/jupyterhub/templates/404.html b/share/jupyterhub/templates/404.html index 19da8e43..2fc227aa 100644 --- a/share/jupyterhub/templates/404.html +++ b/share/jupyterhub/templates/404.html @@ -1,5 +1,2 @@ {% extends "error.html" %} - -{% block error_detail %} -

Jupyter has lots of moons, but this is not one...

-{% endblock %} +{% block error_detail %}

Jupyter has lots of moons, but this is not one...

{% endblock %} diff --git a/share/jupyterhub/templates/accept-share.html b/share/jupyterhub/templates/accept-share.html index af8b37b4..fd8d8d69 100644 --- a/share/jupyterhub/templates/accept-share.html +++ b/share/jupyterhub/templates/accept-share.html @@ -1,55 +1,51 @@ {% extends "page.html" %} -{% block login_widget %} -{% endblock %} - +{% block login_widget %}{% endblock %} {% block main %} -
-
-
-

Accept sharing invitation

-

- You ({{ user.name }}) have been invited to access {{ owner.name }}'s server - {%- if spawner.name %} ({{ spawner.name }}){%- endif %} at {{ spawner_url }} -

- - {% if not spawner_ready %} -

- The server at {{ spawner_url }} is not currently running. - After accepting permission, you may need to ask {{ owner.name }} - to start the server before you can access it. -

- {% endif %} - -
-
-
- By accepting the invitation, you will be granted the following permissions, - restricted to this particular server: -
-
- {# these are the 'real' inputs to the form -#} - - - {% for scope_info in scope_descriptions -%} -
- +
+
+
+

Accept sharing invitation

+

+ You ({{ user.name }}) have been invited to access {{ owner.name }}'s server + {%- if spawner.name %}({{ spawner.name }}){%- endif %} at {{ spawner_url }} +

+ {% if not spawner_ready %} +

+ The server at {{ spawner_url }} is not currently running. + After accepting permission, you may need to ask {{ owner.name }} + to start the server before you can access it. +

+ {% endif %} + +
+
+ By accepting the invitation, you will be granted the following permissions, + restricted to this particular server: +
+
+ {# these are the 'real' inputs to the form -#} + + + {% for scope_info in scope_descriptions -%} +
+ +
+ {% endfor -%} +
+ +
+
- {% endfor -%} -
-
- -
- {% endblock %} diff --git a/share/jupyterhub/templates/admin.html b/share/jupyterhub/templates/admin.html index 18247ee9..c5936c7c 100644 --- a/share/jupyterhub/templates/admin.html +++ b/share/jupyterhub/templates/admin.html @@ -1,17 +1,13 @@ {% extends "page.html" %} - {% block main %} -
- - -
+ + +
{% endblock %} - {% block footer %} - + {% endblock %} diff --git a/share/jupyterhub/templates/error.html b/share/jupyterhub/templates/error.html index 8a151e6e..1a63fe04 100644 --- a/share/jupyterhub/templates/error.html +++ b/share/jupyterhub/templates/error.html @@ -1,40 +1,19 @@ {% extends "page.html" %} - -{% block login_widget %} -{% endblock %} - +{% block login_widget %}{% endblock %} {% block main %} - -
- {% block h1_error %} -

- {{status_code}} : {{status_message}} -

- {% endblock h1_error %} - {% block error_detail %} - {% if message %} -

- {{message}} -

- {% endif %} - {% if message_html %} -

- {{message_html | safe}} -

- {% endif %} - {% if extra_error_html %} -

- {{extra_error_html | safe}} -

- {% endif %} - {% endblock error_detail %} -
- +
+ {% block h1_error %} +

{{ status_code }} : {{ status_message }}

+ {% endblock h1_error %} + {% block error_detail %} + {% if message %}

{{ message }}

{% endif %} + {% if message_html %}

{{ message_html | safe }}

{% endif %} + {% if extra_error_html %}

{{ extra_error_html | safe }}

{% endif %} + {% endblock error_detail %} +
{% endblock %} - {% block script %} - {{super()}} - + {{ super() }} + {{ super() }} + {% endblock %} diff --git a/share/jupyterhub/templates/login.html b/share/jupyterhub/templates/login.html index 8c13b2e1..03ad65b5 100644 --- a/share/jupyterhub/templates/login.html +++ b/share/jupyterhub/templates/login.html @@ -2,112 +2,94 @@ {% if announcement_login is string %} {% set announcement = announcement_login %} {% endif %} - -{% block login_widget %} -{% endblock %} - +{% block login_widget %}{% endblock %} {% block main %} - -{% block login %} -
-{% block login_container %} -{% if custom_html %} -{{ custom_html | safe }} -{% elif login_service %} - -{% else %} -
-
-

Sign in

-
-
- - - - {% if login_error %} - - {% endif %} - - - - - - {% if authenticator.request_otp %} - - - {% endif %} - - - -{% endif %} -{% endblock login_container %} -
-{% endblock login %} - + {% endblock login %} {% endblock %} - {% block script %} -{{ super() }} - + {% endblock %} diff --git a/share/jupyterhub/templates/logout.html b/share/jupyterhub/templates/logout.html index 6bce3c19..910c580f 100644 --- a/share/jupyterhub/templates/logout.html +++ b/share/jupyterhub/templates/logout.html @@ -2,13 +2,8 @@ {% if announcement_logout is string %} {% set announcement = announcement_logout %} {% endif %} - {% block main %} - -
-

- Successfully logged out. -

-
- +
+

Successfully logged out.

+
{% endblock %} diff --git a/share/jupyterhub/templates/not_running.html b/share/jupyterhub/templates/not_running.html index b2fcfa73..52d56c77 100644 --- a/share/jupyterhub/templates/not_running.html +++ b/share/jupyterhub/templates/not_running.html @@ -1,60 +1,62 @@ {% extends "page.html" %} - {% block main %} - -
-
-
- {% block heading %} -

- {% if failed %} - Spawn failed - {% else %} - Server not running - {% endif %} -

- {% endblock %} - {% block message %} -

- {% if failed %} - The latest attempt to start your server {{ server_name }} has failed. - {% if failed_html_message %} -

{{ failed_html_message | safe }}

- {% elif failed_message %} -

{{ failed_message }}

- {% endif %} - Would you like to retry starting it? - {% else %} - Your server {{ server_name }} is not running. - {% if implicit_spawn_seconds %} - It will be restarted automatically. - If you are not redirected in a few seconds, - click below to launch your server. - {% else %} - Would you like to start it? - {% endif %} - {% endif %} -

- {% endblock %} - {% block start_button %} - - {% if failed %} - Relaunch - {% else %} - Launch - {% endif %} - Server {{ server_name }} - - {% endblock %} +
+
+
+ {% block heading %} +

+ {% if failed %} + Spawn failed + {% else %} + Server not running + {% endif %} +

+ {% endblock %} + {% block message %} +

+ {% if failed %} + The latest attempt to start your server {{ server_name }} has failed. + {% if failed_html_message %} +

+

{{ failed_html_message | safe }}

+

{% elif failed_message %}

+

{{ failed_message }}

+

+ {% endif %} + Would you like to retry starting it? + {% else %} + Your server {{ server_name }} is not running. + {% if implicit_spawn_seconds %} + It will be restarted automatically. + If you are not redirected in a few seconds, + click below to launch your server. + {% else %} + Would you like to start it? + {% endif %} + {% endif %} +

+ {% endblock %} + {% block start_button %} + + {% if failed %} + Relaunch + {% else %} + Launch + {% endif %} + Server {{ server_name }} + + {% endblock %} +
-
- {% endblock %} {% block script %} -{{ super () }} -{% if implicit_spawn_seconds %} - -{% endif %} - + + {% endif %} + {% endblock script %} diff --git a/share/jupyterhub/templates/oauth.html b/share/jupyterhub/templates/oauth.html index eab725d7..4756312f 100644 --- a/share/jupyterhub/templates/oauth.html +++ b/share/jupyterhub/templates/oauth.html @@ -1,60 +1,47 @@ {% extends "page.html" %} - -{% block login_widget %} -{% endblock %} - +{% block login_widget %}{% endblock %} {% block main %} -
-
-
-

Authorize access

-

- An application is requesting authorization to access data associated with your JupyterHub account -

-

- {{ oauth_client.description }} (oauth URL: {{ oauth_client.redirect_uri }}) - would like permission to identify you. - {% if scope_descriptions | length == 1 and not scope_descriptions[0].scope %} - It will not be able to take actions on - your behalf. - {% endif %} -

- -
-
-
-

This will grant the application permission to: -

-
-
- - {# these are the 'real' inputs to the form -#} - {% for scope in allowed_scopes %} - - {% endfor %} - - {% for scope_info in scope_descriptions %} -
- +
+
+
+

Authorize access

+

An application is requesting authorization to access data associated with your JupyterHub account

+

+ {{ oauth_client.description }} (oauth URL: {{ oauth_client.redirect_uri }}) + would like permission to identify you. + {% if scope_descriptions | length == 1 and not scope_descriptions[0].scope %} + It will not be able to take actions on + your behalf. + {% endif %} +

+ +
+
+

This will grant the application permission to:

- {% endfor %} -
- +
- -
-
- -{% endblock %} + {% endblock %} diff --git a/share/jupyterhub/templates/page.html b/share/jupyterhub/templates/page.html index 43888fcb..533e8311 100644 --- a/share/jupyterhub/templates/page.html +++ b/share/jupyterhub/templates/page.html @@ -1,51 +1,55 @@ {% macro modal(title, btn_label=None, btn_class="btn-primary") %} -{% set key = title.replace(' ', '-').lower() %} -{% set btn_label = btn_label or title %} -