fix: ensure HTML response for search and fix player container
- Added html=1 parameter support to router_anime.py for guaranteed HTML fragments - Added missing #player-container to index.html for HTMX interactions - Cleaned up legacy CSS .active classes interfering with Alpine.js x-show
This commit is contained in:
@@ -65,11 +65,12 @@ async def search_anime_unified(
|
||||
q: str,
|
||||
lang: str = "vostfr",
|
||||
include_metadata: bool = False,
|
||||
html: bool = Query(False),
|
||||
):
|
||||
"""
|
||||
Search across all anime providers using MetadataEnricher and health checks.
|
||||
Results are grouped by provider for legacy UI compatibility.
|
||||
Returns HTML for HTMX requests.
|
||||
Returns HTML for HTMX requests or if html=True parameter is set.
|
||||
"""
|
||||
print(f"\n[SEARCH] Starting modern unified search for '{q}' in {lang}")
|
||||
start_time = time.time()
|
||||
@@ -103,7 +104,7 @@ async def search_anime_unified(
|
||||
seen_urls = set()
|
||||
enricher = await get_metadata_enricher()
|
||||
enrichment_tasks = []
|
||||
enrichment_mapping = [] # List of (provider_id, index_in_provider_results)
|
||||
enrichment_mapping = []
|
||||
|
||||
for i, raw_result in enumerate(all_raw_results):
|
||||
provider_info = task_metadata[i]
|
||||
@@ -172,7 +173,7 @@ async def search_anime_unified(
|
||||
print(f"[SEARCH] Finished in {elapsed:.2f}s. Found {total_found} unique results across {len(results)} providers.")
|
||||
|
||||
# 6. Return HTML for HTMX or JSON for API
|
||||
if request.headers.get("HX-Request"):
|
||||
if html or request.headers.get("HX-Request"):
|
||||
return templates.TemplateResponse(
|
||||
"components/anime_search_results.html",
|
||||
{"request": request, "results": results}
|
||||
@@ -351,6 +352,7 @@ async def search_anime_mal_details(
|
||||
await fetcher.close()
|
||||
|
||||
|
||||
@router.post("/api/translate")
|
||||
@router.post("/translate")
|
||||
async def translate_text(request: Request):
|
||||
"""Translate text from English to French using Google Translate"""
|
||||
|
||||
@@ -172,11 +172,7 @@
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
/* Managed by Alpine.js x-show */
|
||||
}
|
||||
|
||||
.tab-content.active {
|
||||
display: block;
|
||||
/* Handled by Alpine.js x-show */
|
||||
}
|
||||
|
||||
select {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{% block content %}
|
||||
{% include "components/header.html" %}
|
||||
|
||||
<!-- Main content - Shown only when authenticated -->
|
||||
<!-- Main content - Managed by Alpine state -->
|
||||
<div id="main-content">
|
||||
|
||||
{% include "components/home_section.html" %}
|
||||
@@ -15,7 +15,7 @@
|
||||
<h2>🎬 Rechercher un Anime</h2>
|
||||
</div>
|
||||
<div class="url-form">
|
||||
<form hx-get="/api/anime/search"
|
||||
<form hx-get="/api/anime/search?html=1"
|
||||
hx-target="#animeSearchResults"
|
||||
hx-indicator="#search-loading"
|
||||
class="input-group">
|
||||
@@ -43,6 +43,9 @@
|
||||
|
||||
<!-- Anime search results -->
|
||||
<div id="animeSearchResults" style="margin-bottom: 40px;"></div>
|
||||
|
||||
<!-- Player container for HTMX injections -->
|
||||
<div id="player-container"></div>
|
||||
|
||||
<hr style="border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 40px 0;">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user