mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-24 02:39:20 -05:00
fixed external recipe viewer
This commit is contained in:
31
cookbook/templates/pdf_viewer.html
Normal file
31
cookbook/templates/pdf_viewer.html
Normal file
@@ -0,0 +1,31 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" height="100%">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>PDF</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>PDF</title>
|
||||
<style>
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden; /* Prevent scrollbars on the body itself */
|
||||
}
|
||||
|
||||
iframe {
|
||||
display: block; /* Prevents potential extra space below the iframe */
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none; /* Remove default iframe border */
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body >
|
||||
|
||||
<iframe src="{% static 'pdfjs/web/viewer.html' %}?file={% url 'api_get_recipe_file' recipe_id %}" ></iframe>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -100,12 +100,13 @@ urlpatterns = [
|
||||
path('edit/recipe/convert/<int:pk>/', edit.convert_recipe, name='edit_convert_recipe'),
|
||||
path('edit/storage/<int:pk>/', edit.edit_storage, name='edit_storage'),
|
||||
path('delete/recipe-source/<int:pk>/', delete.delete_recipe_source, name='delete_recipe_source'),
|
||||
path('view-recipe-pdf/<int:pk>/', views.recipe_pdf_viewer, name='view_recipe_pdf'),
|
||||
|
||||
# Tandoor v1 redirects
|
||||
path('view/recipe/<int:pk>', views.redirect_recipe_view, name='redirect_recipe_view'),
|
||||
path('view/recipe/<int:pk>/<slug:share>', 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'),
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<v-card class="mt-1 h-100">
|
||||
<iframe width="100%" height="700px" :src="`${getDjangoUrl('/static/pdfjs/web/viewer.html', false)}?file=${getDjangoUrl('/api/get_recipe_file/')}${props.recipe.id}/`" v-if="isPdf"></iframe>
|
||||
<iframe width="100%" height="700px" :src="`${getDjangoUrl('/view-recipe-pdf/')}${props.recipe.id}/`" v-if="isPdf"></iframe>
|
||||
|
||||
<v-img :src="`${getDjangoUrl('/api/get_recipe_file/')}${props.recipe.id}/`" v-if="isImage"></v-img>
|
||||
</v-card>
|
||||
|
||||
Reference in New Issue
Block a user