web: Unify _link and _url variable suffixes

This commit is contained in:
Franciszek Stachura 2025-02-14 11:51:45 +01:00 committed by Théo Lebrun
parent 0f0695e09c
commit fc8106d520
5 changed files with 18 additions and 18 deletions

View file

@ -40,12 +40,12 @@ from .autocomplete import AutocompleteResource
from .api import ApiIdentGetterResource
from .query import get_query
from .web_utils import ProjectConverter, IdentConverter, validate_version, validate_project, validate_ident, \
get_elixir_version_string, get_elixir_repo_link, RequestContext, Config
get_elixir_version_string, get_elixir_repo_url, RequestContext, Config
VERSION_CACHE_DURATION_SECONDS = 2 * 60 # 2 minutes
ADD_ISSUE_LINK = "https://github.com/bootlin/elixir/issues/new"
ELIXIR_VERSION_STRING = get_elixir_version_string()
ELIXIR_REPO_LINK = get_elixir_repo_link(ELIXIR_VERSION_STRING)
ELIXIR_REPO_LINK = get_elixir_repo_url(ELIXIR_VERSION_STRING)
DEFAULT_PROJECT = 'linux'
@ -70,7 +70,7 @@ def generate_error_details(req, resp, title, details):
f"Error title: {title}\n" + \
f"Error details: {details}\n"
def get_github_issue_link(details: str):
def get_github_issue_url(details: str):
body = ("TODO: add information on how you reached the error here and " +
"validate the details below.\n\n" +
"---\n\n" +
@ -90,10 +90,10 @@ def get_project_error_page(req, resp, exception: ElixirProjectError):
'current_family': 'A',
'source_base_url': '/',
'elixir_version_string': req.context.config.version_string,
'elixir_repo_link': req.context.config.repo_link,
'elixir_repo_url': req.context.config.repo_url,
'referer': req.referer if req.referer != req.uri else None,
'bug_report_link': get_github_issue_link(report_error_details),
'bug_report_url': get_github_issue_url(report_error_details),
'home_page_url': '/',
'report_error_details': report_error_details,
@ -157,7 +157,7 @@ def get_error_page(req, resp, exception: ElixirProjectError):
'source_base_url': '/',
'referer': req.referer,
'bug_report_link': ADD_ISSUE_LINK + parse.quote(report_error_details),
'bug_report_url': ADD_ISSUE_LINK + parse.quote(report_error_details),
'report_error_details': report_error_details,
'error_title': exception.title,
@ -458,7 +458,7 @@ def get_layout_template_context(q: Query, ctx: RequestContext, get_url_with_new_
'current_version_path': current_version_path,
'topbar_families': TOPBAR_FAMILIES,
'elixir_version_string': ctx.config.version_string,
'elixir_repo_link': ctx.config.repo_link,
'elixir_repo_url': ctx.config.repo_url,
'source_base_url': get_source_base_url(project, version),
'ident_base_url': get_ident_base_url(project, version),
@ -602,10 +602,10 @@ def generate_source_page(ctx: RequestContext, q: Query,
# Generate breadcrumbs
path_split = path.split('/')[1:]
path_temp = ''
breadcrumb_links = []
breadcrumb_urls = []
for p in path_split:
path_temp += '/'+p
breadcrumb_links.append((p, f'{ source_base_url }{ path_temp }'))
breadcrumb_urls.append((p, f'{ source_base_url }{ path_temp }'))
if type == 'tree':
back_path = os.path.dirname(path[:-1])
@ -627,7 +627,7 @@ def generate_source_page(ctx: RequestContext, q: Query,
raise ElixirProjectError('File not found', 'This file does not exist.',
status=falcon.HTTP_NOT_FOUND,
query=q, project=project, version=version,
extra_template_args={'breadcrumb_links': breadcrumb_links})
extra_template_args={'breadcrumb_urls': breadcrumb_urls})
# Create titles like this:
# root path: "Linux source code (v5.5.6) - Bootlin"
@ -648,7 +648,7 @@ def generate_source_page(ctx: RequestContext, q: Query,
'title_path': title_path,
'path': path,
'breadcrumb_links': breadcrumb_links,
'breadcrumb_urls': breadcrumb_urls,
**template_ctx,
}

View file

@ -33,7 +33,7 @@ def get_elixir_version_string():
return ''
def get_elixir_repo_link(version):
def get_elixir_repo_url(version):
if re.match('^[0-9a-f]{5,12}$', version) or version.startswith('v'):
return ELIXIR_REPO_LINK + f'tree/{ version }'
else:
@ -43,7 +43,7 @@ def get_elixir_repo_link(version):
class Config(NamedTuple):
project_dir: str
version_string: str
repo_link: str
repo_url: str
# Basic information about handled request - current Elixir configuration, configured Jinja environment
# and logger

View file

@ -16,9 +16,9 @@
{% if referer is not none -%}
<li><a class="link" href="{{ referer }}">Go back</a></li>
{%- endif %}
<li><a class="link" href="{{ home_page_link }}">Go to home page</a></li>
{% if bug_report_link is not none -%}
<li><a class="link" href="{{ bug_report_link }}">Report a bug</a></li>
<li><a class="link" href="{{ home_page_url }}">Go to home page</a></li>
{% if bug_report_url is not none -%}
<li><a class="link" href="{{ bug_report_url }}">Report a bug</a></li>
{%- endif %}
</ul>
{% if report_error_details is not none -%}

View file

@ -69,7 +69,7 @@
Top
</a>
<span class="poweredby">powered by
<a target="_blank" href="{{ elixir_repo_link }}">
<a target="_blank" href="{{ elixir_repo_url }}">
Elixir {{ elixir_version_string }}
</a>
</span>

View file

@ -2,7 +2,7 @@
<div class="breadcrumb">
<a href="#menu" class="open-menu icon-menu screenreader" title="Open Menu">Open Menu</a>
<a class="project" href="{{ source_base_url }}">/</a>
{% for name, url in breadcrumb_links %}
{% for name, url in breadcrumb_urls %}
<a href="{{ url }}">{{ name }}</a>
{{ '/' if not loop.last else '' }}
{% endfor %}