generated from coulomb/repo-seed
Milestone 5 polish
This commit is contained in:
@@ -179,6 +179,8 @@ def search_page(
|
||||
status: str = "",
|
||||
language: str = "",
|
||||
framework: str = "",
|
||||
ability: str = "",
|
||||
capability: str = "",
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> HTMLResponse:
|
||||
results = (
|
||||
@@ -187,6 +189,8 @@ def search_page(
|
||||
status=status or None,
|
||||
language=language or None,
|
||||
framework=framework or None,
|
||||
ability=ability or None,
|
||||
capability=capability or None,
|
||||
)
|
||||
if q.strip()
|
||||
else []
|
||||
@@ -194,7 +198,7 @@ def search_page(
|
||||
rows = "\n".join(
|
||||
f"""
|
||||
<tr>
|
||||
<td><a href="/ui/repos/{result.repository_id}">{escape(result.repository_name)}</a></td>
|
||||
<td><a href="{search_result_href(asdict(result))}">{escape(result.repository_name)}</a></td>
|
||||
<td><span class="pill">{escape(result.match_type)}</span></td>
|
||||
<td>
|
||||
<strong>{escape(result.match_name)}</strong>
|
||||
@@ -223,6 +227,8 @@ def search_page(
|
||||
<label>Status <input name="status" value="{escape(status)}" placeholder="indexed"></label>
|
||||
<label>Language <input name="language" value="{escape(language)}" placeholder="Python"></label>
|
||||
<label>Framework <input name="framework" value="{escape(framework)}" placeholder="FastAPI"></label>
|
||||
<label>Ability <input name="ability" value="{escape(ability)}" placeholder="Email Routing"></label>
|
||||
<label>Capability <input name="capability" value="{escape(capability)}" placeholder="Classification"></label>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button type="submit">Search</button>
|
||||
@@ -930,7 +936,7 @@ def render_ability_map(ability_map: dict) -> str:
|
||||
)
|
||||
capabilities.append(
|
||||
f"""
|
||||
<li>
|
||||
<li id="capability-{capability['id']}">
|
||||
<strong>{escape(capability['name'])}</strong>
|
||||
<p class="muted">{escape(capability['description'])}</p>
|
||||
<ul>{features}{evidence}</ul>
|
||||
@@ -939,7 +945,7 @@ def render_ability_map(ability_map: dict) -> str:
|
||||
)
|
||||
items.append(
|
||||
f"""
|
||||
<li>
|
||||
<li id="ability-{ability['id']}">
|
||||
<strong>{escape(ability['name'])}</strong>
|
||||
<p class="muted">{escape(ability['description'])}</p>
|
||||
<ul>{''.join(capabilities)}</ul>
|
||||
@@ -949,6 +955,15 @@ def render_ability_map(ability_map: dict) -> str:
|
||||
return f'<div class="tree"><ul>{"".join(items)}</ul></div>'
|
||||
|
||||
|
||||
def search_result_href(result: dict) -> str:
|
||||
href = f"/ui/repos/{result['repository_id']}"
|
||||
if result.get("capability_id"):
|
||||
return f"{href}#capability-{result['capability_id']}"
|
||||
if result.get("ability_id"):
|
||||
return f"{href}#ability-{result['ability_id']}"
|
||||
return href
|
||||
|
||||
|
||||
def render_sources(source_refs: list[dict]) -> str:
|
||||
if not source_refs:
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user