Skip to content

Commit 531529a

Browse files
fstachuratleb
authored andcommitted
web: Make "Go to home page" link to current version
If project and version is valid. Otherwise, redirect to latest or /.
1 parent 6edaafb commit 531529a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

elixir/web.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def get_project_error_page(req, resp, exception: ElixirProjectError):
9494

9595
'referer': req.referer if req.referer != req.uri else None,
9696
'bug_report_link': get_github_issue_link(report_error_details),
97+
'home_page_url': '/',
9798
'report_error_details': report_error_details,
9899

99100
'error_title': exception.title,
@@ -109,25 +110,24 @@ def get_project_error_page(req, resp, exception: ElixirProjectError):
109110
get_url_with_new_version = lambda v: stringify_source_path(project, v, '/')
110111
versions, current_version_path = get_versions(versions_raw, get_url_with_new_version, version)
111112

113+
if current_version_path[2] is None:
114+
# If details about current version are not available, make base links
115+
# point to latest.
116+
# current_tag is not set to latest to avoid latest being highlighted in the sidebar
117+
version = query.query('latest')
118+
112119
template_ctx = {
113120
**template_ctx,
114121

115122
'current_project': project,
123+
'current_tag': version,
116124
'versions': versions,
117125
'current_version_path': current_version_path,
118-
}
119-
120126

121-
if version is None:
122-
# If details about current version are not available, make base links
123-
# point to latest.
124-
# current_tag is not set to latest to avoid latest being highlighted in the sidebar
125-
version = query.query('latest')
126-
else:
127-
template_ctx['current_tag'] = version
128-
129-
template_ctx['source_base_url'] = get_source_base_url(project, version)
130-
template_ctx['ident_base_url'] = get_ident_base_url(project, version)
127+
'home_page_url': get_source_base_url(project, version),
128+
'source_base_url': get_source_base_url(project, version),
129+
'ident_base_url': get_ident_base_url(project, version),
130+
}
131131

132132
if exception.description is not None:
133133
template_ctx['error_details'] = exception.description

templates/error.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h2>{{ error_title }}</h2>
1616
{% if referer is not none -%}
1717
<li><a class="link" href="{{ referer }}">Go back</a></li>
1818
{%- endif %}
19-
<li><a class="link" href="/">Go to home page</a></li>
19+
<li><a class="link" href="{{ home_page_link }}">Go to home page</a></li>
2020
{% if bug_report_link is not none -%}
2121
<li><a class="link" href="{{ bug_report_link }}">Report a bug</a></li>
2222
{%- endif %}

0 commit comments

Comments
 (0)