Skip to content

Commit 50a6867

Browse files
merwokm-aciek
andauthored
avoid identical text for all links (#155)
* avoid identical text for all links * rework things - move logic from template to code - use list instead of decorative characters (style tbd) - use aria labels to distinguish identical links * style * fix test * drop now not needed paragraph tags --------- Co-authored-by: Maciej Olko <maciej.olko@gmail.com>
1 parent d11dacb commit 50a6867

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

contribute.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ def get_contrib_link(language: str, repo: str | None) -> str | None:
2222
and 'https://explore.transifex.com/python-doc/python-newest/'
2323
)
2424
or (repo and f'https://github.com/{repo}')
25+
or 'https://devguide.python.org/documentation/translations/translating/'
2526
)

generate.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def get_project_data(
8181
change,
8282
built,
8383
translated_name=languages_built.get(language.code, ''),
84-
uses_platform=language.code in contribute.pulling_from_transifex,
8584
contribution_link=contribute.get_contrib_link(language.code, repo),
8685
)
8786

@@ -95,7 +94,6 @@ class LanguageProjectData:
9594
change: float
9695
built: bool
9796
translated_name: str
98-
uses_platform: bool
9997
contribution_link: str | None
10098

10199

src/style.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ body {
9090
background-color: #f5e9a8;
9191
}
9292

93+
ul.links-row {
94+
display: flex;
95+
padding-left: 0;
96+
list-style: none;
97+
}
98+
ul.links-row li:not(:first-child) {
99+
padding-left: 1ch;
100+
}
101+
ul.links-row li:not(:first-child)::before {
102+
content: '•';
103+
margin-right: 0.5ch;
104+
}
105+
93106
/* ------------------------------ Index ------------------------------------- */
94107

95108
.progress-bar-container {

templates/index.html.jinja

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
<p class="text-muted">Completion: <strong>{{ '{:.2f}%'.format(project.completion) }}</strong></p>
1313
<p class="text-muted">30-day progress: {{ '{:.2f}%'.format(project.change) }}</p>
1414

15-
<p style="text-align: center;">
15+
<ul class="links-row">
1616
{% if project.built %}
17-
<a href="https://docs.python.org/{{ project.language.code }}/3/" style="color: #1178cc;">View</a>
18-
17+
<li>
18+
<a href="https://docs.python.org/{{ project.language.code }}/3/" aria-label="View {{ project.language.name }} documentation"
19+
style="color: #1178cc;">View</a>
20+
</li>
1921
{% endif %}
20-
{% if project.contribution_link %}
21-
<a href="{{ project.contribution_link }}" style="color: #1178cc;">Contribute</a>
22-
{% elif project.uses_platform %}
23-
<a href="https://app.transifex.com/join/?o=python-doc&p=python-newest&t=opensource" style="color: #1178cc;">Contribute</a>
24-
{% else %}
25-
<a href="https://devguide.python.org/documentation/translations/translating/" style="color: #1178cc;">Contribute</a>
26-
{% endif %}
27-
</p>
22+
<li>
23+
<a href="{{ project.contribution_link }}" style="color: #1178cc;" aria-label="Contribute to {{ project.language.name }} translation">
24+
Contribute
25+
</a>
26+
</li>
27+
</ul>
2828
<div class="progress-bar-container">
2929
<div class="progress-bar" style="width: {{ project.completion }}%;
3030
{% if project.change %}

tests/test_contribute.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
class testContributeLink(unittest.TestCase):
1010
def test_get_contrib_link(self):
1111
PULL_FROM_TX = 'https://explore.transifex.com/python-doc/python-newest/'
12+
DEVGUIDE = 'https://devguide.python.org/documentation/translations/translating/'
1213

1314
for code, repo, expected in (
14-
('en', None, None),
15+
('en', None, DEVGUIDE),
1516
('pl', None, PULL_FROM_TX),
1617
('ar', 'python/python-docs-ar', 'https://github.com/python/python-docs-ar'),
1718
(

0 commit comments

Comments
 (0)