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

feat: Create Recipe From HTML or JSON #4274

Conversation

michael-genson
Copy link
Collaborator

@michael-genson michael-genson commented Sep 26, 2024

What type of PR is this?

(REQUIRED)

  • feature

What this PR does / why we need it:

(REQUIRED)

This PR adds the ability to create a recipe from raw HTML or JSON. We leverage the existing URL scrapers as-is, but bypass calling the target URL and instead provide the HTML/JSON directly (JSON must be in schema.org format, although if OpenAI is enabled it might figure it out regardless).

This is suggested on the create by URL page:
image

Which brings you here:
image

You can put HTML or JSON into that text field, however you may optionally use the JSON editor mode for JSON:
image

The main advantages of this are:

  1. If you have raw HTML or JSON from a local recipe (or if you fed something to OpenAI) you can import it here without spinning up a webserver or similar
  2. If our scrapers fail for some reason (e.g. the target URL has anti-bot protection, or recipes are locked behind a login) you can use this as a workaround

Which issue(s) this PR fixes:

(REQUIRED)

Closes #3224
Closes #2391

Special notes for your reviewer:

I changed some of the "create" route names because they're getting a bit unorganized. All recipe create routes are now under /recipe/create/.... This is a breaking change, so I added it to the migration docs.

Testing

(fill-in or delete this section)

Pytest

Copy link
Collaborator

@Kuchenpirat Kuchenpirat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was way more straigt-foreward than expected 😊
All good on this one 🚀

@@ -52,6 +52,11 @@ export default defineComponent({
text: i18n.tc("recipe.bulk-url-import"),
value: "bulk",
},
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at some point we should try to simplify that list somehow. It kepps getting longer and longer...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, we're gonna have to do something about it soon

@Kuchenpirat Kuchenpirat enabled auto-merge (squash) September 30, 2024 15:44
@Kuchenpirat Kuchenpirat merged commit 4c1d855 into mealie-recipes:mealie-next Sep 30, 2024
13 checks passed
@michael-genson michael-genson deleted the feat/create-recipe-from-json branch September 30, 2024 16:30
@Kuchenpirat Kuchenpirat added the v2 Version 2 Issue/PR label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants