src/App/Controller/MainController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. // use App\Utils\Gpx;
  8. class MainController extends AbstractController
  9. {
  10. /**
  11. * @Route("/", name="homepage")
  12. * @Route("/", name="app_homepage")
  13. */
  14. public function index(): Response
  15. {
  16. $txt = $this->renderView('main/index.markdown.twig', [
  17. 'title' => "Accueil",
  18. ]);
  19. $html = sf()->convertMarkdown($txt);
  20. // return new Response($html);
  21. return $this->render('base.html.twig', [
  22. 'main' => $html,
  23. ]);
  24. // Pour mémoire : version standard twig en html
  25. // return $this->render('main/index.html.twig', [
  26. // 'title' => "Accueil"
  27. // ]);
  28. }
  29. /**
  30. * @Route("/tools", name="app_main_tools")
  31. */
  32. public function tools(): Response
  33. {
  34. $txt = $this->renderView('main/tools.markdown.twig', [
  35. 'title' => "Outils",
  36. ]);
  37. $html = sf()->convertMarkdown($txt);
  38. // return new Response($html);
  39. return $this->render('base.html.twig', [
  40. 'main' => $html,
  41. ]);
  42. }
  43. /**
  44. * @Route("/randomoissy", name="app_main_randomoissy")
  45. */
  46. public function randomoissy() {
  47. $txt = $this->renderView('main/randomoissy.markdown.twig', [
  48. 'title' => "Randomoissy",
  49. ]);
  50. $html = sf()->convertMarkdown($txt);
  51. // return new Response($html);
  52. return $this->render('base.html.twig', [
  53. 'main' => $html,
  54. ]);
  55. }
  56. /**
  57. * @Route("/randos", name="app_main_randos")
  58. */
  59. public function randos() {
  60. $html = $this->renderView('main/randos.html.twig', [
  61. 'title' => "Randos",
  62. ]);
  63. // $html = sf()->convertMarkdown($txt);
  64. // return new Response($html);
  65. return $this->render('base.html.twig', [
  66. 'main' => $html,
  67. ]);
  68. }
  69. /**
  70. * @Route("/randos_old", name="app_main_randos_old")
  71. */
  72. public function randos_old() {
  73. $html = $this->renderView('main/randos_old.html.twig', [
  74. 'title' => "Randos",
  75. ]);
  76. // $html = sf()->convertMarkdown($txt);
  77. // return new Response($html);
  78. return $this->render('base.html.twig', [
  79. 'main' => $html,
  80. ]);
  81. }
  82. /**
  83. * @Route("/show_gpx", name="app_main_show_gpx")
  84. */
  85. public function show_gpx(Request $request) {
  86. $file_default = "gpx/rougeau/rougeau-MN-9.20km-or9241313/rougeau-MN-9.20km-or9241313-1660117195-373.gpx";
  87. $file = $request->query->get("file", $file_default);
  88. // Test de la lib phpGPX
  89. $gpx = new \App\Utils\Gpx($file);
  90. // \madi\mdlib\prt($gpx->getKm(), '$gpx->getKm()');
  91. // \madi\mdlib\prt($gpx->getInfos(), '$gpx->getInfos()');
  92. // dump($file);
  93. // dd($request);
  94. $full = (bool)$request->query->get("full", false);
  95. // $width = $request->query->get("width", "50vw"); // 50% équivaux à 0 !!
  96. $width = $request->query->get("width", "400pt");
  97. $height = $request->query->get("height", "400pt");
  98. // $height = $request->query->get("height", "800pt");
  99. if ($full) {
  100. // $height = "100%";
  101. // $height = "20rem";
  102. return $this->render('main/show_gpx_full.html.twig', [
  103. 'title' => "Trace GPX",
  104. 'file' => $file,
  105. 'width' => $width,
  106. 'height' => $height,
  107. 'gpx' => $gpx,
  108. ]);
  109. } else {
  110. return $this->render('main/show_gpx.html.twig', [
  111. 'title' => "Trace GPX",
  112. 'file' => $file,
  113. 'width' => $width,
  114. 'height' => $height,
  115. 'gpx' => $gpx,
  116. ]);
  117. }
  118. }
  119. /**
  120. * @Route("/show_gpx_full", name="app_main_show_gpx_full")
  121. */
  122. public function show_gpx_full(Request $request) {
  123. // $full = (bool)$request->query->get("full", true);
  124. // $request->query->set("full", $full);
  125. $request->query->set("full", true);
  126. $request->query->set("width", "100vw");
  127. // $request->query->set("width", "80vw");
  128. // $request->query->set("height", "98vh"); // ori good
  129. $request->query->set("height", "150vh");
  130. return $this->show_gpx($request);
  131. }
  132. }