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: Recipe Actions #3448

Merged

Conversation

michael-genson
Copy link
Collaborator

@michael-genson michael-genson commented Apr 10, 2024

What type of PR is this?

(REQUIRED)

  • feature

What this PR does / why we need it:

(REQUIRED)

This adds Group Recipe Actions to Mealie, allowing for custom "actions" on all recipes. This is specifically to address integrating with the Bring! shopping list (which has been requested a lot), but has other uses as well.

Recipe actions add custom menu options on all recipes:
image

They're managed through the Manage Data page:
image

"link" actions simply direct you to the target URL (using target="_blank" so a new tab is opened). "post" actions send a post request to the target URL and display a message once the request is complete.
image

The URL can be customized with merge fields a la JS string interpolation. For example, this is how you integrate with the Bring! shopping list:

https://api.getbring.com/rest/bringrecipes/deeplink?url=${url}&source=web

This is what I used for testing the POST requests:

https://webhook.site/35e84d12-7c3c-4f5b-ab95-9f28fd07fa03?id=${id}&slug=${slug}

image

(note: it doesn't actually use JS string interpolation, since that would require an eval expression, it just uses action.url.replace(...))

POST requests also include the recipe JSON in the request body.

EDIT: the updated menu, with some style changes:
image

Which issue(s) this PR fixes:

(REQUIRED)

Closes #790
Closes #1838
Closes #2589

Testing

Tests for backend, manually for frontend

@michael-genson michael-genson marked this pull request as ready for review April 16, 2024 13:34
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.

Finally had time to look at this beauty 😊
Looks all good, just some small things.

And would additionally suggest you run task docs to update the api reference in the docs.

frontend/components/Domain/Recipe/RecipeContextMenu.vue Outdated Show resolved Hide resolved
frontend/pages/group/data.vue Outdated Show resolved Hide resolved
@Kuchenpirat Kuchenpirat self-assigned this Apr 30, 2024
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.

Looking Good 😊🚀

@Kuchenpirat Kuchenpirat merged commit 3807778 into mealie-recipes:mealie-next May 1, 2024
10 checks passed
@michael-genson michael-genson deleted the feat/recipe-actions branch May 1, 2024 14:17
@felixschndr
Copy link

felixschndr commented May 16, 2024

https://api.getbring.com/rest/bringrecipes/deeplink?url=${url}&source=web

However this requires the mealie instance to be publicly available from the internet. Optimally the mealie instance would send the data of the reciepe directly (just like the post type) to bring however I do not see any endpoint in the mealie api docs (https://sites.google.com/getbring.com/bring-import-dev-guide/web-to-app-integration) that would allow this :(


I am currently thinking about how to avoid needing the mealie instance to be public. One idea I have to setup a local simple webserver that listens for post requests of mealie (with the recipe in its body), parses it and then sends the individual ingredients direcly via the API (something like this https://pypi.org/project/python-bring-api/)

@michael-genson
Copy link
Collaborator Author

this requires the mealie instance to be publicly available from the internet

Not necessarily, you just need internet access from the device you're using. It opens the target URL in a separate tab

One idea I have to setup a local simple webserver that listens for post requests of mealie

Yup, that is another solution, to create your own webservice

@felixschndr
Copy link

felixschndr commented May 16, 2024

Not necessarily, you just need internet access from the device you're using. It opens the target URL in a separate tab

I dont understand. Using the link integration I would be redirected to https://api.getbring.com/rest/bringrecipes/deeplink?url=<my-local-server>/g/home/r/apfelstrudel. Bring would then try to reach out to <my-local-server>/g/home/r/apfelstrudel and GET the contents. However it cannot reach the local webserver.

Can you please elaborate how this would work without the mealie instance to be public?

@michael-genson
Copy link
Collaborator Author

Sorry, my mistake, I forgot this API scrapes. I was looking at another bring endpoint that accepts posts (the one you shared above). With the get method your instance does need to be public

@felixschndr
Copy link

felixschndr commented May 16, 2024

Sorry, my mistake, I forgot this API scrapes.

No problem.


I will build a webserver based on python which does the method I described above. Afterwards, I will publish it, might be interesting for others too.


The bring api supports baseQuantity and requestedQuantity(https://sites.google.com/getbring.com/bring-import-dev-guide/web-to-app-integration#h.p_MCSdfKdC6YjI). Do you thin we could get these two fields as placeholders (or valid merge fields) as well? That would be great. :)

@michael-genson
Copy link
Collaborator Author

Yeah if you could open a feature request for it that would be great

@felixschndr
Copy link

Great! Will do this later today or tomorrow. Thank you in advance!

@felixschndr
Copy link

Yeah if you could open a feature request for it that would be great

Done in #3610

@felixschndr
Copy link

I am currently working on the python server that sends the data to the Bring API. Making great progress; I will release some source code and a container image in the next few days

@felixschndr
Copy link

I am currently working on the python server that sends the data to the Bring API. Making great progress; I will release some source code and a container image in the next few days

For anyone who is interested: You can find the code and a container image here.

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

Successfully merging this pull request may close these issues.

4 participants