diff --git a/server.py b/server.py index c949a3e..65bc4c1 100644 --- a/server.py +++ b/server.py @@ -1055,19 +1055,76 @@ async def list_recipes_api(request: Request, page: int = 1, limit: int = 20): current_user = get_user_from_cookie(request) all_recipes = list_all_recipes() - total = len(all_recipes) - # Pagination + if wants_html(request): + # HTML response + if not current_user: + return HTMLResponse(render_page( + "Recipes", + '
Login to see recipes.
', + None, + active_tab="recipes" + )) + + # Filter to user's recipes + actor_id = f"@{current_user}@{L2_DOMAIN}" + user_recipes = [c for c in all_recipes if c.uploader in (current_user, actor_id)] + total = len(user_recipes) + + if not user_recipes: + content = ''' +No recipes yet. Upload a recipe YAML file to get started.
+ ''' + return HTMLResponse(render_page("Recipes", content, current_user, active_tab="recipes")) + + html_parts = [] + for recipe in user_recipes: + var_count = len(recipe.variable_inputs) + fixed_count = len(recipe.fixed_inputs) + input_info = [] + if var_count: + input_info.append(f"{var_count} variable") + if fixed_count: + input_info.append(f"{fixed_count} fixed") + inputs_str = ", ".join(input_info) if input_info else "no inputs" + + html_parts.append(f''' + +Login to see recipes.
', - None, - active_tab="recipes" - )) - - all_recipes = list_all_recipes() - - # Filter to user's configs - actor_id = f"@{current_user}@{L2_DOMAIN}" - user_recipes = [c for c in all_recipes if c.uploader in (current_user, actor_id)] - total = len(user_recipes) - - if not user_recipes: - content = ''' -No recipes yet. Upload a recipe YAML file to get started.
- ''' - return HTMLResponse(render_page("Recipes", content, current_user, active_tab="recipes")) - - html_parts = [] - for recipe in user_recipes: - var_count = len(recipe.variable_inputs) - fixed_count = len(recipe.fixed_inputs) - input_info = [] - if var_count: - input_info.append(f"{var_count} variable") - if fixed_count: - input_info.append(f"{fixed_count} fixed") - inputs_str = ", ".join(input_info) if input_info else "no inputs" - - html_parts.append(f''' - -