From c8a4861df8a792e8a784bf67b4861bde6f00fff6 Mon Sep 17 00:00:00 2001 From: smilerz Date: Mon, 29 Mar 2021 11:49:56 -0500 Subject: [PATCH] redirect to import url for processing --- cookbook/helper/recipe_html_import.py | 2 +- cookbook/helper/recipe_url_import.py | 3 ++ cookbook/templates/url_import.html | 53 ++++++++++++++++++++------- cookbook/views/api.py | 2 + cookbook/views/data.py | 7 +++- 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/cookbook/helper/recipe_html_import.py b/cookbook/helper/recipe_html_import.py index f9882778..9140d076 100644 --- a/cookbook/helper/recipe_html_import.py +++ b/cookbook/helper/recipe_html_import.py @@ -118,7 +118,7 @@ def get_recipe_from_source(text, url, space): temp_tree.append(node) if '@type' in el and el['@type'] == 'Recipe': - recipe_json = helper.find_recipe_json(el, None, space) + recipe_json = helper.find_recipe_json(el, url, space) recipe_tree += [{'name': 'ld+json', 'children': temp_tree}] else: recipe_tree += [{'name': 'json', 'children': temp_tree}] diff --git a/cookbook/helper/recipe_url_import.py b/cookbook/helper/recipe_url_import.py index 1b0828d4..0951ace2 100644 --- a/cookbook/helper/recipe_url_import.py +++ b/cookbook/helper/recipe_url_import.py @@ -86,6 +86,9 @@ def find_recipe_json(ld_json, url, space): else: ld_json['recipeInstructions'] = "" + if url: + ld_json['recipeInstructions'] += "\nImported from " + url + if 'image' in ld_json: ld_json['image'] = parse_image(ld_json['image']) else: diff --git a/cookbook/templates/url_import.html b/cookbook/templates/url_import.html index 6dd3ec33..c4775fa0 100644 --- a/cookbook/templates/url_import.html +++ b/cookbook/templates/url_import.html @@ -30,18 +30,18 @@ title="{% trans 'Drag me to your bookmarks to import recipes from anywhere' %}"> {% trans 'Bookmark Me!' %} -