<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
// use App\Utils\Gpx;
class MainController extends AbstractController
{
/**
* @Route("/", name="homepage")
* @Route("/", name="app_homepage")
*/
public function index(): Response
{
$txt = $this->renderView('main/index.markdown.twig', [
'title' => "Accueil",
]);
$html = sf()->convertMarkdown($txt);
// return new Response($html);
return $this->render('base.html.twig', [
'main' => $html,
]);
// Pour mémoire : version standard twig en html
// return $this->render('main/index.html.twig', [
// 'title' => "Accueil"
// ]);
}
/**
* @Route("/tools", name="app_main_tools")
*/
public function tools(): Response
{
$txt = $this->renderView('main/tools.markdown.twig', [
'title' => "Outils",
]);
$html = sf()->convertMarkdown($txt);
// return new Response($html);
return $this->render('base.html.twig', [
'main' => $html,
]);
}
/**
* @Route("/randomoissy", name="app_main_randomoissy")
*/
public function randomoissy() {
$txt = $this->renderView('main/randomoissy.markdown.twig', [
'title' => "Randomoissy",
]);
$html = sf()->convertMarkdown($txt);
// return new Response($html);
return $this->render('base.html.twig', [
'main' => $html,
]);
}
/**
* @Route("/randos", name="app_main_randos")
*/
public function randos() {
$html = $this->renderView('main/randos.html.twig', [
'title' => "Randos",
]);
// $html = sf()->convertMarkdown($txt);
// return new Response($html);
return $this->render('base.html.twig', [
'main' => $html,
]);
}
/**
* @Route("/randos_old", name="app_main_randos_old")
*/
public function randos_old() {
$html = $this->renderView('main/randos_old.html.twig', [
'title' => "Randos",
]);
// $html = sf()->convertMarkdown($txt);
// return new Response($html);
return $this->render('base.html.twig', [
'main' => $html,
]);
}
/**
* @Route("/show_gpx", name="app_main_show_gpx")
*/
public function show_gpx(Request $request) {
$file_default = "gpx/rougeau/rougeau-MN-9.20km-or9241313/rougeau-MN-9.20km-or9241313-1660117195-373.gpx";
$file = $request->query->get("file", $file_default);
// Test de la lib phpGPX
$gpx = new \App\Utils\Gpx($file);
// \madi\mdlib\prt($gpx->getKm(), '$gpx->getKm()');
// \madi\mdlib\prt($gpx->getInfos(), '$gpx->getInfos()');
// dump($file);
// dd($request);
$full = (bool)$request->query->get("full", false);
// $width = $request->query->get("width", "50vw"); // 50% équivaux à 0 !!
$width = $request->query->get("width", "400pt");
$height = $request->query->get("height", "400pt");
// $height = $request->query->get("height", "800pt");
if ($full) {
// $height = "100%";
// $height = "20rem";
return $this->render('main/show_gpx_full.html.twig', [
'title' => "Trace GPX",
'file' => $file,
'width' => $width,
'height' => $height,
'gpx' => $gpx,
]);
} else {
return $this->render('main/show_gpx.html.twig', [
'title' => "Trace GPX",
'file' => $file,
'width' => $width,
'height' => $height,
'gpx' => $gpx,
]);
}
}
/**
* @Route("/show_gpx_full", name="app_main_show_gpx_full")
*/
public function show_gpx_full(Request $request) {
// $full = (bool)$request->query->get("full", true);
// $request->query->set("full", $full);
$request->query->set("full", true);
$request->query->set("width", "100vw");
// $request->query->set("width", "80vw");
// $request->query->set("height", "98vh"); // ori good
$request->query->set("height", "150vh");
return $this->show_gpx($request);
}
}