From 463141981bcf814c207930c3ebb6682342b04091 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Sun, 19 Jan 2025 21:11:38 +0100 Subject: [PATCH] fix(backend): rendering issue --- article.html | 600 +++++++++++++++++++++++++++++ compose.yml | 13 + islands/KMenu/commands.ts | 2 +- lib/parseIngredient.ts | 5 +- lib/resource/recipes.ts | 5 + routes/api/recipes/create/index.ts | 16 +- routes/movies/[name].tsx | 10 +- 7 files changed, 635 insertions(+), 16 deletions(-) create mode 100644 article.html create mode 100644 compose.yml diff --git a/article.html b/article.html new file mode 100644 index 0000000..bc5faa9 --- /dev/null +++ b/article.html @@ -0,0 +1,600 @@ +Linsen-Curry-Topf mit Koriander-Joghurt Rezept - REWE.de
Linsen-Curry-Topf mit Koriander-Joghurt

Linsen-Curry-Topf mit Koriander-Joghurt +

+ +
35min Gesamtzeit
+
Mittel +
70

Zubereitung +

+ +
  • Sparschäler
+ +
  • 2 Zwiebeln
  • 1 Knoblauchzehe
  • 3 Möhren
  • 1 Zucchini
  • 1 Bd. Frühlingszwiebeln

Zwiebeln, Knoblauch und Möhren schälen und fein würfeln. Zucchini waschen und klein schneiden. Frühlingszwiebeln waschen und in Röllchen schneiden.

+ +
  • 2 EL Rapsöl
  • 120 g rote Linsen
  • 2 EL Currypulver
  • 400 g gehackte Tomaten
  • 1 EL Tomatenmark
  • Salz
  • Pfeffer

Öl in einem großen Topf erhitzen. Zwiebeln und Knoblauch anschwitzen. Linsen, Zucchini und Möhren sowie Currypulver, gehackte Tomaten und Tomatenmark zufügen. Kurz anschwitzen und mit gut 600 ml Wasser ablöschen. Frühlingszwiebeln zufügen und gut 10-15 Minuten köcheln lassen, bis die Linsen gar sind. Bei Bedarf noch etwas Wasser zufügen. Mit Salz, Pfeffer und Curry abschmecken.

+ +
  • 1 Bd. Koriander
  • 300 g Naturjoghurt

Koriander waschen, trocken schütteln und fein hacken. Unter den Joghurt rühren und mit Salz und Pfeffer würzen. Zum Linsen-Curry-Topf servieren.

Linsen-Curry-Topf mit Koriander-Joghurt

Tipp zum Rezept +

Reste des Koriander-Joghurts schmecken auch gut mit Gemüsesticks oder als Brotbelag. Pro Portion kostet das Essen ca. 1,90 €, insgesamt ca. 7,50 Euro.

Diane Buckstegge Bild
Ökotrophologin

Gib uns dein Feedback

Hast du Feedback für unsere Redaktion? Hier kannst du uns Feedback zum Rezept geben.

Bewertungen mit Kommentar

Hat's geschmeckt? Sag uns, wie dir unser Rezept gefallen hat.
Dieses Rezept wurde noch nicht kommentiert, mit deiner Bewertung mit Kommentar hilfst du anderen dabei, schneller zu finden, was sie mögen.
Du kannst deine Bewertung kommentieren, wenn du dich anmeldest.

Lecker gespart +

Hier findest du unsere besten Angebotsrezepte der Woche. +

+ + Angebotsrezepte entdecken +
\ No newline at end of file diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..98ac27b --- /dev/null +++ b/compose.yml @@ -0,0 +1,13 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + volumes: + - .:/app # Mount the local directory to /app in the container + working_dir: /app # Set the working directory inside the container to /app + command: run --env-file -A --watch=static/,routes/ dev.ts # Custom start command + ports: + - "8000:8000" # Expose the container port + environment: + - DATA_DIR=/app/data # Set the environment variable inside the container diff --git a/islands/KMenu/commands.ts b/islands/KMenu/commands.ts index 084dffb..05e8e02 100644 --- a/islands/KMenu/commands.ts +++ b/islands/KMenu/commands.ts @@ -77,7 +77,7 @@ export const menus: Record = { createNewSeries, createNewRecipe, addMovieInfos, - updateAllRecommendations, + // updateAllRecommendations, ], }, }; diff --git a/lib/parseIngredient.ts b/lib/parseIngredient.ts index 83d32a0..b8caf21 100644 --- a/lib/parseIngredient.ts +++ b/lib/parseIngredient.ts @@ -46,7 +46,10 @@ export const unitsOfMeasure = { export function parseIngredients( text: string, ): (Ingredient | IngredientGroup)[] { - const cleanText = removeMarkdownFormatting(text); + const cleanText = removeMarkdownFormatting(text) + .split("\n") + .map((line) => line.trim().replace(/^-/, "")) + .join("\n"); const ingredients = parseIngredient(cleanText, { normalizeUOM: true, diff --git a/lib/resource/recipes.ts b/lib/resource/recipes.ts index b4b9724..bb737a7 100644 --- a/lib/resource/recipes.ts +++ b/lib/resource/recipes.ts @@ -160,6 +160,11 @@ export function renderRecipe(recipe: Recipe) { item.unit?.trim() || "" }** ${item.name}`; } + + if (item.quantity) { + return `- **${item.quantity}** ${item.name}`; + } + return `- ${item.name}`; }) .join("\n"); diff --git a/routes/api/recipes/create/index.ts b/routes/api/recipes/create/index.ts index 9456743..24669a3 100644 --- a/routes/api/recipes/create/index.ts +++ b/routes/api/recipes/create/index.ts @@ -93,10 +93,13 @@ async function extractUsingAI( const recipe = await openai.extractRecipe(markdown); - if (isValidRecipe(recipe)) { - return recipe; + if (recipe) { + if ("errorMessages" in recipe) { + throw new Error("Failed to extract recipe: " + recipe.errorMessages[0]); + } else { + return recipe; + } } - return; } async function processCreateRecipeFromUrl( @@ -172,13 +175,6 @@ async function processCreateRecipeFromUrl( } } - if (!recipe) { - console.error("Failed to parse recipe"); - streamResponse.enqueue("failed to parse recipe"); - streamResponse.cancel(); - return; - } - const newRecipe: Recipe = { type: "recipe", id, diff --git a/routes/movies/[name].tsx b/routes/movies/[name].tsx index 0156945..e06f5fb 100644 --- a/routes/movies/[name].tsx +++ b/routes/movies/[name].tsx @@ -51,10 +51,12 @@ export default async function Greet( - + {false && ( + + )} {movie.tags.length > 0 && ( <>