From 75391b705336eaf73c0e79fc3663127f602c718d Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sun, 7 May 2017 11:38:31 +0100 Subject: [PATCH] Fix supporting of "artisan down" command. Closes #2458 --- .../Displayers/MaintenanceDisplayer.php | 104 ++++++++++++++++++ .../Providers/ComposerServiceProvider.php | 2 +- config/exceptions.php | 1 + resources/views/errors/maintenance.blade.php | 12 ++ resources/views/index.blade.php | 4 + resources/views/layout/master.blade.php | 2 +- resources/views/signup.blade.php | 4 + resources/views/single-incident.blade.php | 4 + resources/views/single-schedule.blade.php | 4 + 9 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 app/Foundation/Exceptions/Displayers/MaintenanceDisplayer.php create mode 100644 resources/views/errors/maintenance.blade.php diff --git a/app/Foundation/Exceptions/Displayers/MaintenanceDisplayer.php b/app/Foundation/Exceptions/Displayers/MaintenanceDisplayer.php new file mode 100644 index 000000000000..77c583f7a002 --- /dev/null +++ b/app/Foundation/Exceptions/Displayers/MaintenanceDisplayer.php @@ -0,0 +1,104 @@ + + */ +class MaintenanceDisplayer implements DisplayerInterface +{ + /** + * The view factory instance. + * + * @var \Illuminate\Contracts\View\Factory + */ + protected $view; + + /** + * Create a new maintenance displayer instance. + * + * @param \Illuminate\Contracts\View\Factory $view + * + * @return void + */ + public function __construct(Factory $view) + { + $this->view = $view; + } + + /** + * Get the error response associated with the given exception. + * + * @param \Exception $exception + * @param string $id + * @param int $code + * @param string[] $headers + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function display(Exception $exception, $id, $code, array $headers) + { + return new Response($this->render(), $code, array_merge($headers, ['Content-Type' => $this->contentType()])); + } + + /** + * Render the page. + * + * @return string + */ + protected function render() + { + return $this->view->make('errors.maintenance')->render(); + } + + /** + * Get the supported content type. + * + * @return string + */ + public function contentType() + { + return 'text/html'; + } + + /** + * Can we display the exception? + * + * @param \Exception $original + * @param \Exception $transformed + * @param int $code + * + * @return bool + */ + public function canDisplay(Exception $original, Exception $transformed, $code) + { + return $transformed instanceof MaintenanceModeException; + } + + /** + * Do we provide verbose information about the exception? + * + * @return bool + */ + public function isVerbose() + { + return false; + } +} diff --git a/app/Foundation/Providers/ComposerServiceProvider.php b/app/Foundation/Providers/ComposerServiceProvider.php index b1cc0844b336..19ca8fc208b8 100644 --- a/app/Foundation/Providers/ComposerServiceProvider.php +++ b/app/Foundation/Providers/ComposerServiceProvider.php @@ -38,7 +38,7 @@ public function boot(Factory $factory) { $factory->composer('*', AppComposer::class); $factory->composer('*', CurrentUserComposer::class); - $factory->composer(['index', 'single-incident', 'subscribe.*', 'signup', 'dashboard.settings.theme', 'notifications::email', 'single-schedule'], ThemeComposer::class); + $factory->composer(['index', 'single-incident', 'subscribe.*', 'signup', 'dashboard.settings.theme', 'notifications::email', 'single-schedule', 'errors.*'], ThemeComposer::class); $factory->composer('dashboard.*', DashboardComposer::class); $factory->composer(['setup.*', 'dashboard.settings.localization'], TimezoneLocaleComposer::class); diff --git a/config/exceptions.php b/config/exceptions.php index d084355e0b16..d31878908b1b 100644 --- a/config/exceptions.php +++ b/config/exceptions.php @@ -50,6 +50,7 @@ 'CachetHQ\Cachet\Foundation\Exceptions\Displayers\JsonValidationDisplayer', 'CachetHQ\Cachet\Foundation\Exceptions\Displayers\RedirectDisplayer', 'CachetHQ\Cachet\Foundation\Exceptions\Displayers\ThrottleDisplayer', + 'CachetHQ\Cachet\Foundation\Exceptions\Displayers\MaintenanceDisplayer', 'GrahamCampbell\Exceptions\Displayers\DebugDisplayer', 'GrahamCampbell\Exceptions\Displayers\HtmlDisplayer', 'GrahamCampbell\Exceptions\Displayers\JsonDisplayer', diff --git a/resources/views/errors/maintenance.blade.php b/resources/views/errors/maintenance.blade.php new file mode 100644 index 000000000000..a625cc77c5c0 --- /dev/null +++ b/resources/views/errors/maintenance.blade.php @@ -0,0 +1,12 @@ +@extends('layout.master') + +@section('content') +
+
+ Under Maintenance +
+
+

We're currently under maintnenance, come back shortly.

+
+
+@stop diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index f25348891171..07742bb47927 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -3,3 +3,7 @@ @section('content') @modules @stop + +@section('bottom-content') +@include('partials.footer') +@stop diff --git a/resources/views/layout/master.blade.php b/resources/views/layout/master.blade.php index ba5a12e4ee3f..422ff14f336b 100644 --- a/resources/views/layout/master.blade.php +++ b/resources/views/layout/master.blade.php @@ -76,6 +76,6 @@ @yield('content') - @include('partials.footer') + @yield('bottom-content') diff --git a/resources/views/signup.blade.php b/resources/views/signup.blade.php index e8e2aeb4d9d7..a81a45625325 100644 --- a/resources/views/signup.blade.php +++ b/resources/views/signup.blade.php @@ -45,3 +45,7 @@ @stop + +@section('bottom-content') +@include('partials.footer') +@stop diff --git a/resources/views/single-incident.blade.php b/resources/views/single-incident.blade.php index b576bccc10d5..f05bfbd3578d 100644 --- a/resources/views/single-incident.blade.php +++ b/resources/views/single-incident.blade.php @@ -43,3 +43,7 @@ @endif @stop + +@section('bottom-content') +@include('partials.footer') +@stop diff --git a/resources/views/single-schedule.blade.php b/resources/views/single-schedule.blade.php index f85095d89a12..c47851aa8104 100644 --- a/resources/views/single-schedule.blade.php +++ b/resources/views/single-schedule.blade.php @@ -33,3 +33,7 @@ @stop + +@section('bottom-content') +@include('partials.footer') +@stop