Closed maxxcan closed 2 years ago
The org-capture example from the readme doesn't work for me either, but i"m using doom-emacs, so maybe it depends on that.
The function 'org-chef-insert-recipe ' works just fine, it's only the capture template i have problems with.
I get the error message "Capture template ‘c’: Template is not a valid Org entry or tree".
It asks for the URL, so the capture template is configured, the plugin seems to be loaded and the function 'org-chef-get-recipe-from-url' gets called. But after entering the URL i get the error message mentioned.
My Capture Template looks as follows:
(setq org-capture-templates
'(("c" "Cookbook" entry (file "~/sync/pm/org/cookbook.org"")
"%(org-chef-get-recipe-from-url)")
("m" "Manual Cookbook" entry (file "~/sync/pm/org/cookbook.org")
"* %^{Recipe title: }\n :PROPERTIES:\n :source-url:\n :servings:\n :prep-time:\n :cook-time:\n :ready-in:\n :END:\n** Ingredients\n %?\n** Directions\n\n")))
)
Replacing file with file+datetree doesn't make a difference for me.
How can i debug this further?
Which recipe are you having problems with? This happens when the recipe website isn't supported (should probably have a better error message / means of failure, though).
All of them? I've tried different sites, first the example one http://allrecipes.com/recipe/85452/homemade-black-bean-veggie-burgers/ and https://www.jamieoliver.com/recipes/vegetable-recipes/veggie-pad-thai/ https://www.chefkoch.de/rezepte/2654951416926884/Karottenkuchen-Rueblikuchen-oder-Moehrenkuchen.html https://steamykitchen.com/123148-baked-potato-in-the-microwave.html
They all work with 'org-chef-insert-recipe ', it's just the capture template i have problems with.
Hmmm. It might have something with how it's getting inserted into the capture buffer now. I'm also having problems with those recipes, but some work, e.g.:
https://www.budgetbytes.com/white-cheddar-mac-and-cheese/
Definitely worth looking into.
Doesn't work for me either.
At least as long as 'org-chef-insert-recipe ' works it's just a convenience problem.
FWIW the budgetbytes and jamieoliver recipes worked fine for me. In case it helps, here is my template entry:
("c" "Cookbook" entry (file "~/org/cookbook.org")
"%(org-chef-get-recipe-from-url)"
:empty-lines 1)
When using the capture template, and ALSO when using (org-chef-fetch-recipe URL)
, allrecipes and steamykitchen recipes were all blank, which suggests the sites have been updated and their parsers need fixing (although JSON-LD should make this easy, and in the meantime try setting org-chef-prefer-json-ld
to t
as a workaround).
When using the capture template, the chefkoch recipe gave a "Template is not a valid Org entry or tree" error. Using org-chef-insert-recipe
inserted the ingredients, but not the directions. Running (org-chef-fetch-recipe "https://www.chefkoch.de/rezepte/2654951416926884/Karottenkuchen-Rueblikuchen-oder-Moehrenkuchen.html")
gave the following output:
((source-url . "https://www.chefkoch.de/rezepte/2654951416926884/Karottenkuchen-Rueblikuchen-oder-Moehrenkuchen.html")
(ingredients " " "375 g Möhre(n), gerieben" "250 g Mehl" "2 L Backpulver" "250 g Zucker" "1 L Zimtpulver" "250 ml Öl, neutrales" "4 Ei(er)" "200 g Mandel(n), gemahlen" " Fett für die Form" " " "300 g Frischkäse" "100 g Puderzucker" "1 Pck. Vanillezucker" "1 Sp i ze Zitronensaft")
(name . "Karottenkuchen, Rüblikuchen oder Möhrenkuchen")
(servings . "1")
(prep-time)
(cook-time)
(ready-in . "")
(directions "Eier, Zucker, Öl und Zimt mit dem Mixer verrühren. Die Karotten und Mandeln hinzugeben. Mehl und Backpulver mischen, ebenfalls unterrühren. Den Teig in eine gefettete 26er Springform füllen, bei 180 °C Ober-/Unterhitze 40 - 50 Minuten backen. Man sollte eine Stäbchenprobe machen und die Erfahrungswerte mit dem eigenen Backofen berücksichtigen." "Für das Frosting Frischkäse und Zitronensaft mit dem Mixer auf niedriger Stufe glatt rühren. Puderzucker und Vanillezucker einrieseln lassen." "Nach dem Backen den Kuchen abkühlen lassen. Das Frosting mit der Streichpalette rundherum auftragen."))
This alist seems valid, so I suspect something is wrong with the Org insertion code.
Yeah the org-chef-insert-recipe is a bit of a hack. I actually have a different version locally. Let me fix it up and see if it fixes the problem.
I've pushed the changes. You can see if it changes your problem, though I suspect there's something else wrong as well.
I've updated everything (doom-emacs itself and a lot of other packages got updates as well) and now my capture Template works just as intended. From the links in this issue the allrecipes and the steamykitchen didn't fetch any ingredients or directions, but all the others worked.
Thanks for looking into it and thanks for the awesome plugin.
That's great! I'm happy it was just a fix I literally had lying around :). Looks like we should look into fixing the recipe fetching from those websites...
I'm going to close this issue for now, but let me know if it's an issue again.
Looks like we should look into fixing the recipe fetching from those websites...
Would it be a good idea to have some regression tests to catch these errors earlier?
Yeah, I've always wanted to do that, but I haven't done it because I haven't been 100% sure about the legality of copying a recipe into a test suite... But it's probably fine?
Yes you're right... We're unlikely to get sued but still I think it might be best to put these tests into a different package/repo? Possibly with a different license? Obviously I am no lawyer...
Alternatively, it might not be necessary to copy the recipe, e.g. we could compare string hashes instead (but that could lead to more cryptic test failures).
Yeah, I was thinking that a separate repo could work, just to kind of keep it separate for paranoia's sake. I'd really hope it wouldn't be a problem... But who knows. If anybody has ideas / plans for some kind of test suite, I'd be happy to hear them and facilitate the repo, etc.
I've also thought of the hashing idea, which I think would be fine too. Not ideal if we change the format (or the website does), but also not the end of the world because it should be fairly easy to inspect the change later.
I'm not super familiar with the world of testing in Emacs, but if people can point me in the right direction that would be awesome :). It does weigh on me that sites break under org-chef sometimes, and I have no idea when it happens. I don't like leaving everybody in a lurch, haha.
@rotlaus FYI, I have pushed fixes for allrecipes and steamykitchen. I think everything should work now. Thanks again for pointing out these issues.
@Chobbes Thanks again for all the work, all the sites i use are working.
But while i was checking the sites i use, i thought i can check all the others mentionend in the readme too.
If you are interested, a few were not working for different reasons:
Sites with the 'Template is not a valid Org entry or tree' error: https://www.simplyrecipes.com/recipes/pasta_with_roasted_tomatoes_and_herb_cashew_sauce/ https://www.bingingwithbabish.com/recipes/trenette-el-pesto-luca
No Title, Ingredients and Directions: https://www.marthastewart.com/1554453/brown-sugar-bananas https://www.marmiton.org/recettes/recette_gateau-au-yaourt-au-cooking-chef_383740.aspx https://www.reluctantgourmet.com/roasted-carrots-asparagus-pesto-recipe/
No Title: https://www.culturesforhealth.com/learn/recipe/sourdough-recipes/basic-sourdough-bread/
Unchecked because of language/Account Barriers: https://www.xiachufang.com https://www.nytimes.com
All the others are working fine.
Addendum: marthastewart, marmiton, reluctantgourmet and culturesforhealth do work with (setq org-chef-prefer-json-ld t)
if I use the org-capture template supply for the readme don't work. I have to change file by file+datetree
this line '(("r" "Cookbook" entry (file "~/cookbook/cookbook.org") by '(("r" "Cookbook" entry (file+datetree "~/cookbook/cookbook.org")