Closed thomaspreece closed 6 years ago
I have mixed thoughts about importing data from other sites. I tried to do something similar awhile back but it never really worked the way I wanted it to. Long story short I don't want to include a "Import from URL" feature in the way that you are describing. Trying to support different parsers becomes messy really quickly and everyone has a different Idea on what a json dump of a recipe should look like. To counter this, I tried to make creating recipes super easier and a lot of the time I just copy paste text from the food blogs.
In light of that I do what to have some type of Import/Export feature (#15). I'm not entirely sure what that should look like ATM. But I don't wanna add a UI to it (except for maybe a link for users who are logged-in). Maybe something like a new API endpoint that takes a properly formatted json object with all the data needed inside. This would either replace or inherit the way that creating recipes is done now. We can also make it an array for bulk creation.
If you wanna build out a separate service that mines data from sites and provide a properly formatted json object (In your case, you can just use ruby to build the service). Then I will try and help guide you though what is needed and make a few changes to support this.
The reason I wanted it on the "Create Recipe" screen is because my idea was that clicking on the button would populate the fields for the user to correct/fill in manually with cut/paste. I'm quite happy to just create a separate service which I'll just run on a different endpoint. However I'll want it to direct to the Create Recipe page rather then just submitting it to the database. I see two ways of doing this atm:
From my point of view, 2 will be easiest for me to implement as I won't have to worry about user tokens/getting username for submitting of data to API. Also commiting dodgy data to the database and then correcting it afterwards in 1 seems wrong to me. What's your thoughts? Is there a option 3?
So I was thinking something a bit more abstract than that. I can see the advantage of using the form to fix/add information that may still be needed. But I'm not sure about building the specific recipe import feature into the code.
I was thinking of having whatever you (or any user) want to pull recipe data from as a separate script. Then add a textbox that allows the user to input a json blob, in the format of a recipe json that is returned by the API. From there the form can load the data just like as if it where editing something.
I've been using the API for a while to import and export recipes. I would think a chrome extension that allows specific sites to be captured and sent through the API to import would work. My current code is a bit old and I don't know if it still works with the recent changes to the recipe format, but it's pretty simple to create an json object from old xml data and send it to the site for import. Scraping a site is basically the same thing. Willing to share my python, but don't know much about extensions.
A chrome extension sounds like a pretty perfect solution!
An extension seems like a faff for such a simple import function. If the extension route is taken then it needs to be compatable with other browsers, thats the whole point of open eats being a web app so that it works on all platforms in my opinion. The route I am currently favouring is a javascript bookmarklet which imports the page you are currently viewing, should be easier to implement then browser extensions. I'm also still favouring a backend parser as it'll mean I don't have to rewrite existing code into javascript.
I still don't mind supporting a small button on the top of the recipe creation page. It would redirect the user to an import page which is just a textarea that accepts a json object. From there, the data will be sent to the recipe creation page (just like editing would). This way u can use any language and any parser you like.
Closing this as I don't have plans to support this feature any time soon. I would much prefer making the recipe creation better and faster to use. However PRs are welcome on the items discussed above.
Want to add import from URL functionality into OpenEats. Thinking of having a button under the "URL Source of the recipe" which says "Import details from URL".
This repo is looking the most favorable for the functionality
https://github.com/lukeasrodgers/hangry
, for example an older version of the code produces:http://hangryingreedytest.herokuapp.com/?recipe_url=https%3A%2F%2Fwww.bbcgoodfood.com%2Frecipes%2F691639%2Fsatay-chicken-pieces
which looks pretty good to me. The only issue is that it is in ruby so I'm wondering should I submit a PR to the API component or should I keep it a separate docker service (new component under open-eats) and then have the API query that service and forward the request onto the frontend?