mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 11:30:55 +01:00
Merge branch '404'
This commit is contained in:
commit
39a976ae7f
12 changed files with 178 additions and 1 deletions
|
@ -34,6 +34,15 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'disk' => '/rsrc/css/aphront/panel-view.css',
|
'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' =>
|
'aphront-side-nav-view-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/0fc0545c/rsrc/css/aphront/side-nav-view.css',
|
'uri' => '/res/0fc0545c/rsrc/css/aphront/side-nav-view.css',
|
||||||
|
|
|
@ -45,6 +45,7 @@ phutil_register_library_map(array(
|
||||||
'AphrontRedirectException' => 'aphront/exception/redirect',
|
'AphrontRedirectException' => 'aphront/exception/redirect',
|
||||||
'AphrontRedirectResponse' => 'aphront/response/redirect',
|
'AphrontRedirectResponse' => 'aphront/response/redirect',
|
||||||
'AphrontRequest' => 'aphront/request',
|
'AphrontRequest' => 'aphront/request',
|
||||||
|
'AphrontRequestFailureView' => 'view/page/failure',
|
||||||
'AphrontResponse' => 'aphront/response/base',
|
'AphrontResponse' => 'aphront/response/base',
|
||||||
'AphrontSideNavView' => 'view/layout/sidenav',
|
'AphrontSideNavView' => 'view/layout/sidenav',
|
||||||
'AphrontTableView' => 'view/control/table',
|
'AphrontTableView' => 'view/control/table',
|
||||||
|
@ -97,6 +98,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus',
|
'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus',
|
||||||
'Javelin' => 'infratructure/javelin/api',
|
'Javelin' => 'infratructure/javelin/api',
|
||||||
'LiskDAO' => 'storage/lisk/dao',
|
'LiskDAO' => 'storage/lisk/dao',
|
||||||
|
'Phabricator404Controller' => 'applications/base/controller/404',
|
||||||
'PhabricatorAuthController' => 'applications/auth/controlller/base',
|
'PhabricatorAuthController' => 'applications/auth/controlller/base',
|
||||||
'PhabricatorConduitAPIController' => 'applications/conduit/controller/api',
|
'PhabricatorConduitAPIController' => 'applications/conduit/controller/api',
|
||||||
'PhabricatorConduitConnectionLog' => 'applications/conduit/storage/connectionlog',
|
'PhabricatorConduitConnectionLog' => 'applications/conduit/storage/connectionlog',
|
||||||
|
@ -209,6 +211,7 @@ phutil_register_library_map(array(
|
||||||
'AphrontQueryRecoverableException' => 'AphrontQueryException',
|
'AphrontQueryRecoverableException' => 'AphrontQueryException',
|
||||||
'AphrontRedirectException' => 'AphrontException',
|
'AphrontRedirectException' => 'AphrontException',
|
||||||
'AphrontRedirectResponse' => 'AphrontResponse',
|
'AphrontRedirectResponse' => 'AphrontResponse',
|
||||||
|
'AphrontRequestFailureView' => 'AphrontView',
|
||||||
'AphrontSideNavView' => 'AphrontView',
|
'AphrontSideNavView' => 'AphrontView',
|
||||||
'AphrontTableView' => 'AphrontView',
|
'AphrontTableView' => 'AphrontView',
|
||||||
'AphrontWebpageResponse' => 'AphrontResponse',
|
'AphrontWebpageResponse' => 'AphrontResponse',
|
||||||
|
@ -240,6 +243,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionListController' => 'DifferentialController',
|
'DifferentialRevisionListController' => 'DifferentialController',
|
||||||
'DifferentialRevisionUpdateHistoryView' => 'AphrontView',
|
'DifferentialRevisionUpdateHistoryView' => 'AphrontView',
|
||||||
'DifferentialRevisionViewController' => 'DifferentialController',
|
'DifferentialRevisionViewController' => 'DifferentialController',
|
||||||
|
'Phabricator404Controller' => 'PhabricatorController',
|
||||||
'PhabricatorAuthController' => 'PhabricatorController',
|
'PhabricatorAuthController' => 'PhabricatorController',
|
||||||
'PhabricatorConduitAPIController' => 'PhabricatorConduitController',
|
'PhabricatorConduitAPIController' => 'PhabricatorConduitController',
|
||||||
'PhabricatorConduitConnectionLog' => 'PhabricatorConduitDAO',
|
'PhabricatorConduitConnectionLog' => 'PhabricatorConduitDAO',
|
||||||
|
|
|
@ -28,6 +28,7 @@ abstract class AphrontApplicationConfiguration {
|
||||||
abstract public function getApplicationName();
|
abstract public function getApplicationName();
|
||||||
abstract public function getURIMap();
|
abstract public function getURIMap();
|
||||||
abstract public function buildRequest();
|
abstract public function buildRequest();
|
||||||
|
abstract public function build404Controller();
|
||||||
|
|
||||||
final public function setRequest(AphrontRequest $request) {
|
final public function setRequest(AphrontRequest $request) {
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
|
@ -45,6 +46,10 @@ abstract class AphrontApplicationConfiguration {
|
||||||
$path = $request->getPath();
|
$path = $request->getPath();
|
||||||
list($controller_class, $uri_data) = $mapper->mapPath($path);
|
list($controller_class, $uri_data) = $mapper->mapPath($path);
|
||||||
|
|
||||||
|
if (!$controller_class) {
|
||||||
|
return $this->build404Controller();
|
||||||
|
}
|
||||||
|
|
||||||
PhutilSymbolLoader::loadClass($controller_class);
|
PhutilSymbolLoader::loadClass($controller_class);
|
||||||
$controller = newv($controller_class, array($request));
|
$controller = newv($controller_class, array($request));
|
||||||
|
|
||||||
|
|
|
@ -150,10 +150,29 @@ class AphrontDefaultApplicationConfiguration
|
||||||
$response->setContent($view->render());
|
$response->setContent($view->render());
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
} else if ($response instanceof Aphront404Response) {
|
||||||
|
|
||||||
|
$failure = new AphrontRequestFailureView();
|
||||||
|
$failure->setHeader('404 Not Found');
|
||||||
|
$failure->appendChild(
|
||||||
|
'<p>The page you requested was not found.</p>');
|
||||||
|
|
||||||
|
$view = new PhabricatorStandardPageView();
|
||||||
|
$view->setTitle('404 Not Found');
|
||||||
|
$view->appendChild($failure);
|
||||||
|
|
||||||
|
$response = new AphrontWebpageResponse();
|
||||||
|
$response->setContent($view->render());
|
||||||
|
$response->setHTTPResponseCode(404);
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function build404Controller() {
|
||||||
|
return array(new Phabricator404Controller($this->getRequest()), array());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
phutil_require_module('phabricator', 'aphront/applicationconfiguration');
|
phutil_require_module('phabricator', 'aphront/applicationconfiguration');
|
||||||
phutil_require_module('phabricator', 'aphront/request');
|
phutil_require_module('phabricator', 'aphront/request');
|
||||||
phutil_require_module('phabricator', 'aphront/response/webpage');
|
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('phabricator', 'view/page/standard');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
|
@ -23,6 +23,7 @@ abstract class AphrontResponse {
|
||||||
|
|
||||||
private $request;
|
private $request;
|
||||||
private $cacheable = false;
|
private $cacheable = false;
|
||||||
|
private $responseCode = 200;
|
||||||
|
|
||||||
public function setRequest($request) {
|
public function setRequest($request) {
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
|
@ -36,12 +37,21 @@ abstract class AphrontResponse {
|
||||||
public function getHeaders() {
|
public function getHeaders() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCacheDurationInSeconds($duration) {
|
public function setCacheDurationInSeconds($duration) {
|
||||||
$this->cacheable = $duration;
|
$this->cacheable = $duration;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setHTTPResponseCode($code) {
|
||||||
|
$this->responseCode = $code;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHTTPResponseCode() {
|
||||||
|
return $this->responseCode;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCacheHeaders() {
|
public function getCacheHeaders() {
|
||||||
if ($this->cacheable) {
|
if ($this->cacheable) {
|
||||||
$epoch = time() + $this->cacheable;
|
$epoch = time() + $this->cacheable;
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Phabricator404Controller extends PhabricatorController {
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
13
src/applications/base/controller/404/__init__.php
Normal file
13
src/applications/base/controller/404/__init__.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/404');
|
||||||
|
phutil_require_module('phabricator', 'applications/base/controller/base');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('Phabricator404Controller.php');
|
43
src/view/page/failure/AphrontRequestFailureView.php
Executable file
43
src/view/page/failure/AphrontRequestFailureView.php
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
final class AphrontRequestFailureView extends AphrontView {
|
||||||
|
|
||||||
|
private $header;
|
||||||
|
|
||||||
|
public function setHeader($header) {
|
||||||
|
$this->header = $header;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final public function render() {
|
||||||
|
require_celerity_resource('aphront-request-failure-view-css');
|
||||||
|
|
||||||
|
return
|
||||||
|
'<div class="aphront-request-failure-view">'.
|
||||||
|
'<div class="aphront-request-failure-head">'.
|
||||||
|
'<h1>'.phutil_escape_html($this->header).'</h1>'.
|
||||||
|
'</div>'.
|
||||||
|
'<div class="aphront-request-failure-body">'.
|
||||||
|
$this->renderChildren().
|
||||||
|
'</div>'.
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
14
src/view/page/failure/__init__.php
Normal file
14
src/view/page/failure/__init__.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'view/base');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('AphrontRequestFailureView.php');
|
|
@ -55,6 +55,12 @@ $response = $application->willSendResponse($response);
|
||||||
$response->setRequest($request);
|
$response->setRequest($request);
|
||||||
|
|
||||||
$response_string = $response->buildResponseString();
|
$response_string = $response->buildResponseString();
|
||||||
|
|
||||||
|
$code = $response->getHTTPResponseCode();
|
||||||
|
if ($code != 200) {
|
||||||
|
header("HTTP/1.0 {$code}");
|
||||||
|
}
|
||||||
|
|
||||||
$headers = $response->getCacheHeaders();
|
$headers = $response->getCacheHeaders();
|
||||||
$headers = array_merge($headers, $response->getHeaders());
|
$headers = array_merge($headers, $response->getHeaders());
|
||||||
foreach ($headers as $header) {
|
foreach ($headers as $header) {
|
||||||
|
|
27
webroot/rsrc/css/aphront/request-failure-view.css
Normal file
27
webroot/rsrc/css/aphront/request-failure-view.css
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* @provides aphront-request-failure-view-css
|
||||||
|
*/
|
||||||
|
|
||||||
|
.aphront-request-failure-view {
|
||||||
|
margin: 2em auto;
|
||||||
|
background: #eff2f7;
|
||||||
|
width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aphront-request-failure-view .aphront-request-failure-head {
|
||||||
|
padding: 1em 2em;
|
||||||
|
border-bottom: 1px solid #afb2b7;
|
||||||
|
background: #dfe2e7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aphront-request-failure-view .aphront-request-failure-head h1 {
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aphront-request-failure-view .aphront-request-failure-body {
|
||||||
|
padding: 1em 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aphront-request-failure-view .aphront-request-failure-body p {
|
||||||
|
margin: .5em 0 1.25em;
|
||||||
|
}
|
Loading…
Reference in a new issue