Import an Umai recipe?
I'm trying to import a recipe from one Solid account to another. Changes have been made to the recipe, so I can't just reimport the original website. I would be ok with adding the remote recipe to the cookbook if it was possible (i.e. one recipe in two cookbooks), but importing is actually preferred in this case.
This was my journey, starting with "Import from the web":
- Importing directly fails with a 401, because it uses an unauthenticated fetch https://github.com/NoelDeMartin/umai/blob/302a2b559c74d65c25ca2c4a7faa28d2c3e8aa2a/src/components/modals/WebImportModal.ts#L56
- In principle it seems a Solid resource could be detected with the header
www-authenticate Bearer scope="openid webid" - Workaround is to change the resource to being public
- In principle it seems a Solid resource could be detected with the header
- No recipe is found because parseWebsite expects HTML
- Probably content type would need to be detected, which would then need to be passed to parseWebsite? https://github.com/NoelDeMartin/umai/blob/302a2b559c74d65c25ca2c4a7faa28d2c3e8aa2a/src/components/modals/WebImportModal.ts#L67
- JSON-LD islands are already supported so maybe setting an accept header with "application/ld+json" would be the easiest support route, subsequently with minimal changes in https://github.com/NoelDeMartin/umai/blob/302a2b559c74d65c25ca2c4a7faa28d2c3e8aa2a/src/utils/web-parsing.ts
- Workaround is to manually download JSON-LD
- I used Share -> JSON-LD -> Download and then Upload JSON-LD
- This mostly worked, though images are hotlinked rather than downloaded, so a private image was not available from the new account
- Given this works well, perhaps the same function could be used directly on the remote JSON-LD (without having to download) https://github.com/NoelDeMartin/umai/blob/302a2b559c74d65c25ca2c4a7faa28d2c3e8aa2a/src/components/recipe/RecipeCreateOptions.vue#L68
Hey, as always, thanks for opening an issue and using Umai :D.
I have to check what's going on with the "import from the web", because maybe I could make that work. But the easiest way is definitely to share a recipe with the Share modal (you can make it unlisted so that only people with the link can find it).
For example, if you want to import my Ramen recipe to your cookbook, you only have to click the following link and you'll see a button saying "Save in my cookbook": https://umai.noeldemartin.com/viewer?url=https://noeldemartin.solidcommunity.net/cookbook/ramen%23it
In practice, though, this is very similar to exporting/importing from JSON-LD. So yes, if images are private, they won't work... But if you make a recipe public (or unlisted), that also changes the visibility of the images. I thought about making something to export the entire recipes, including the images, but in the end I decided it wasn't necessary because this approach seemed to work fine. What do you think?
By the way, there aren't any affordances in the UI (yet?), but you could also change the permissions so that only another account can see the recipe. You could change the ACLs to add read permissions for your other account and the image should work.
Cool! I hadn't thought to look at the viewer. I'd still like to be able to import directly at some point, but this should work well in the mean time.
I don't have a strong opinion about exporting/importing images at the moment, but I'll let you know if I form one :-)
Also, the SAI position is generally that apps shouldn't control permissions, so there's no need for a UI affordance to share the image yet until the specs mature.