From 302528256c0aa8e218e3a2b3db097ddc432a7c4a Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sat, 26 Apr 2025 18:53:14 +0200 Subject: [PATCH] fixed external recipe viewer --- cookbook/templates/pdf_viewer.html | 31 +++++++++++++++++++ cookbook/urls.py | 3 +- cookbook/views/views.py | 7 +++++ .../display/ExternalRecipeViewer.vue | 2 +- 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 cookbook/templates/pdf_viewer.html diff --git a/cookbook/templates/pdf_viewer.html b/cookbook/templates/pdf_viewer.html new file mode 100644 index 000000000..d81bef81a --- /dev/null +++ b/cookbook/templates/pdf_viewer.html @@ -0,0 +1,31 @@ +{% load static %} + + + + + PDF + + PDF + + + + + + + + + \ No newline at end of file diff --git a/cookbook/urls.py b/cookbook/urls.py index 2b8e1eac8..3aedd1468 100644 --- a/cookbook/urls.py +++ b/cookbook/urls.py @@ -100,12 +100,13 @@ urlpatterns = [ path('edit/recipe/convert//', edit.convert_recipe, name='edit_convert_recipe'), path('edit/storage//', edit.edit_storage, name='edit_storage'), path('delete/recipe-source//', delete.delete_recipe_source, name='delete_recipe_source'), + path('view-recipe-pdf//', views.recipe_pdf_viewer, name='view_recipe_pdf'), # Tandoor v1 redirects path('view/recipe/', views.redirect_recipe_view, name='redirect_recipe_view'), path('view/recipe//', views.redirect_recipe_share_view, name='redirect_recipe_share_view'), - # TODO move to generic "new" view + path('data/sync', data.sync, name='data_sync'), path('data/batch/edit', data.batch_edit, name='data_batch_edit'), path('data/batch/import', data.batch_import, name='data_batch_import'), diff --git a/cookbook/views/views.py b/cookbook/views/views.py index cf6739a03..218d6e2ad 100644 --- a/cookbook/views/views.py +++ b/cookbook/views/views.py @@ -32,6 +32,7 @@ from cookbook.models import Comment, CookLog, InviteLink, SearchFields, SearchPr from cookbook.tables import CookLogTable, ViewLogTable from cookbook.templatetags.theming_tags import get_theming_values from cookbook.version_info import VERSION_INFO +from cookbook.views.api import get_recipe_provider from recipes.settings import PLUGINS @@ -196,6 +197,12 @@ def meal_plan(request): return render(request, 'meal_plan.html', {}) +@group_required('guest') +def recipe_pdf_viewer(request, pk): + recipe = get_object_or_404(Recipe, pk=pk, space=request.space) + return render(request, 'pdf_viewer.html', {'recipe_id': pk}) + + @group_required('guest') def user_settings(request): if request.space.demo: diff --git a/vue3/src/components/display/ExternalRecipeViewer.vue b/vue3/src/components/display/ExternalRecipeViewer.vue index 95c92cc41..d2f366afc 100644 --- a/vue3/src/components/display/ExternalRecipeViewer.vue +++ b/vue3/src/components/display/ExternalRecipeViewer.vue @@ -1,6 +1,6 @@