Move topbar family list to web.py
This commit is contained in:
parent
ddf00119b8
commit
8932f26a22
2 changed files with 30 additions and 19 deletions
36
http/web.py
36
http/web.py
|
|
@ -205,6 +205,14 @@ def route(path, params):
|
|||
return (404, "Unknown path")
|
||||
|
||||
|
||||
TOPBAR_FAMILIES = {
|
||||
'A': 'All symbols',
|
||||
'C': 'C/CPP/ASM',
|
||||
'K': 'Kconfig',
|
||||
'D': 'Devicetree',
|
||||
'B': 'DT compatible',
|
||||
}
|
||||
|
||||
# Returns a list of names of top-level directories in basedir
|
||||
def get_directories(basedir):
|
||||
directories = []
|
||||
|
|
@ -427,7 +435,7 @@ def generate_source_page(q, basedir, parsed_path):
|
|||
breadcrumb_links.append((p, f'{ source_base_url }{ path_temp }'))
|
||||
|
||||
# Generate title
|
||||
title_suffix = project.capitalize()+' source code ('+version_unquoted+') - Bootlin'
|
||||
title_suffix = f'{ project.capitalize() } source code ({ version_unquoted }) - Bootlin'
|
||||
|
||||
# Create titles like this:
|
||||
# root path: "Linux source code (v5.5.6) - Bootlin"
|
||||
|
|
@ -442,18 +450,20 @@ def generate_source_page(q, basedir, parsed_path):
|
|||
|
||||
# Create template context
|
||||
data = {
|
||||
**template_ctx,
|
||||
'title': title,
|
||||
'projects': get_projects(basedir),
|
||||
'versions': get_versions(q.query('versions'), get_url_with_new_version),
|
||||
'topbar_families': TOPBAR_FAMILIES,
|
||||
|
||||
'source_base_url': source_base_url,
|
||||
'ident_base_url': f'/{ project }/{ version }/ident',
|
||||
'current_project': project,
|
||||
'current_tag': version_unquoted,
|
||||
'current_family': 'A',
|
||||
|
||||
'breadcrumb_links': breadcrumb_links,
|
||||
'title': title,
|
||||
|
||||
'versions': get_versions(q.query('versions'), get_url_with_new_version),
|
||||
'projects': get_projects(basedir),
|
||||
**template_ctx,
|
||||
}
|
||||
|
||||
return (status, template.render(data))
|
||||
|
|
@ -541,23 +551,23 @@ def generate_ident_page(q, basedir, parsed_path):
|
|||
if ident != '':
|
||||
status = 404
|
||||
|
||||
title_suffix = project.capitalize()+' source code ('+tag+') - Bootlin'
|
||||
title_suffix = f'{ project.capitalize() } source code { tag } - Bootlin'
|
||||
|
||||
get_url_with_new_version = lambda v: stringify_ident_path(parsed_path._replace(version=parse.quote(v, safe='')))
|
||||
|
||||
data = {
|
||||
'title': f'{ ident } identifier - { title_suffix }',
|
||||
'projects': get_projects(basedir),
|
||||
'versions': get_versions(q.query('versions'), get_url_with_new_version),
|
||||
'topbar_families': TOPBAR_FAMILIES,
|
||||
|
||||
'source_base_url': f'/{ project }/{ version }/source',
|
||||
'ident_base_url': f'/{ project }/{ version }/ident',
|
||||
'current_project': project,
|
||||
'current_tag': tag,
|
||||
|
||||
'ident': ident,
|
||||
'family': family,
|
||||
|
||||
'title': ident+' identifier - '+title_suffix,
|
||||
|
||||
'projects': get_projects(basedir),
|
||||
'versions': get_versions(q.query('versions'), get_url_with_new_version),
|
||||
'searched_ident': ident,
|
||||
'current_family': family,
|
||||
|
||||
'symbol_sections': symbol_sections,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,15 @@
|
|||
<div class="search">
|
||||
<form method="post" action="{{ ident_base_url }}">
|
||||
<select name="f" title="Restricts search to specific file families">
|
||||
<option value="A" {{ 'selected' if family == 'A' or family is not defined else '' }}>All symbols</option>
|
||||
<option value="C" {{ 'selected' if family == 'C' else '' }}>C/CPP/ASM</option>
|
||||
<option value="K" {{ 'selected' if family == 'K' else '' }}>Kconfig</option>
|
||||
<option value="D" {{ 'selected' if family == 'D' else '' }}>Devicetree</option>
|
||||
<option value="B" {{ 'selected' if family == 'B' else '' }}>DT compatible</option>
|
||||
{% for id, description in topbar_families.items() %}
|
||||
<option value="{{ id }}" {{ 'selected' if (current_family == id or current_family is not defined) else '' }}>
|
||||
{{ description }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<input placeholder="Search Identifier" type="text" id="search-input" name="i" value="{{ ident|default('') }}" autofocus/>
|
||||
<input placeholder="Search Identifier" type="text" id="search-input" name="i"
|
||||
value="{{ searched_ident|default('') }}" autofocus/>
|
||||
<button class="icon-search"><span class="screenreader">Go get it</span></button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue