From 6e1ac908e01893a4e9dc8dc8ef56b5d896e84c23 Mon Sep 17 00:00:00 2001 From: Sebastien Curt <sebastien.curt@tetras-libre.fr> Date: Tue, 18 Jan 2022 15:56:46 +0100 Subject: [PATCH] show preview of capsule within /preview/{capsule_path} url --- config/packages/security.yaml | 2 +- src/Controller/CapsuleController.php | 13 +++++++++++ templates/capsule/index.html.twig | 4 ++-- templates/capsule/preview.html.twig | 35 ++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 templates/capsule/preview.html.twig diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 9a6f39d..d13aa02 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -34,4 +34,4 @@ security: # switch_user: true access_control: - - { path: ^/(?!register|login|generate-captcha|verify/email|reset-password), roles: ROLE_USER } \ No newline at end of file + - { path: ^/(?!register|login|generate-captcha|verify/email|reset-password|preview|legacy), roles: ROLE_USER } \ No newline at end of file diff --git a/src/Controller/CapsuleController.php b/src/Controller/CapsuleController.php index 6591914..e49221a 100644 --- a/src/Controller/CapsuleController.php +++ b/src/Controller/CapsuleController.php @@ -79,4 +79,17 @@ class CapsuleController extends AbstractController 'capsuleCreationForm' => $form->createView() ]); } + + /** + * @Route("/preview/{path}", name="preview_capsule") + */ + public function preview(string $path): Response + { + $url = $this->getParameter('app.legacy_external_prefix') . '/' . $path . "/?w=1"; + + return $this->render( + 'capsule/preview.html.twig', + [ 'url' => $url ] + ); + } } diff --git a/templates/capsule/index.html.twig b/templates/capsule/index.html.twig index d120f01..e5e772b 100644 --- a/templates/capsule/index.html.twig +++ b/templates/capsule/index.html.twig @@ -39,7 +39,7 @@ <div class="capsule-item pb-4 m-5"> <div class="d-flex flex-column flex-md-row justify-content-center align-items-center mt-sm-4"> <div class="list-item"> - <a href="{{ capsule.getEditionLink() }}" class="capsule-title"> + <a href="/preview/{{ capsule.getPreviewLink() }}/?w=1" class="capsule-title"> {{ capsule.getName() }} </a> </div> @@ -51,7 +51,7 @@ <div class="d-flex flex-column flex-md-row justify-content-center align-items-center"> <div class="m-4 ratio ratio-16x9"> <iframe - src="{{ legacy_url }}/{{ capsule.getPreviewLink() }}/?p=read" + src="/preview/{{ capsule.getPreviewLink() }}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen> </iframe> diff --git a/templates/capsule/preview.html.twig b/templates/capsule/preview.html.twig new file mode 100644 index 0000000..650a202 --- /dev/null +++ b/templates/capsule/preview.html.twig @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="UTF-8"> + <title>{% block title %}MemoRekall{% endblock %}</title> + + {% block stylesheets %} + {{ encore_entry_link_tags('app') }} + {% endblock %} + + {% block javascripts %} + {{ encore_entry_script_tags('app') }} + {% endblock %} + + <link rel="icon" type="image/x-icon" href="{{ asset('build/images/favicon.ico') }}" /> + +</head> + +<body class="container col-10 col-md-8 col-lg-6 m-auto"> + + <div class="position-relative d-flex flex-row align-items-center justify-content-center mb-5"> + <img id="header-memorekall-logo" class="memorekall-logo" src="{{ asset('build/images/MemoRekall.png') }}"> + </div> + + <iframe src="{{ url }}" + style="width:100%;height:100%;top:0;left:0;position:absolute" + + frameborder="0" + webkitallowfullscreen + mozallowfullscreen + allowfullscreen> + </iframe> + +</body> +</html> -- GitLab