UI: Minimalistisches 5-Kachel-Menü, 1-seitiges Inhaltsverzeichnis & schlanker mobiler Einkaufslisten-Header
This commit is contained in:
+10
-8
@@ -326,9 +326,9 @@ async def cookbook_view(
|
||||
|
||||
# --- Seitenzahlen & Inhaltsverzeichnis (TOC) berechnen ---
|
||||
# Seite 1: Cover
|
||||
# TOC: 1 oder 2 Seiten (wenn > 20 Rezepte vorhanden sind)
|
||||
# TOC: 1 Seite (bis ca. 55 Rezepte passt alles wunderbar auf 1 A4-Seite in 2 Spalten), 2 Seiten erst bei sehr vielen Rezepten
|
||||
total_display_recipes = len(all_recipes)
|
||||
toc_page_count = 2 if total_display_recipes > 20 else (1 if total_display_recipes > 0 else 0)
|
||||
toc_page_count = 2 if total_display_recipes > 55 else (1 if total_display_recipes > 0 else 0)
|
||||
current_page = 1 + toc_page_count + 1
|
||||
|
||||
display_chapters_data = []
|
||||
@@ -349,23 +349,25 @@ async def cookbook_view(
|
||||
chap_copy["recipes"] = chap_recipes
|
||||
display_chapters_data.append(chap_copy)
|
||||
|
||||
# Inhaltsverzeichnis auf 2 Seiten aufteilen
|
||||
# Inhaltsverzeichnis aufteilen (falls 2 Seiten: gleichmäßige 50/50 Balance)
|
||||
active_chapters = [c for c in display_chapters_data if recipes_by_chapter.get(c["number"], [])]
|
||||
total_weight = sum(len(recipes_by_chapter.get(c["number"], [])) + 2 for c in active_chapters)
|
||||
half_weight = total_weight / 2
|
||||
|
||||
toc_p1 = []
|
||||
toc_p2 = []
|
||||
if toc_page_count == 2:
|
||||
accum = 0
|
||||
for c in display_chapters_data:
|
||||
for c in active_chapters:
|
||||
c_recs = recipes_by_chapter.get(c["number"], [])
|
||||
if not c_recs:
|
||||
continue
|
||||
item_weight = len(c_recs) + 2
|
||||
if accum < 28 or not toc_p1:
|
||||
if accum < half_weight or not toc_p1:
|
||||
toc_p1.append(c)
|
||||
accum += item_weight
|
||||
else:
|
||||
toc_p2.append(c)
|
||||
else:
|
||||
toc_p1 = [c for c in display_chapters_data if recipes_by_chapter.get(c["number"], [])]
|
||||
toc_p1 = active_chapters
|
||||
|
||||
# User Agent Check für Apple iOS
|
||||
user_agent = request.headers.get("user-agent", "").lower()
|
||||
|
||||
Reference in New Issue
Block a user