Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipes imported from Nextcloud Cookbook using HowToStep result in malformed steps #2428

Closed
agc93 opened this issue Apr 20, 2023 · 2 comments

Comments

@agc93
Copy link

agc93 commented Apr 20, 2023

Tandoor Version

1.4.8

Setup

Docker / Docker-Compose

Reverse Proxy

Traefik

Other

No response

Bug description

Nextcloud Cookbooks supports recipes specifying the steps (in the JSON) as either a plain array of strings, like this:

"recipeInstructions": [
    "Bring a medium saucepan of salted water to the boil for the gnocchi. Grease a 1.5L (6 cup) baking dish. Finely chop the onion. Crush or finely chop 2 garlic cloves. Finely grate the parmesan.",
    "Grill the gnocchi bake for 5 mins or until golden and bubbling. Divide among bowls and enjoy."
  ],

or using the HowToStep schema from the schema.org Recipe type:

"recipeInstructions": [
    {
        "text": "Preheat the oven to 220C, fan-forced. Line a large oven tray with baking paper. Halve the cucumber lengthwise and thinly slice on an angle (see Kitchen 101). Thinly slice the spring onion. Thinly slice the chicken.\n",
        "name": "Prep ingredients",
        "@type": "HowToStep"
    },
    {
        "text": "Combine 1 tbs barbecue sauce and 1 tbs mayonnaise in a bowl. Top the pizzas with the drained pickled cucumber, then scatter over the spring onion and fried shallots. Cut into wedges, drizzle with the barbecue mayo and enjoy!\n",
        "name": "Serve up",
        "@type": "HowToStep"
    }
],

However, that means that if you download a recipe from Nextcloud and import it into Tandoor using the Nextcloud Cookbooks type, recipes using the HowToStep method have their instructions messed up as Tandoor seems to assume it will only be an array of strings.

For example, when I imported two recipes from a Nextcloud download, the one with steps of just strings worked fine, but the one using the full HowToStep schema (so that steps could have titles/names), resulted in this:

image

Recipe JSON (basic steps)
{
  "id": 185110,
  "name": "Sweet Tomato and Gnocchi Bake",
  "description": "Whether you\u2019re full-time vego or part-time only, our varied range of vegetarian dishes really hits the spot. Bursting with veggies, dairy, legumes, grains and nuts, they\u2019re packed with flavour, they\u2019ll fill you up and they\u2019re totally mouth-watering too!",
  "image": "\/Recipes\/Sweet Tomato and Gnocchi Bake\/full.jpg",
  "imageUrl": "\/index.php\/apps\/cookbook\/webapp\/recipes\/185110\/image?size=full",
  "prepTime": null,
  "cookTime": null,
  "totalTime": "PT0H40M0S",
  "recipeCategory": "veggie",
  "keywords": "vegetarian,kid_friendly,climate_hero",
  "recipeIngredient": [
    "1 onion",
    "50g parmesan",
    "5g Italian seasoning",
    "400g can cherry tomatoes",
    "400g gnocchi",
    "50g baby spinach leaves",
    "2 garlic cloves",
    "20g butter",
    "2 tsp olive oil",
    "1 tsp sugar",
    "125ml (\u00BD cup) boiling water"
  ],
  "recipeInstructions": [
    "Bring a medium saucepan of salted water to the boil for the gnocchi. Grease a 1.5L (6 cup) baking dish. Finely chop the onion. Crush or finely chop 2 garlic cloves. Finely grate the parmesan.",
    "Melt 20g butter and 2 tsp olive oil in a medium saucepan over medium heat. Add the onion, garlic and Italian seasoning and cook, stirring, for 5 mins or until softened. Add the tomatoes, 1 tsp sugar and 125ml (\u00BD cup) boiling water and bring to the boil. Reduce the heat to medium-low and cook, pressing the tomatoes to help break down, for 15 mins or until thickened.",
    "Meanwhile, preheat the grill to high. Add the gnocchi to the pan of boiling water, stir to separate, then return to the boil and cook for 2 mins or until the gnocchi float to the surface. Drain well.",
    "Add the spinach to the tomato sauce and cook for 1 min or until wilted. Remove the pan from the heat. Add the gnocchi and half the parmesan, season with pepper and stir to combine. Spoon into the prepared dish and scatter over the remaining parmesan (see Make it yours).",
    "Grill the gnocchi bake for 5 mins or until golden and bubbling. Divide among bowls and enjoy."
  ],
  "nutrition": {
    "calories": "705kcal",
    "carbohydrateContent": "102.0g",
    "proteinContent": "23.4g",
    "fatContent": "21.1g",
    "@type": "NutritionInformation"
  },
  "recipeYield": 2,
  "dateCreated": "2023-04-20T08:34:01.756Z",
  "dateModified": "2023-04-20T08:34:01.756Z",
  "tool": [],
  "printImage": true,
  "@type": "Recipe",
  "@context": "http:\/\/schema.org"
}
Recipe JSON (`HowToStep`)
{
    "id": 14916,
    "name": "Peking Chicken Pizzas",
    "description": "You may notice this recipe's back for a victory lap \u2013 that's because sometimes you can't beat a tried-and-true winner! Our Dinnerly home cooks loved this recipe, so here it is again for you to enjoy its easy cooking, big flavours and satisfying goodness.",
    "image": "\/Recipes\/Peking Chicken Pizzas\/full.jpg",
    "imageUrl": "\/index.php\/apps\/cookbook\/webapp\/recipes\/184055\/image?size=full",
    "prepTime": null,
    "cookTime": null,
    "totalTime": "PT0H25M0S",
    "recipeCategory": "meat",
    "keywords": [
        "under_30min",
        "poultry",
        "kid_friendly",
        "dairy_free"
    ],
    "recipeIngredient": [
        "1 Lebanese cucumber",
        "1 spring onion",
        "chicken breast fillet",
        "60g hoisin sauce",
        "4 pita breads",
        "10g fried shallots",
        "2 tsp sugar",
        "2 tsp white vinegar",
        "1 tbs vegetable oil",
        "2 tbs barbecue sauce",
        "1 tbs mayonnaise"
    ],
    "recipeInstructions": [
        {
            "text": "Preheat the oven to 220C, fan-forced. Line a large oven tray with baking paper. Halve the cucumber lengthwise and thinly slice on an angle (see Kitchen 101). Thinly slice the spring onion. Thinly slice the chicken.\n",
            "name": "Prep ingredients",
            "url": null,
            "@type": "HowToStep"
        },
        {
            "text": "Combine 2 tsp sugar and 2 tsp white vinegar in a large bowl. Add the cucumber and toss to combine. Set aside to pickle, tossing occasionally, until needed.\n",
            "name": "Pickle cucumber",
            "url": null,
            "@type": "HowToStep"
        },
        {
            "text": "Heat 1 tbs vegetable oil in a medium frypan over medium-high heat. Cook the chicken, stirring, for 2-3 mins until browned. Remove the pan from the heat. Season the chicken with salt and pepper.\n",
            "name": "Brown chicken",
            "url": null,
            "@type": "HowToStep"
        },
        {
            "text": "Combine the hoisin sauce and 1 tbs barbecue sauce in a bowl. Put 2 pita* on the lined tray. Spread with the hoisin mixture and top with the chicken. Bake the pizzas for 10-12 mins until golden.\n",
            "name": "Bake pizzas",
            "url": null,
            "@type": "HowToStep"
        },
        {
            "text": "Combine 1 tbs barbecue sauce and 1 tbs mayonnaise in a bowl. Top the pizzas with the drained pickled cucumber, then scatter over the spring onion and fried shallots. Cut into wedges, drizzle with the barbecue mayo and enjoy!\n",
            "name": "Serve up",
            "url": null,
            "@type": "HowToStep"
        }
    ],
    "nutrition": {
        "calories": "700kcal",
        "carbohydrateContent": "80.0g",
        "proteinContent": "42.8g",
        "fatContent": "22.1g",
        "@type": "NutritionInformation"
    },
    "recipeYield": 2,
    "dateCreated": "2023-04-20T08:52:55.147Z",
    "dateModified": null
}

I know that might not be the clearest explanation so let me know if you need more information (or an export from Nextcloud to test with) or anything.

Relevant logs

No response

@vabene1111
Copy link
Collaborator

Thanks for the great report, I will need to look into this

@vabene1111
Copy link
Collaborator

fixed for the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants