Edit page: auto-expand step textareas, wider layout, image management
- Textareas auto-resize to fit content (min 120px) - Edit page container widened to 1100px - Show recipe image with URL input and file upload options - Add image upload endpoint (POST /api/recipes/<backend>/<id>/image) - Add upload_image_bytes() to both Mealie and Tandoor clients Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+33
@@ -349,6 +349,39 @@ def api_update_recipe(backend, recipe_id):
|
||||
return jsonify({"ok": False, "error": str(exc)})
|
||||
|
||||
|
||||
@app.route("/api/recipes/<backend>/<path:recipe_id>/image", methods=["POST"])
|
||||
def api_upload_image(backend, recipe_id):
|
||||
"""AJAX — upload an image file to a recipe."""
|
||||
cfg = config.load()
|
||||
if "image" not in request.files:
|
||||
return jsonify({"ok": False, "error": "Nincs fájl."})
|
||||
file = request.files["image"]
|
||||
if not file.filename:
|
||||
return jsonify({"ok": False, "error": "Nincs fájl."})
|
||||
|
||||
content_type = file.content_type or "image/jpeg"
|
||||
image_data = file.read()
|
||||
|
||||
try:
|
||||
if backend == "mealie":
|
||||
if not cfg.get("mealie_url") or not cfg.get("mealie_api_key"):
|
||||
return jsonify({"ok": False, "error": "Mealie nincs beállítva."})
|
||||
client = MealieClient(cfg["mealie_url"], cfg["mealie_api_key"],
|
||||
api_url=config.MEALIE_INTERNAL_URL)
|
||||
client.upload_image_bytes(recipe_id, image_data, content_type)
|
||||
elif backend == "tandoor":
|
||||
if not cfg.get("tandoor_url") or not cfg.get("tandoor_api_key"):
|
||||
return jsonify({"ok": False, "error": "Tandoor nincs beállítva."})
|
||||
client = TandoorClient(cfg["tandoor_url"], cfg["tandoor_api_key"],
|
||||
api_url=config.TANDOOR_INTERNAL_URL)
|
||||
client.upload_image_bytes(int(recipe_id), image_data, content_type)
|
||||
else:
|
||||
return jsonify({"ok": False, "error": "Ismeretlen backend."})
|
||||
return jsonify({"ok": True, "message": "Kép feltöltve."})
|
||||
except Exception as exc:
|
||||
return jsonify({"ok": False, "error": str(exc)})
|
||||
|
||||
|
||||
@app.route("/api/recipes/<backend>/delete", methods=["POST"])
|
||||
def api_delete_recipes(backend):
|
||||
"""AJAX — delete one or more recipes."""
|
||||
|
||||
Reference in New Issue
Block a user