From 406a14ebe519aef7906d199649b58d4dcf8a8135 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 30 Jan 2011 09:15:01 -0800 Subject: [PATCH] Make 404 page somewhat prettier. --- src/__celerity_resource_map__.php | 9 ++++ src/__phutil_library_map__.php | 2 + ...AphrontDefaultApplicationConfiguration.php | 10 ++++- .../default/configuration/__init__.php | 1 + src/aphront/response/base/AphrontResponse.php | 6 +-- .../failure/AphrontRequestFailureView.php | 43 +++++++++++++++++++ src/view/page/failure/__init__.php | 14 ++++++ .../rsrc/css/aphront/request-failure-view.css | 27 ++++++++++++ 8 files changed, 107 insertions(+), 5 deletions(-) create mode 100755 src/view/page/failure/AphrontRequestFailureView.php create mode 100644 src/view/page/failure/__init__.php create mode 100644 webroot/rsrc/css/aphront/request-failure-view.css diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 1500a5ed97..7c73c57ed0 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -34,6 +34,15 @@ celerity_register_resource_map(array( ), 'disk' => '/rsrc/css/aphront/panel-view.css', ), + 'aphront-request-failure-view-css' => + array( + 'uri' => '/res/d7df3b42/rsrc/css/aphront/request-failure-view.css', + 'type' => 'css', + 'requires' => + array( + ), + 'disk' => '/rsrc/css/aphront/request-failure-view.css', + ), 'aphront-side-nav-view-css' => array( 'uri' => '/res/0fc0545c/rsrc/css/aphront/side-nav-view.css', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 74defb7455..d7dc179c5a 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -45,6 +45,7 @@ phutil_register_library_map(array( 'AphrontRedirectException' => 'aphront/exception/redirect', 'AphrontRedirectResponse' => 'aphront/response/redirect', 'AphrontRequest' => 'aphront/request', + 'AphrontRequestFailureView' => 'view/page/failure', 'AphrontResponse' => 'aphront/response/base', 'AphrontSideNavView' => 'view/layout/sidenav', 'AphrontTableView' => 'view/control/table', @@ -210,6 +211,7 @@ phutil_register_library_map(array( 'AphrontQueryRecoverableException' => 'AphrontQueryException', 'AphrontRedirectException' => 'AphrontException', 'AphrontRedirectResponse' => 'AphrontResponse', + 'AphrontRequestFailureView' => 'AphrontView', 'AphrontSideNavView' => 'AphrontView', 'AphrontTableView' => 'AphrontView', 'AphrontWebpageResponse' => 'AphrontResponse', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index d040b13277..ee7c71caa6 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -151,10 +151,16 @@ class AphrontDefaultApplicationConfiguration return $response; } } else if ($response instanceof Aphront404Response) { + + $failure = new AphrontRequestFailureView(); + $failure->setHeader('404 Not Found'); + $failure->appendChild( + '

The page you requested was not found.

'); + $view = new PhabricatorStandardPageView(); - $view->appendChild('404 Not Found'); $view->setTitle('404 Not Found'); - + $view->appendChild($failure); + $response = new AphrontWebpageResponse(); $response->setContent($view->render()); $response->setHTTPResponseCode(404); diff --git a/src/aphront/default/configuration/__init__.php b/src/aphront/default/configuration/__init__.php index 66935aa326..ea6f86450a 100644 --- a/src/aphront/default/configuration/__init__.php +++ b/src/aphront/default/configuration/__init__.php @@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'aphront/applicationconfiguration'); phutil_require_module('phabricator', 'aphront/request'); phutil_require_module('phabricator', 'aphront/response/webpage'); phutil_require_module('phabricator', 'applications/base/controller/404'); +phutil_require_module('phabricator', 'view/page/failure'); phutil_require_module('phabricator', 'view/page/standard'); phutil_require_module('phutil', 'markup'); diff --git a/src/aphront/response/base/AphrontResponse.php b/src/aphront/response/base/AphrontResponse.php index c8ea750562..786f56b77e 100644 --- a/src/aphront/response/base/AphrontResponse.php +++ b/src/aphront/response/base/AphrontResponse.php @@ -37,17 +37,17 @@ abstract class AphrontResponse { public function getHeaders() { return array(); } - + public function setCacheDurationInSeconds($duration) { $this->cacheable = $duration; return $this; } - + public function setHTTPResponseCode($code) { $this->responseCode = $code; return $this; } - + public function getHTTPResponseCode() { return $this->responseCode; } diff --git a/src/view/page/failure/AphrontRequestFailureView.php b/src/view/page/failure/AphrontRequestFailureView.php new file mode 100755 index 0000000000..832838e921 --- /dev/null +++ b/src/view/page/failure/AphrontRequestFailureView.php @@ -0,0 +1,43 @@ +header = $header; + return $this; + } + + + final public function render() { + require_celerity_resource('aphront-request-failure-view-css'); + + return + '
'. + '
'. + '

'.phutil_escape_html($this->header).'

'. + '
'. + '
'. + $this->renderChildren(). + '
'. + '
'; + } + +} diff --git a/src/view/page/failure/__init__.php b/src/view/page/failure/__init__.php new file mode 100644 index 0000000000..e753355fdb --- /dev/null +++ b/src/view/page/failure/__init__.php @@ -0,0 +1,14 @@ +