diff --git a/config/services.yaml b/config/services.yaml index ce509b2..0ac630b 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -34,3 +34,11 @@ services: App\Command\MaintenanceCommand: arguments: $projectDir: '%kernel.project_dir%' + + App\Event\Seo\SeoBlockerSubscriber: + arguments: + $projectDir: '%kernel.project_dir%' + + App\Twig\OnlineExtension: + arguments: + $projectDir: '%kernel.project_dir%' diff --git a/src/Controller/ReserverController.php b/src/Controller/ReserverController.php index 9b0e1ab..9512741 100644 --- a/src/Controller/ReserverController.php +++ b/src/Controller/ReserverController.php @@ -182,11 +182,20 @@ class ReserverController extends AbstractController public function index(Request $request): Response { $robots = new RobotsTxt(); - $robots->disallow('/signature'); - $robots->disallow('/payment'); - $robots->crawlDelay(60); - $robots->allow('/reservation'); - $robots->sitemap($request->getSchemeAndHttpHost().'/seo/sitemap.xml'); + + if (!file_exists($this->kernel->getProjectDir() . '/var/.online')) { + $robots->disallow('/'); + } else { + $robots->disallow('/signature'); + $robots->disallow('/payment'); + $robots->disallow('/paiment'); + $robots->disallow('/intranet'); + $robots->disallow('/crm'); + $robots->disallow('/etl'); + $robots->crawlDelay(60); + $robots->allow('/reservation'); + $robots->sitemap($request->getSchemeAndHttpHost().'/seo/sitemap.xml'); + } return new Response($robots->toString(), Response::HTTP_OK, [ 'Content-Type' => 'text/plain' diff --git a/src/Event/Seo/SeoBlockerSubscriber.php b/src/Event/Seo/SeoBlockerSubscriber.php new file mode 100644 index 0000000..febfa28 --- /dev/null +++ b/src/Event/Seo/SeoBlockerSubscriber.php @@ -0,0 +1,43 @@ +projectDir = $projectDir; + } + + public static function getSubscribedEvents(): array + { + return [ + KernelEvents::RESPONSE => 'onKernelResponse', + ]; + } + + public function onKernelResponse(ResponseEvent $event): void + { + $request = $event->getRequest(); + $path = $request->getPathInfo(); + + $blockedPaths = ['/intranet', '/signature', '/paiment', '/payment', '/crm', '/etl']; + foreach ($blockedPaths as $blockedPath) { + if (str_starts_with($path, $blockedPath)) { + $event->getResponse()->headers->set('X-Robots-Tag', 'noindex, nofollow'); + return; + } + } + + // Check if var/.online exists + if (!file_exists($this->projectDir . '/var/.online')) { + $event->getResponse()->headers->set('X-Robots-Tag', 'noindex, nofollow'); + } + } +} diff --git a/src/Twig/OnlineExtension.php b/src/Twig/OnlineExtension.php new file mode 100644 index 0000000..08578fd --- /dev/null +++ b/src/Twig/OnlineExtension.php @@ -0,0 +1,28 @@ +projectDir = $projectDir; + } + + public function getFunctions(): array + { + return [ + new TwigFunction('is_online', [$this, 'isOnline']), + ]; + } + + public function isOnline(): bool + { + return file_exists($this->projectDir . '/var/.online'); + } +} diff --git a/templates/base.twig b/templates/base.twig index 2d30fe5..0b911a8 100644 --- a/templates/base.twig +++ b/templates/base.twig @@ -7,7 +7,6 @@ Ludikevent | {% block title %}Accueil{% endblock %} - {{ vite_asset('app.js', []) }} {% if app.environment != 'dev'%} diff --git a/templates/dashboard/base.twig b/templates/dashboard/base.twig index e93549d..e16e53a 100644 --- a/templates/dashboard/base.twig +++ b/templates/dashboard/base.twig @@ -12,6 +12,12 @@ +{% if not is_online() %} +
+ Votre site internet n'est actuellement pas en ligne. Aucun référencement n'est possible. Pour demander sa mise en ligne, rendez-vous dans votre intranet pour effectuer la demande d'activation. +
+{% endif %} +
{# SIDEBAR #} diff --git a/templates/dashboard/home.twig b/templates/dashboard/home.twig index d68702e..454278b 100644 --- a/templates/dashboard/home.twig +++ b/templates/dashboard/home.twig @@ -44,6 +44,27 @@ {% block body %}
+ {# --- ACTIVATION SECTION (OFFLINE ONLY) --- #} + {% if not is_online() %} +
+
+
+
+

Mise en ligne

+

Activation du site internet

+

+ Une fois la demande faite, vous serez invité à signer le certificat de mise en ligne. En le signant, vous reconnaissez que la fin du développement de l'intranet est conforme au cahier des charges établi. Une fois signé, toute modification sera facturée. +

+
+
+ +
+
+
+ {% endif %} + {# --- HEADER STATS (GLASS PILLS) --- #}
diff --git a/templates/revervation/base.twig b/templates/revervation/base.twig index 733fdd4..bd1dd02 100644 --- a/templates/revervation/base.twig +++ b/templates/revervation/base.twig @@ -83,6 +83,12 @@ +{% if not is_online() %} +
+ Votre site internet n'est actuellement pas en ligne. Aucun référencement n'est possible. Pour demander sa mise en ligne, rendez-vous dans votre intranet pour effectuer la demande d'activation. +
+{% endif %} + {% if is_granted('ROLE_USER') %} {% endif %}