Skip to content

Commit a0d0686

Browse files
committed
a11y: #4232 nested template heading level logic
1 parent df00f0a commit a0d0686

File tree

24 files changed

+174
-57
lines changed

24 files changed

+174
-57
lines changed

src/templates/common/elements/guest_editors.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{% if issue.editors.all %}
22
<p>
33
{% if small %}<small>{% endif %}
4-
<h2>Editors: </h2>
4+
{% if level == "issuepage" %}
5+
<h2>Editors: </h2>
6+
{% else %}
7+
<h3>Editors: </h3>
8+
{% endif %}
59
{% for editor in issue.issueeditor_set.all %}{{ editor.account.full_name }} ({{ editor.role }}){% if not forloop.last %}, {% endif %}{% endfor %}
610
{% if small %}</small>{% endif %}
711
</p>

src/templates/common/elements/journal/article_issue_list.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load i18n %}
22

33
{% with issue_length=article.issues_list|length %}
4-
{# HeadingA11y Clash #} <h2>{% if issue_length > 1 %}{% trans 'Issues' %}{% else %}{% trans 'Issue' %}{% endif %}</h2>
4+
<h2>{% if issue_length > 1 %}{% trans 'Issues' %}{% else %}{% trans 'Issue' %}{% endif %}</h2>
55
{% endwith %}
66
<ul>
77
{% if article.primary_issue %}

src/themes/OLH/templates/core/accounts/public_profile.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ <h2>{% trans "Biography" %}</h2>
5151
<h2>{% trans "Publications" %}</h2>
5252
<hr />
5353
{% for article in user.published_articles %}
54-
{% include "elements/journal/box_article.html" with article=article %}
54+
{% include "elements/journal/box_article.html" with article=article level="shallow" %}
5555
<hr />
5656
{% endfor %}
5757
{% endif %}

src/themes/OLH/templates/elements/journal/box_article.html

+24-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,30 @@
2222
<i aria-hidden="true" class="float-right fa fa-thumb-tack"></i>
2323
<span class="sr-only">{% trans 'Pinned' %}</span>
2424
{% endif %}
25-
{# HeadingA11y Clash #} <h2>{{ article.title|safe }}
26-
{% if article.is_remote %}
27-
&nbsp;<i aria-hidden="true" class="fa fa-external-link small-icon-text"></i>
28-
<span class="sr-only">, {% trans 'externally hosted article' %}.</span>
29-
{% endif %}
30-
</h2>
25+
26+
{% if level == "deep" %}
27+
<h4>{{ article.title|safe }}
28+
{% if article.is_remote %}
29+
&nbsp;<i aria-hidden="true" class="fa fa-external-link small-icon-text"></i>
30+
<span class="sr-only">, {% trans 'externally hosted article' %}.</span>
31+
{% endif %}
32+
</h4>
33+
{% elif level == "shallow" %}
34+
<h3>{{ article.title|safe }}
35+
{% if article.is_remote %}
36+
&nbsp;<i aria-hidden="true" class="fa fa-external-link small-icon-text"></i>
37+
<span class="sr-only">, {% trans 'externally hosted article' %}.</span>
38+
{% endif %}
39+
</h3>
40+
{% else %}
41+
<h2>{{ article.title|safe }}
42+
{% if article.is_remote %}
43+
&nbsp;<i aria-hidden="true" class="fa fa-external-link small-icon-text"></i>
44+
<span class="sr-only">, {% trans 'externally hosted article' %}.</span>
45+
{% endif %}
46+
</h2>
47+
{% endif %}
48+
3149
{% include "elements/journal/authors_block.html" %}
3250
<p>
3351
<span class="date">

src/themes/OLH/templates/elements/journal/issue_block.html

+23-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,31 @@
22
<div>
33
{% regroup articles by section as grouped_articles %}
44
{% for section, section_articles in grouped_articles %}
5-
{# HeadingA11y Clash #} <h2 class="em">
6-
{% if section.plural and section_articles|length >= 2 %}
7-
{{ section.plural }}
8-
{% else %}
9-
{{ section.name }}
10-
{% endif %}
11-
</h2>
5+
{% if level == "deep" %}
6+
<h3 class="em">
7+
{% if section.plural and section_articles|length >= 2 %}
8+
{{ section.plural }}
9+
{% else %}
10+
{{ section.name }}
11+
{% endif %}
12+
</h3>
13+
{% else %}
14+
<h2 class="em">
15+
{% if section.plural and section_articles|length >= 2 %}
16+
{{ section.plural }}
17+
{% else %}
18+
{{ section.name }}
19+
{% endif %}
20+
</h2>
21+
{% endif %}
22+
1223
<hr>
1324
{% for article in section_articles %}
14-
{% include "elements/journal/box_article.html" with article=article %}
25+
{% if level == "deep" %}
26+
{% include "elements/journal/box_article.html" with article=article level=level %}
27+
{% else %}
28+
{% include "elements/journal/box_article.html" with article=article level="shallow" %}
29+
{% endif %}
1530
{% endfor %}
1631
{% endfor %}
1732
</div>

src/themes/OLH/templates/elements/journal/issue_top.html

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
alt="{{ issue.display_title }}">
99
<div class="row column">
1010
<figcaption class="orbit-caption">
11-
{# HeadingA11y Clash #} <h1>{{ issue.display_title }}</h1>
11+
{% if level == "deep" %}
12+
<h2>{{ issue.display_title }}</h2>
13+
{% else %}
14+
<h1>{{ issue.display_title }}</h1>
15+
{% endif %}
1216
</figcaption>
1317
</div>
1418
</li>
@@ -17,7 +21,11 @@
1721
<br/>
1822
{% if issue.issue_description %}<p>{{ issue.issue_description|safe }}</p>{% endif %}
1923
{% else %}
20-
{# HeadingA11y Clash #} <h1 class="em">{{ issue.display_title }}</h1>
24+
{% if level == "deep" %}
25+
<h2 class="em">{{ issue.display_title }}</h2>
26+
{% else %}
27+
<h1 class="em">{{ issue.display_title }}</h1>
28+
{% endif %}
2129
{% if issue.issue_description %}<p>{{ issue.issue_description|safe }}</p>{% endif %}
2230
{% endif %}
2331

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<section>
1+
<section aria-label="{% trans 'Current Issue' %}">
22
<div class="row">
33
<div class="columns">
4-
{% include 'elements/journal/issue_top.html' %}
5-
{% include 'elements/journal/issue_block.html' %}
4+
{% include 'elements/journal/issue_top.html' with level="deep" %}
5+
{% include 'elements/journal/issue_block.html' with level="deep" %}
66
</div>
77
</div>
88
</section>

src/themes/OLH/templates/journal/search.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h1>{% trans 'All Articles' %}</h1>
3131
<h2>{% trans "Articles" %}</h2>
3232

3333
{% for article in articles %}
34-
{% include "elements/journal/box_article.html" with article=article %}
34+
{% include "elements/journal/box_article.html" with article=article level="shallow" %}
3535
{% endfor %}
3636

3737
</div>

src/themes/clean/templates/core/accounts/public_profile.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h2>{% trans "Biography" %}</h2>
2525
<h2>{% trans "Publications" %}</h2>
2626
<hr />
2727
{% for article in user.published_articles %}
28-
{% include "elements/article_listing.html" with article=article %}
28+
{% include "elements/article_listing.html" with article=article level="shallow" %}
2929
<hr />
3030
{% endfor %}
3131
{% endif %}

src/themes/clean/templates/elements/article_listing.html

+26-6
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,33 @@
2121
<div class="col article-block">
2222
<a href="{% if article.is_remote %}{{ article.remote_url }}{% else %}{{ article.url }}{% endif %}">
2323
{% if article.is_remote %}
24-
{# HeadingA11y Clash #} <h4 class="card-title article-title">
25-
<span class="sr-only">{% trans 'Externally hosted article' %}: </span>
26-
{{ article.title|safe }}&nbsp;
27-
<i aria-hidden="true" class="fa fa-external-link small-icon-text"></i>
28-
</h4>
24+
{% if level == "deep" %}
25+
<h4 class="card-title article-title">
26+
<span class="sr-only">{% trans 'Externally hosted article' %}: </span>
27+
{{ article.title|safe }}&nbsp;
28+
<i aria-hidden="true" class="fa fa-external-link small-icon-text"></i>
29+
</h4>
30+
{% elif level == "shallow" %}
31+
<h3 class="card-title article-title">
32+
<span class="sr-only">{% trans 'Externally hosted article' %}: </span>
33+
{{ article.title|safe }}&nbsp;
34+
<i aria-hidden="true" class="fa fa-external-link small-icon-text"></i>
35+
</h3>
36+
{% else %}
37+
<h2 class="card-title article-title">
38+
<span class="sr-only">{% trans 'Externally hosted article' %}: </span>
39+
{{ article.title|safe }}&nbsp;
40+
<i aria-hidden="true" class="fa fa-external-link small-icon-text"></i>
41+
</h2>
42+
{% endif %}
2943
{% else %}
30-
{# HeadingA11y Clash #} <h4 class="card-title article-title">{{ article.title|safe }}</h4>
44+
{% if level == "deep" %}
45+
<h4 class="card-title article-title">{{ article.title|safe }}</h4>
46+
{% elif level == "shallow" %}
47+
<h3 class="card-title article-title">{{ article.title|safe }}</h3>
48+
{% else %}
49+
<h2 class="card-title article-title">{{ article.title|safe }}</h2>
50+
{% endif %}
3151
{% endif %}
3252
</a>
3353
<p class="card-subtitle mb-2 text-muted">{% for author in article.frozen_authors.all %}{% if forloop.last %}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
{% regroup articles by section as grouped_articles %}
22
{% for section, section_articles in grouped_articles %}
3-
{# HeadingA11y Clash #} <h3 class="em">
3+
4+
{% if level == "deep" %}
5+
<h3 class="em">
46
{% if section.plural and section_articles|length >= 2 %}
57
{{ section.plural }}
68
{% else %}
79
{{ section.name }}
810
{% endif %}
911
</h3>
12+
{% else %}
13+
<h2 class="em">
14+
{% if section.plural and section_articles|length >= 2 %}
15+
{{ section.plural }}
16+
{% else %}
17+
{{ section.name }}
18+
{% endif %}
19+
</h2>
20+
{% endif %}
21+
1022
{% for article in section_articles %}
11-
{% include "elements/article_listing.html" with article=article %}
23+
{% include "elements/article_listing.html" with article=article level=level %}
1224
{% endfor %}
1325
{% endfor %}

src/themes/clean/templates/elements/journal/issue_top.html

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@
55
<img class="card-img img-fluid article-img" src="{{ issue.hero_image_url }}" alt="{{ issue.display_title }} Cover Image">
66
<div class="card-img-overlay white-text">
77
<div class="card-text">
8-
{# HeadingA11y Clash #} <h2 class="card-title">{{ issue.display_title }}</h2>
8+
{% if level == "deep" %}
9+
<h2 class="card-title">{{ issue.display_title }}</h2>
10+
{% else %}
11+
<h1 class="card-title">{{ issue.display_title }}</h1>
12+
{% endif %}
913
</div>
1014
</div>
1115
</div>
1216
{% else %}
13-
{# HeadingA11y Clash #} <h2 class="em">{{ issue.display_title }}</h2>
17+
{% if level == "deep" %}
18+
<h2 class="em">{{ issue.display_title }}</h2>
19+
{% else %}
20+
<h1 class="em">{{ issue.display_title }}</h1>
21+
{% endif %}
1422
{% if issue.issue_description %}<p>{{ issue.issue_description|safe }}</p>{% endif %}
1523
{% endif %}
1624

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<section aria-label="{% trans 'Current Issue' %}">
2-
{% include 'elements/journal/issue_top.html' %}
3-
{% include 'elements/journal/issue_block.html' %}
2+
{% include 'elements/journal/issue_top.html' with level="deep" %}
3+
{% include 'elements/journal/issue_block.html' with level="deep" %}
44
</section>

src/themes/clean/templates/journal/issue_display.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<div class="row">
55
<div class="col-md-{% if not show_sidebar %}12{% else %}8 border-right{% endif %}" id="issue_top">
66

7-
{% include "elements/journal/issue_top.html" %}
8-
{% include "elements/journal/issue_block.html" %}
7+
{% include "elements/journal/issue_top.html" with level="shallow" %}
8+
{% include "elements/journal/issue_block.html" with level="shallow" %}
99
{% include "elements/journal/issue_paginator.html" %}
1010

1111

src/themes/material/templates/core/accounts/public_profile.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h2>{% trans "Biography" %}</h2>
2525
<h2>{% trans "Publications" %}</h2>
2626
<hr />
2727
{% for article in user.published_articles %}
28-
{% include "elements/article_listing.html" with article=article %}
28+
{% include "elements/article_listing.html" with article=article level="deep" %}
2929
<hr />
3030
{% endfor %}
3131
{% endif %}

src/themes/material/templates/elements/article_listing.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919
{% endif %}
2020
<div class="col m{% if not journal_settings.article.disable_article_thumbnails %}10{% else %}12{% endif %} s12">
2121
<a href="{% if article.is_remote %}{{ article.remote_url }}{% else %}{{ article.url }}{% endif %}">
22-
{# HeadingA11y Clash #} <h2 class="article-title">{{ article.title|safe }}</h2>
22+
{% if level == "issuepage" %}
23+
<h3 class="article-title">{{ article.title|safe }}</h3>
24+
{% elif level == "deep" %}
25+
<h4 class="article-title">{{ article.title|safe }}</h4>
26+
{% else %}
27+
<h2 class="article-title">{{ article.title|safe }}</h2>
28+
{% endif %}
2329
</a>
2430
<p>{% for author in article.frozen_authors.all %}{% if forloop.last %}
2531
{% if article.frozen_authors.all|length > 1 %} {% trans "and" %}

src/themes/material/templates/elements/journal/issue_block.html

+21-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,28 @@
22

33
{% regroup articles by section as grouped_articles %}
44
{% for section, section_articles in grouped_articles %}
5-
<h2 class="em">
6-
{% if section.plural and section_articles|length >= 2 %}
7-
{{ section.plural }}
5+
{% if level == "issuepage" %}
6+
<h2 class="em">
7+
{% if section.plural and section_articles|length >= 2 %}
8+
{{ section.plural }}
9+
{% else %}
10+
{{ section.name }}
11+
{% endif %}
12+
</h2>
13+
{% else %}
14+
<h3 class="em">
15+
{% if section.plural and section_articles|length >= 2 %}
16+
{{ section.plural }}
17+
{% else %}
18+
{{ section.name }}
19+
{% endif %}
20+
</h3>
21+
{% endif %}
22+
{% for article in section_articles %}
23+
{% if level == "issuepage" %}
24+
{% include "elements/article_listing.html" with article=article level=level %}
825
{% else %}
9-
{{ section.name }}
26+
{% include "elements/article_listing.html" with article=article level="deep" %}
1027
{% endif %}
11-
</h2>
12-
{% for article in section_articles %}
13-
{% include "elements/article_listing.html" with article=article %}
1428
{% endfor %}
1529
{% endfor %}

src/themes/material/templates/elements/journal/issue_list.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
<div class="col m12 l6 xl4">
44
<div class="card horizontal">
55
<div class="card-image">
6-
{# HeadingA11y Clash #} <h3 class="sr-only">{{ issue.display_title }}</h3>
6+
{% if level == "deep" %}
7+
<h3 class="sr-only">{{ issue.display_title }}</h3>
8+
{% else %}
9+
<h2 class="sr-only">{{ issue.display_title }}</h2>
10+
{% endif %}
711
<a href="{% url 'journal_issue' issue.id %}"><img
812
class="issue_image" src="
913
{% if issue.cover_image %}{{ issue.cover_image.url }}{% elif journal.default_cover_image %}{{ journal.default_cover_image.url }}{% else %}{% static "common/img/sample/issue_cover.png" %}{% endif %}"

src/themes/material/templates/elements/journal/issue_list_by_decade.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ <h2 id="decade-{{ decade }}">{{ decade }}</h2>
2020
</div>
2121
<div class="row">
2222
<div class="large-12 columns">
23-
{% include "elements/journal/issue_list.html" with issues=issues %}
23+
{% include "elements/journal/issue_list.html" with issues=issues level="deep" %}
2424
</div>
2525
</div>
2626

src/themes/material/templates/elements/journal/issue_top.html

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{% load i18n %}
22

33
{% if issue.large_image %}
4-
<h1 class="sr-only">{{ issue.display_title }}</h1>
4+
{% if level == "issuepage" %}
5+
<h1 class="sr-only">{{ issue.display_title }}</h1>
6+
{% else %}
7+
<h2 class="sr-only">{{ issue.display_title }}</h2>
8+
{% endif %}
59
<div class="card">
610
<div class="card-image">
711
<a href="{{ issue.url }}">
@@ -22,13 +26,17 @@ <h1 class="sr-only">{{ issue.display_title }}</h1>
2226
{% endif %}
2327
</div>
2428
{% else %}
25-
<h1>{{ issue.display_title }}</h1>
29+
{% if level == "issuepage" %}
30+
<h1>{{ issue.display_title }}</h1>
31+
{% else %}
32+
<h2>{{ issue.display_title }}</h2>
33+
{% endif %}
2634
{% if issue.issue_description %}<p>{{ issue.issue_description|safe }}</p>{% endif %}
2735
{% endif %}
2836

2937
{% if issue.journal.display_issue_doi and issue.doi_url %}
3038
<p><b>DOI: </b><a href="{{issue.doi_url}}">{{ issue.doi_url }}</a></p>
3139
{% endif %}
3240

33-
{% include "common/elements/guest_editors.html" %}
41+
{% include "common/elements/guest_editors.html" with level=level %}
3442
<br/>

src/themes/material/templates/journal/issue.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
{% endblock %}
1111

1212
{% block body %}
13-
{% include "journal/issue_display.html" %}
13+
{% include "journal/issue_display.html" with level="issuepage" %}
1414
{% endblock body %}

0 commit comments

Comments
 (0)