Enable strict accessibility toggle on navbar and homepage.

This commit is contained in:
Greg Sarjeant 2025-06-23 09:21:51 -04:00
parent 35033e50a6
commit d4f6b16756
4 changed files with 27 additions and 12 deletions

View File

@ -17,10 +17,12 @@ class Util {
return preg_replace_callback(
'~(https?://[^\s<>"\'()]+)~i',
function($matches) use ($link_attrs) {
global $config;
$escaped_url = rtrim($matches[1], '.,!?;:)]}>');
$clean_url = html_entity_decode($escaped_url, ENT_QUOTES, 'UTF-8');
$tabIndex = $config->strictAccessibility ? ' tabindex="0" ' : ' ';
return '<a tabindex="0" href="' . $clean_url . '"' . $link_attrs . '>' . $escaped_url . '</a>';
return '<a' . $tabIndex . 'href="' . $clean_url . '"' . $link_attrs . '>' . $escaped_url . '</a>';
},
$text
);

View File

@ -22,10 +22,12 @@ class HomeView {
</ul>
<div class="tick-pagination">
<?php if ($page > 1): ?>
<a tabindex="0" href="?page=<?php echo $page - 1 ?>">&laquo; Newer</a>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="?page=<?php echo $page - 1 ?>">&laquo; Newer</a>
<?php endif; ?>
<?php if (count($ticks) === $limit): ?>
<a tabindex="0" href="?page=<?php echo $page + 1 ?>">Older &raquo;</a>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="?page=<?php echo $page + 1 ?>">Older &raquo;</a>
<?php endif; ?>
</div>

View File

@ -12,7 +12,10 @@
<span class="profile-greeting-content-mood"><?php echo Util::escape_html($user->mood) ?></span>
</span>
<?php if (Session::isLoggedIn()): ?>
<a tabindex="0" href="<?= Util::escape_html($config->basePath) ?>mood" class="change-mood">Change mood</a>
<a
<?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="<?= Util::escape_html($config->basePath) ?>mood"
class="change-mood">Change mood</a>
<?php endif ?>
</dd>
<?php if (!empty($user->about)): ?>

View File

@ -1,25 +1,33 @@
<?php /** @var ConfigModel $config */ ?>
<?php /* https://www.w3schools.com/howto/howto_css_dropdown.asp */ ?>
<nav aria-label="Main navigation">
<a tabindex="0" href="<?= Util::escape_html($config->basePath) ?>">home</a>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="<?= Util::escape_html($config->basePath) ?>">home</a>
<details>
<summary aria-haspopup="true">feeds</summary>
<div class="dropdown-items">
<a tabindex="0" href="<?= Util::escape_html($config->basePath) ?>feed/rss">rss</a>
<a tabindex="0" href="<?= Util::escape_html($config->basePath) ?>feed/atom">atom</a>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="<?= Util::escape_html($config->basePath) ?>feed/rss">rss</a>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="<?= Util::escape_html($config->basePath) ?>feed/atom">atom</a>
</div>
</details>
<?php if (!Session::isLoggedIn()): ?>
<a tabindex="0" href="<?= Util::escape_html($config->basePath) ?>login">login</a>
<a tabindex="0"
href="<?= Util::escape_html($config->basePath) ?>login">login</a>
<?php else: ?>
<details>
<summary aria-haspopup="true">admin</summary>
<div class="dropdown-items">
<a tabindex="0" href="<?= Util::escape_html($config->basePath) ?>admin">settings</a>
<a tabindex="0" href="<?= Util::escape_html($config->basePath) ?>admin/css">css</a>
<a tabindex="0" href="<?= Util::escape_html($config->basePath) ?>admin/emoji">emoji</a>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="<?= Util::escape_html($config->basePath) ?>admin">settings</a>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="<?= Util::escape_html($config->basePath) ?>admin/css">css</a>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="<?= Util::escape_html($config->basePath) ?>admin/emoji">emoji</a>
</div>
</details>
<a tabindex="0" href="<?= Util::escape_html($config->basePath) ?>logout">logout</a>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="<?= Util::escape_html($config->basePath) ?>logout">logout</a>
<?php endif; ?>
</nav>