mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2026-09-10 21:26:48 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d7149b83e9 | |||
| e00ff9437c |
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## [2.1.1] - 2026-09-10
|
||||
|
||||
* Accessibility: header icons are *aria-hidden*, links read by label alone
|
||||
* Test coverage: unit test requires *aria-hidden* on every header icon
|
||||
|
||||
## [2.1.0] - 2026-08-22
|
||||
|
||||
* Multilingual site: every ISO 639-1 language has its own URL, */* follows the visitor's browser language, and a switcher in the navbar lists all 184 in their own script
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% macro render_icon_and_name(item) %}
|
||||
<i class="{{ item.icon.class if item.icon is defined and item.icon.class is defined else 'fa-solid fa-link' }}"></i>
|
||||
<i class="{{ item.icon.class if item.icon is defined and item.icon.class is defined else 'fa-solid fa-link' }}" aria-hidden="true"></i>
|
||||
{% if item.name is defined %}
|
||||
{{ item.name }}
|
||||
{% else %}
|
||||
@@ -101,7 +101,7 @@
|
||||
{% if menu_type == "header" %}
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle btn btn-light" id="navbarDropdownLanguage" role="button" data-bs-toggle="dropdown" data-bs-display="dynamic" aria-expanded="false" title="{{ t('Language') }}">
|
||||
<i class="fa-solid fa-language"></i> {{ languages[lang] }}
|
||||
<i class="fa-solid fa-language" aria-hidden="true"></i> {{ languages[lang] }}
|
||||
</a>
|
||||
<ul class="dropdown-menu language-menu">
|
||||
{% for code, endonym in languages.items() %}
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "portfolio-ui"
|
||||
version = "2.1.0"
|
||||
version = "2.1.1"
|
||||
description = "A lightweight YAML-driven portfolio and landing-page generator."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
@@ -9,14 +9,46 @@ class AnchorCollector(HTMLParser):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.anchors = []
|
||||
self.icons = []
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag == "a":
|
||||
self.anchors.append(dict(attrs))
|
||||
if tag == "i":
|
||||
self.icons.append(dict(attrs))
|
||||
|
||||
|
||||
class TestNavigationTemplate(unittest.TestCase):
|
||||
def test_top_level_dropdowns_have_bootstrap_toggle_attribute(self):
|
||||
parser = self._render_header()
|
||||
dropdown_toggles = [
|
||||
anchor
|
||||
for anchor in parser.anchors
|
||||
if "nav-link" in anchor.get("class", "")
|
||||
and "dropdown-toggle" in anchor.get("class", "")
|
||||
]
|
||||
|
||||
self.assertEqual(len(dropdown_toggles), 2)
|
||||
for toggle in dropdown_toggles:
|
||||
self.assertEqual(toggle.get("data-bs-toggle"), "dropdown")
|
||||
|
||||
language_links = [
|
||||
anchor for anchor in parser.anchors if anchor.get("hreflang") == "de"
|
||||
]
|
||||
self.assertEqual(len(language_links), 1)
|
||||
self.assertEqual(language_links[0]["href"], "/de/")
|
||||
|
||||
def test_menu_icons_stay_out_of_the_accessible_name(self):
|
||||
parser = self._render_header()
|
||||
|
||||
self.assertTrue(parser.icons)
|
||||
self.assertEqual(
|
||||
[icon for icon in parser.icons if icon.get("aria-hidden") != "true"],
|
||||
[],
|
||||
"a Font Awesome glyph without aria-hidden joins the link's accessible name",
|
||||
)
|
||||
|
||||
def _render_header(self):
|
||||
template_dir = Path(__file__).resolve().parents[2] / "app" / "templates"
|
||||
environment = Environment(
|
||||
loader=FileSystemLoader(template_dir),
|
||||
@@ -68,22 +100,7 @@ class TestNavigationTemplate(unittest.TestCase):
|
||||
|
||||
parser = AnchorCollector()
|
||||
parser.feed(rendered)
|
||||
dropdown_toggles = [
|
||||
anchor
|
||||
for anchor in parser.anchors
|
||||
if "nav-link" in anchor.get("class", "")
|
||||
and "dropdown-toggle" in anchor.get("class", "")
|
||||
]
|
||||
|
||||
self.assertEqual(len(dropdown_toggles), 2)
|
||||
for toggle in dropdown_toggles:
|
||||
self.assertEqual(toggle.get("data-bs-toggle"), "dropdown")
|
||||
|
||||
language_links = [
|
||||
anchor for anchor in parser.anchors if anchor.get("hreflang") == "de"
|
||||
]
|
||||
self.assertEqual(len(language_links), 1)
|
||||
self.assertEqual(language_links[0]["href"], "/de/")
|
||||
return parser
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user