69 lines
13 KiB
HTML
69 lines
13 KiB
HTML
{% extends 'planner/base.html' %}{% load static recipe_markdown %}
|
|
{% block title %}Recipes · Tasknest{% endblock %}
|
|
{% block page_class %}recipes-page-content{% endblock %}
|
|
{% block content %}
|
|
<link rel="stylesheet" href="{% static 'recipes/recipes.css' %}?v=8">
|
|
<div class="recipes-layout {% if explicit_detail %}recipes-layout--detail{% else %}recipes-layout--list{% endif %}">
|
|
<aside class="recipes-browser" aria-label="Recipe browser">
|
|
<div class="recipes-browser__heading">
|
|
<div><h1>Recipes</h1><p>Find, create and cook with what you have.</p><a class="recipes-match-link" href="{% url 'recipes:cook-later' %}">Cook Later</a></div>
|
|
<a class="button recipes-new" href="{% url 'recipes:create' %}">+ New recipe</a>
|
|
</div>
|
|
<nav class="recipes-mode" aria-label="Recipe view"><a href="{% url 'recipes:list' %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" aria-current="page">Search</a><a href="{% url 'recipes:match' %}?q={{ query|urlencode }}&category={{ category|urlencode }}&tag={{ tag|urlencode }}">Swipe</a></nav>
|
|
<form method="get" action="{% url 'recipes:list' %}" class="recipes-filters" role="search">
|
|
<label for="recipes-search">Search recipes</label>
|
|
<div class="recipes-search-row"><input id="recipes-search" type="search" name="q" value="{{ query }}" placeholder="Search recipes or ingredients"><button type="submit">Search</button></div>
|
|
<details class="recipes-filter-details" data-responsive-filters open>
|
|
<summary>More filters{% if category or tag or favourite %} · Applied{% endif %}</summary>
|
|
<div class="recipes-filter-options"><div class="recipes-filter-grid">
|
|
<label>Category<select name="category"><option value="">All categories</option>{% for value in categories %}<option value="{{ value }}"{% if value == category %} selected{% endif %}>{{ value }}</option>{% endfor %}</select></label>
|
|
<label>Tag<select name="tag"><option value="">All tags</option>{% for value in tags %}<option value="{{ value }}"{% if value == tag %} selected{% endif %}>{{ value }}</option>{% endfor %}</select></label>
|
|
</div>
|
|
<label class="recipes-favourite-filter"><input type="checkbox" name="favourite" value="1"{% if favourite %} checked{% endif %}> Favourites only</label>
|
|
<button class="recipes-filter-apply" type="submit">Apply filters</button></div>
|
|
</details>
|
|
</form>
|
|
<div class="recipes-list" aria-label="Your recipes">
|
|
{% for recipe in recipes %}
|
|
<a class="recipes-list-item{% if selected.pk == recipe.pk %} recipes-list-item--selected{% endif %}" href="{% url 'recipes:detail' recipe.api_id %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}"{% if selected.pk == recipe.pk %} aria-current="page"{% endif %}>
|
|
{% if recipe.photo %}<img class="recipes-list-item__image" src="{% url 'recipes:photo' recipe.api_id %}" alt="" loading="lazy">{% else %}<span class="recipes-list-item__placeholder" aria-hidden="true">Recipe</span>{% endif %}
|
|
<span class="recipes-list-item__body"><strong>{{ recipe.title }}</strong><small>{{ recipe.total_minutes }} min · {{ recipe.default_servings|floatformat:-2 }} servings</small><span class="recipes-list-item__tags">{% if recipe.category %}<span>{{ recipe.category }}</span>{% endif %}{% for value in recipe.tags|slice:':2' %}<span>{{ value }}</span>{% endfor %}</span></span>
|
|
{% if recipe.pk in saved_ids %}<span class="recipes-saved-badge">Cook Later</span>{% endif %}{% if recipe.is_favourite %}<span class="recipes-list-item__favourite" aria-label="Favourite">♥</span>{% endif %}
|
|
</a>
|
|
{% empty %}
|
|
<div class="recipes-empty-list"><p>{% if query or category or tag or favourite %}No recipes match these filters.{% else %}Your recipe library is ready.{% endif %}</p><a href="{% url 'recipes:create' %}">Create a recipe</a></div>
|
|
{% endfor %}
|
|
</div>
|
|
</aside>
|
|
|
|
<section class="recipes-detail" aria-label="Recipe details">
|
|
{% if selected %}
|
|
<div class="recipes-detail__top"><a class="recipes-back" href="{% url 'recipes:list' %}">← Back to recipes</a><div class="recipes-detail__top-actions"><form method="post" action="{% url 'recipes:favourite' selected.api_id %}">{% csrf_token %}<button type="submit" class="recipes-heart" aria-label="{% if selected.is_favourite %}Remove {{ selected.title }} from favourites{% else %}Add {{ selected.title }} to favourites{% endif %}" aria-pressed="{% if selected.is_favourite %}true{% else %}false{% endif %}">{% if selected.is_favourite %}♥{% else %}♡{% endif %}</button></form><a class="recipes-outline-button" href="{% url 'recipes:edit' selected.api_id %}">Edit</a></div></div>
|
|
<div class="recipes-hero">
|
|
{% if selected.photo %}<img src="{% url 'recipes:photo' selected.api_id %}" alt="Photo of {{ selected.title }}">{% else %}<form class="recipe-photo-upload" method="post" enctype="multipart/form-data" action="{% url 'recipes:photo-upload' selected.api_id %}" data-photo-upload>{% csrf_token %}<label class="recipes-photo-placeholder" for="recipe-detail-photo"><span class="recipe-photo-upload__icon" aria-hidden="true">↑</span><strong>Add a recipe photo</strong><span>Click or drop a JPEG, PNG or WebP image</span><input id="recipe-detail-photo" name="photo" type="file" accept="image/jpeg,image/png,image/webp" required></label><button class="recipe-photo-submit" type="submit">Upload photo</button><span class="recipe-photo-upload__status" data-photo-status role="status" aria-live="polite"></span></form>{% endif %}
|
|
<div class="recipes-hero__copy"><p class="recipes-eyebrow">{% if selected.status == 'draft' %}Draft recipe{% else %}Recipe{% endif %}</p><h2>{{ selected.title }}</h2><p class="recipes-hero__meta">{{ selected.total_minutes }} min total · {{ selected.default_servings|floatformat:-2 }} servings</p><div class="recipes-chips">{% if selected.category %}<span>{{ selected.category }}</span>{% endif %}{% for value in selected.tags %}<span>{{ value }}</span>{% endfor %}</div>{% if selected.description %}<p class="recipes-hero__description">{{ selected.description }}</p>{% endif %}</div>
|
|
</div>
|
|
<form class="recipes-serving-form" method="get" action="{% url 'recipes:detail' selected.api_id %}"><label for="recipe-servings">Servings</label><input id="recipe-servings" type="number" name="servings" min="0.01" max="99999.99" step="0.01" value="{{ analysis.servings|floatformat:-2 }}"><label class="recipes-checkbox"><input type="checkbox" name="optional" value="1"{% if analysis.include_optional %} checked{% endif %}> Include optional ingredients</label><button type="submit" class="recipes-outline-button">Update</button></form>
|
|
<p class="recipes-cook-entry"><a class="button" href="{% url 'recipes:cook' selected.api_id %}?servings={{ analysis.servings }}{% if analysis.include_optional %}&optional=1{% endif %}">Start cooking</a></p>
|
|
<p class="recipes-cook-entry"><a class="recipes-outline-button" href="{% url 'groceries:recipe-preview' selected.api_id %}?servings={{ analysis.servings }}{% if analysis.include_optional %}&optional=1{% endif %}">Add missing ingredients to groceries</a></p>
|
|
{% if analysis_error %}<p class="recipes-form-error" role="alert">{{ analysis_error }}</p>{% endif %}
|
|
<div class="recipes-content-grid">
|
|
<section class="recipes-panel" aria-labelledby="recipe-ingredients-heading"><h3 id="recipe-ingredients-heading">Ingredients</h3><ul class="recipes-ingredient-list">{% for line in analysis.lines %}<li><span>{{ line.name }}{% if line.source %}<small>From {{ line.source }}</small>{% endif %}{% if line.ingredient.preparation_note %}<small>{{ line.ingredient.preparation_note }}</small>{% endif %}<small class="recipes-stock-label recipes-stock-label--{{ line.status }}">{{ line.status|capfirst }}{% if line.reason %}: {{ line.reason }}{% endif %}</small></span><strong>{{ line.quantity|floatformat:-3 }} {{ line.unit }}</strong>{% if line.optional %}<em>Optional{% if not analysis.include_optional %} · excluded{% endif %}</em>{% endif %}</li>{% empty %}<li class="recipes-muted">No ingredients added yet.</li>{% endfor %}</ul></section>
|
|
<div class="recipes-content-stack"><section class="recipes-panel" aria-labelledby="recipe-instructions-heading"><h3 id="recipe-instructions-heading">Instructions</h3>{% if selected.instructions_markdown %}<div class="recipes-markdown-source">{{ selected.instructions_markdown|recipe_markdown }}</div>{% else %}<p class="recipes-muted">No instructions added yet.</p>{% endif %}</section>{% if selected.notes_markdown %}<section class="recipes-panel" aria-labelledby="recipe-notes-heading"><h3 id="recipe-notes-heading">Notes</h3><div class="recipes-markdown-source">{{ selected.notes_markdown|recipe_markdown }}</div></section>{% endif %}</div>
|
|
</div>
|
|
{% else %}
|
|
<div class="recipes-empty-detail"><h2>Make room for something delicious.</h2><p>Save a recipe to see its ingredients and instructions here.</p><a class="button" href="{% url 'recipes:create' %}">Create your first recipe</a></div>
|
|
{% endif %}
|
|
</section>
|
|
|
|
{% if selected %}<aside class="recipes-info" aria-label="Recipe information">
|
|
<section class="recipes-panel"><h3>At a glance</h3><dl class="recipes-facts"><div><dt>Selected servings</dt><dd>{{ analysis.servings|floatformat:-2 }}</dd></div><div><dt>Preparation</dt><dd>{{ selected.preparation_minutes }} min</dd></div><div><dt>Cooking</dt><dd>{{ selected.cooking_minutes }} min</dd></div><div><dt>Status</dt><dd>{{ selected.get_status_display }}</dd></div></dl></section>
|
|
<section class="recipes-panel"><h3>Nutrition</h3><p class="recipes-muted">For {{ analysis.servings|floatformat:-2 }} servings. Estimates use matched product data.</p><dl class="recipes-nutrition">{% for row in analysis.nutrition_rows %}<div><dt>{{ row.label }}</dt><dd>{% if row.total is not None %}{{ row.per_serving|floatformat:1 }} {{ row.unit }} / serving<small>{{ row.total|floatformat:1 }} {{ row.unit }} total{% if not row.complete %} · incomplete{% endif %}</small>{% else %}<span aria-label="No estimate">—</span><small>Data unavailable</small>{% endif %}</dd></div>{% endfor %}</dl><p class="recipes-muted">A partial estimate excludes missing nutrient values.</p></section>
|
|
<section class="recipes-panel"><h3>Inventory status</h3>{% for group in analysis.groups %}<div class="recipes-stock-group"><div><strong>{{ group.product.product_name }}</strong><span class="recipes-stock-label recipes-stock-label--{{ group.status }}">{{ group.status|capfirst }}</span></div><small>{% if group.plan %}{{ group.plan.total|floatformat:-3 }} / {{ group.stock_amount|floatformat:-3 }} {{ group.unit }} available{% else %}Unit conversion needed{% endif %}</small><div class="recipes-fill" role="progressbar" aria-label="{{ group.product.product_name }} available for recipe" aria-valuenow="{{ group.percent }}" aria-valuemin="0" aria-valuemax="100"><span style="width:{{ group.percent }}%"></span></div></div>{% empty %}<p class="recipes-muted">Match ingredients to products to check stock.</p>{% endfor %}<a class="recipes-outline-button recipes-preview-link" href="{% url 'recipes:stock-preview' selected.api_id %}?servings={{ analysis.servings }}{% if analysis.include_optional %}&optional=1{% endif %}">Review stock and deductions</a></section>
|
|
{% if selected.parent or selected.variations.all or selected.subrecipes.all %}<section class="recipes-panel"><h3>Related recipes</h3>{% if selected.parent %}<p>Variation of <a href="{% url 'recipes:detail' selected.parent.api_id %}">{{ selected.parent.title }}</a></p>{% endif %}{% for variation in selected.variations.all %}<p><a href="{% url 'recipes:detail' variation.api_id %}">{{ variation.title }}</a></p>{% endfor %}{% for item in selected.subrecipes.all %}<div class="recipes-related-component"><p>{{ item.quantity|floatformat:-3 }} {{ item.unit }} of <a href="{% url 'recipes:detail' item.component.api_id %}">{{ item.component.title }}</a></p>{% if item.component.instructions_markdown %}<details><summary>Show {{ item.component.title }} instructions</summary><div class="recipes-markdown-source">{{ item.component.instructions_markdown|recipe_markdown }}</div></details>{% endif %}</div>{% endfor %}</section>{% endif %}
|
|
<section class="recipes-panel"><h3>Actions</h3><a class="recipes-action" href="{% url 'recipes:edit' selected.api_id %}">Edit recipe</a><form method="post" action="{% url 'recipes:create-variation' selected.api_id %}" class="recipes-action-form">{% csrf_token %}<button type="submit" class="recipes-action">Create variation</button></form>{% if last_use %}<form method="post" action="{% url 'recipes:stock-undo' last_use.pk %}" class="recipes-action-form">{% csrf_token %}<button type="submit" class="recipes-action">Undo last inventory use</button></form>{% endif %}<a class="recipes-action recipes-action--danger" href="{% url 'recipes:delete' selected.api_id %}">Delete recipe</a></section>
|
|
</aside>{% endif %}
|
|
</div>
|
|
<script src="{% static 'planner/responsive_filters.js' %}?v=1" defer></script><script src="{% static 'recipes/photo_upload.js' %}?v=1" defer></script>
|
|
{% endblock %}
|