diff --git a/accounts/templates/accounts/lockout.html b/accounts/templates/accounts/lockout.html index 219c958f..4d9a0332 100644 --- a/accounts/templates/accounts/lockout.html +++ b/accounts/templates/accounts/lockout.html @@ -2,6 +2,7 @@ {% load i18n %} {% block title %}{% trans "WebVirtCloud" %} - {% trans "Sign-in locked" %}{% endblock title %} +{% block page_header %}{% endblock page_header %}{# the page has its own heading #} {% block content %}
diff --git a/accounts/templates/accounts/otp_login.html b/accounts/templates/accounts/otp_login.html index 83212346..a4d2192d 100644 --- a/accounts/templates/accounts/otp_login.html +++ b/accounts/templates/accounts/otp_login.html @@ -3,6 +3,7 @@ {% load i18n %} {% block title %}{% trans "WebVirtCloud" %} - {% trans "Sign In with OTP" %}{% endblock title %} +{% block page_header %}{% endblock page_header %}{# the page has its own heading #} {% block content %}
diff --git a/accounts/templates/login.html b/accounts/templates/login.html index 31f15213..ae386c97 100644 --- a/accounts/templates/login.html +++ b/accounts/templates/login.html @@ -3,6 +3,7 @@ {% load i18n %} {% block title %}{% trans "WebVirtCloud" %} - {% trans "Sign In" %}{% endblock title %} +{% block page_header %}{% endblock page_header %}{# the page has its own heading #} {% block content %}
diff --git a/accounts/tests/test_login_page.py b/accounts/tests/test_login_page.py index 165576bc..36b8e31b 100644 --- a/accounts/tests/test_login_page.py +++ b/accounts/tests/test_login_page.py @@ -49,6 +49,7 @@ class LoginPageTests(TestCase): response = self.login("right-pass-1") self.assertEqual(response.status_code, 429) self.assertTemplateUsed(response, "accounts/lockout.html") + self.assertEqual(response.content.decode().count(" @@ -12,6 +13,7 @@ +

{% trans "Balance" %}

{% trans "Migrations that give each host about the same share of its memory, then of its CPUs, for its running VMs: a host twice as large takes twice as much." %}

{% if unreachable %}
{% trans "These hosts cannot be read and are left out:" %} {{ unreachable|join:", " }}
diff --git a/computes/templates/computes/list.html b/computes/templates/computes/list.html index 43fa6b1e..ecfcea00 100644 --- a/computes/templates/computes/list.html +++ b/computes/templates/computes/list.html @@ -4,6 +4,7 @@ {% load bootstrap_icons %} {% load operations %} {% block title %}{% trans "Computes" %}{% endblock %} +{% block page_header %}{% endblock page_header %}{# the page has its own heading #} {% block content %}
@@ -11,7 +12,7 @@ {% include 'create_comp_block.html' %} {% if computes|length > 1 %}{% trans "Balance" %}{% endif %} {% include 'search_block.html' %} -

{% trans "Computes" %}

+

{% trans "Computes" %}

{% include "computes/attention.html" %} diff --git a/computes/templates/overview.html b/computes/templates/overview.html index 3050fb1d..15223b0e 100644 --- a/computes/templates/overview.html +++ b/computes/templates/overview.html @@ -14,11 +14,11 @@ {% elif given.active %} {# its VMs are migrated with it: the Bulk Migrate page puts it in maintenance, with or without moving them #} -{% bs_icon 'wrench-adjustable' %} {% trans "Put in maintenance" %} +{% bs_icon 'wrench-adjustable' %} {% trans "Put in maintenance" %} {% else %}
{% csrf_token %} - +
{% endif %} {% bs_icon 'pencil' %} {% trans "Edit connection" %} diff --git a/locale/tr/LC_MESSAGES/django.mo b/locale/tr/LC_MESSAGES/django.mo index 6825c706..1c472cf9 100644 Binary files a/locale/tr/LC_MESSAGES/django.mo and b/locale/tr/LC_MESSAGES/django.mo differ diff --git a/locale/tr/LC_MESSAGES/django.po b/locale/tr/LC_MESSAGES/django.po index 4b40bf0d..e0714b47 100644 --- a/locale/tr/LC_MESSAGES/django.po +++ b/locale/tr/LC_MESSAGES/django.po @@ -13080,3 +13080,7 @@ msgstr[1] "%(failure_count)d başarısız deneme nedeniyle doğrulama geçici ol msgid "Verification of the token is currently disabled" msgstr "Kod doğrulaması şu anda kapalı" + +#: templates/base.html:35 +msgid "Skip to content" +msgstr "İçeriğe atla" diff --git a/locale/zh/LC_MESSAGES/django.mo b/locale/zh/LC_MESSAGES/django.mo index 355cd220..872ca931 100644 Binary files a/locale/zh/LC_MESSAGES/django.mo and b/locale/zh/LC_MESSAGES/django.mo differ diff --git a/locale/zh/LC_MESSAGES/django.po b/locale/zh/LC_MESSAGES/django.po index d5885b32..280f5d3c 100644 --- a/locale/zh/LC_MESSAGES/django.po +++ b/locale/zh/LC_MESSAGES/django.po @@ -12251,3 +12251,7 @@ msgstr[0] "由于 %(failure_count)d 次验证失败,验证已暂时停用, msgid "Verification of the token is currently disabled" msgstr "当前已停用验证码验证" + +#: templates/base.html:35 +msgid "Skip to content" +msgstr "跳到内容" diff --git a/static/css/webvirtcloud.css b/static/css/webvirtcloud.css index e55e4db3..685a59f4 100644 --- a/static/css/webvirtcloud.css +++ b/static/css/webvirtcloud.css @@ -334,3 +334,8 @@ td .tag-more { width: 0.85em; height: 0.85em; } + +/* "Skip to content" brings #main up below the sticky navbar, not behind it */ +#main { + scroll-margin-top: 5rem; +} diff --git a/static/js/otp_qr.js b/static/js/otp_qr.js index 41c243ec..80d4d8e8 100644 --- a/static/js/otp_qr.js +++ b/static/js/otp_qr.js @@ -1,7 +1,8 @@ // The mailed OTP link carries its token after "#", which no request sends, -// so it is in no access log: the page posts it to get the QR code. +// so it is in no access log: the page posts it to get the QR code. A signed +// token has a ":"; another fragment (the "Skip to content" link's) is not one. var otpQrForm = document.getElementById("otp-qr-form"); -if (otpQrForm && location.hash.length > 1) { +if (otpQrForm && location.hash.includes(":")) { otpQrForm.elements.token.value = location.hash.slice(1); history.replaceState(null, "", location.pathname); otpQrForm.submit(); diff --git a/static/js/searchable_select.js b/static/js/searchable_select.js index 6b50ef46..03107bb2 100644 --- a/static/js/searchable_select.js +++ b/static/js/searchable_select.js @@ -1,6 +1,16 @@ +// Tom Select moves the field's label to its own box: the hidden of many users or VMs gets a search box (Tom Select). document.querySelectorAll("select[data-searchable]").forEach(function (select) { new TomSelect(select, { + onInitialize: labelOriginal, // the box leaves its focused, taller look at once: else the next tap's // button moves away under the finger on a phone onItemAdd: function () { this.blur(); }, @@ -19,6 +29,7 @@ function isTagName(input) { } document.querySelectorAll("select[data-tags]").forEach(function (select) { new TomSelect(select, { + onInitialize: labelOriginal, create: function (input) { return {value: tagName(input), text: tagName(input)}; }, diff --git a/storages/templates/storage.html b/storages/templates/storage.html index ed034dbe..a183550e 100644 --- a/storages/templates/storage.html +++ b/storages/templates/storage.html @@ -113,7 +113,7 @@
{% elif volumes %}
-
{% trans "Volumes" %}
+

{% trans "Volumes" %}

{% if users_read %} diff --git a/templates/base.html b/templates/base.html index 12c6d2da..a77ae4a3 100644 --- a/templates/base.html +++ b/templates/base.html @@ -30,10 +30,12 @@ {% if request.user.is_authenticated %} + {# for the keyboard: past the menu, shown when it has the focus #} + {% trans "Skip to content" %} {% include 'navbar.html' %} {% endif %} -
+
{% block page_header %}{# a page with a heading of its own leaves it out #}
@@ -41,10 +43,10 @@ {% block page_heading_extra %} {% endblock page_heading_extra %}
-

+

{% block page_heading %} {% endblock page_heading %} -

+
{% endblock page_header %} diff --git a/templates/common/confirm_delete.html b/templates/common/confirm_delete.html index 90316a67..a28da5eb 100644 --- a/templates/common/confirm_delete.html +++ b/templates/common/confirm_delete.html @@ -6,7 +6,7 @@ {% block page_header %}
-

{% trans "Delete" %} {{ object }}

+

{% trans "Delete" %} {{ object }}

{% endblock page_header %} diff --git a/templates/common/form.html b/templates/common/form.html index 52463612..ea6d1441 100644 --- a/templates/common/form.html +++ b/templates/common/form.html @@ -11,7 +11,7 @@ {% block page_header %}
-

{{ title }}

+

{{ title }}

{% endblock page_header %} diff --git a/templates/error.html b/templates/error.html index 1bfb489a..8fedca35 100644 --- a/templates/error.html +++ b/templates/error.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load i18n %} +{% block page_header %}{% endblock page_header %}{# the page has its own heading #} {% block content %}
diff --git a/webvirtcloud/tests/test_pages.py b/webvirtcloud/tests/test_pages.py index ac2896fa..d05eb1a4 100644 --- a/webvirtcloud/tests/test_pages.py +++ b/webvirtcloud/tests/test_pages.py @@ -72,6 +72,24 @@ class PageTests(TestCase): with self.subTest(page=name): self.assertEqual({i: n for i, n in ids.items() if n > 1}, {}) + def test_every_page_has_one_main_heading_and_no_empty_one(self): + # screen readers go to a page's h1; an empty heading is read as nothing. Not + # pages of the panel: a tab's fragment, the cloud-init data source, the API docs + parts = {"instances:host_devices", "ds_openstack_index", "schema-redoc", "schema-swagger-ui"} + for name, page in self.pages(): + if name in parts: + continue + headings = page.xpath("//h1|//h2|//h3|//h4|//h5|//h6") + with self.subTest(page=name): + self.assertEqual(len(page.xpath("//h1")), 1) + # a dialog title is filled in when the dialog opens + self.assertEqual([h.tag for h in headings if not h.text_content().strip() and "modal-title" not in h.get("class", "")], []) + + def test_an_error_page_has_one_main_heading(self): + self.client.force_login(get_user_model().objects.create_superuser("err", "err@example.com", "pw")) + page = html.fromstring(self.client.get("/no-such-page/").content) + self.assertEqual([h.text_content().strip() != "" for h in page.xpath("//h1")], [True]) + def test_every_table_scrolls_in_its_own_box(self): # a wide table scrolls inside .table-responsive instead of widening the page on a phone for name, page in self.pages():