@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch '404'

+178 -1
+9
src/__celerity_resource_map__.php
··· 34 34 ), 35 35 'disk' => '/rsrc/css/aphront/panel-view.css', 36 36 ), 37 + 'aphront-request-failure-view-css' => 38 + array( 39 + 'uri' => '/res/d7df3b42/rsrc/css/aphront/request-failure-view.css', 40 + 'type' => 'css', 41 + 'requires' => 42 + array( 43 + ), 44 + 'disk' => '/rsrc/css/aphront/request-failure-view.css', 45 + ), 37 46 'aphront-side-nav-view-css' => 38 47 array( 39 48 'uri' => '/res/0fc0545c/rsrc/css/aphront/side-nav-view.css',
+4
src/__phutil_library_map__.php
··· 45 45 'AphrontRedirectException' => 'aphront/exception/redirect', 46 46 'AphrontRedirectResponse' => 'aphront/response/redirect', 47 47 'AphrontRequest' => 'aphront/request', 48 + 'AphrontRequestFailureView' => 'view/page/failure', 48 49 'AphrontResponse' => 'aphront/response/base', 49 50 'AphrontSideNavView' => 'view/layout/sidenav', 50 51 'AphrontTableView' => 'view/control/table', ··· 97 98 'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus', 98 99 'Javelin' => 'infratructure/javelin/api', 99 100 'LiskDAO' => 'storage/lisk/dao', 101 + 'Phabricator404Controller' => 'applications/base/controller/404', 100 102 'PhabricatorAuthController' => 'applications/auth/controlller/base', 101 103 'PhabricatorConduitAPIController' => 'applications/conduit/controller/api', 102 104 'PhabricatorConduitConnectionLog' => 'applications/conduit/storage/connectionlog', ··· 209 211 'AphrontQueryRecoverableException' => 'AphrontQueryException', 210 212 'AphrontRedirectException' => 'AphrontException', 211 213 'AphrontRedirectResponse' => 'AphrontResponse', 214 + 'AphrontRequestFailureView' => 'AphrontView', 212 215 'AphrontSideNavView' => 'AphrontView', 213 216 'AphrontTableView' => 'AphrontView', 214 217 'AphrontWebpageResponse' => 'AphrontResponse', ··· 240 243 'DifferentialRevisionListController' => 'DifferentialController', 241 244 'DifferentialRevisionUpdateHistoryView' => 'AphrontView', 242 245 'DifferentialRevisionViewController' => 'DifferentialController', 246 + 'Phabricator404Controller' => 'PhabricatorController', 243 247 'PhabricatorAuthController' => 'PhabricatorController', 244 248 'PhabricatorConduitAPIController' => 'PhabricatorConduitController', 245 249 'PhabricatorConduitConnectionLog' => 'PhabricatorConduitDAO',
+5
src/aphront/applicationconfiguration/AphrontApplicationConfiguration.php
··· 28 28 abstract public function getApplicationName(); 29 29 abstract public function getURIMap(); 30 30 abstract public function buildRequest(); 31 + abstract public function build404Controller(); 31 32 32 33 final public function setRequest(AphrontRequest $request) { 33 34 $this->request = $request; ··· 44 45 $request = $this->getRequest(); 45 46 $path = $request->getPath(); 46 47 list($controller_class, $uri_data) = $mapper->mapPath($path); 48 + 49 + if (!$controller_class) { 50 + return $this->build404Controller(); 51 + } 47 52 48 53 PhutilSymbolLoader::loadClass($controller_class); 49 54 $controller = newv($controller_class, array($request));
+19
src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php
··· 150 150 $response->setContent($view->render()); 151 151 return $response; 152 152 } 153 + } else if ($response instanceof Aphront404Response) { 154 + 155 + $failure = new AphrontRequestFailureView(); 156 + $failure->setHeader('404 Not Found'); 157 + $failure->appendChild( 158 + '<p>The page you requested was not found.</p>'); 159 + 160 + $view = new PhabricatorStandardPageView(); 161 + $view->setTitle('404 Not Found'); 162 + $view->appendChild($failure); 163 + 164 + $response = new AphrontWebpageResponse(); 165 + $response->setContent($view->render()); 166 + $response->setHTTPResponseCode(404); 167 + return $response; 153 168 } 154 169 155 170 return $response; 171 + } 172 + 173 + public function build404Controller() { 174 + return array(new Phabricator404Controller($this->getRequest()), array()); 156 175 } 157 176 158 177
+2
src/aphront/default/configuration/__init__.php
··· 9 9 phutil_require_module('phabricator', 'aphront/applicationconfiguration'); 10 10 phutil_require_module('phabricator', 'aphront/request'); 11 11 phutil_require_module('phabricator', 'aphront/response/webpage'); 12 + phutil_require_module('phabricator', 'applications/base/controller/404'); 13 + phutil_require_module('phabricator', 'view/page/failure'); 12 14 phutil_require_module('phabricator', 'view/page/standard'); 13 15 14 16 phutil_require_module('phutil', 'markup');
+11 -1
src/aphront/response/base/AphrontResponse.php
··· 23 23 24 24 private $request; 25 25 private $cacheable = false; 26 + private $responseCode = 200; 26 27 27 28 public function setRequest($request) { 28 29 $this->request = $request; ··· 36 37 public function getHeaders() { 37 38 return array(); 38 39 } 39 - 40 + 40 41 public function setCacheDurationInSeconds($duration) { 41 42 $this->cacheable = $duration; 42 43 return $this; 44 + } 45 + 46 + public function setHTTPResponseCode($code) { 47 + $this->responseCode = $code; 48 + return $this; 49 + } 50 + 51 + public function getHTTPResponseCode() { 52 + return $this->responseCode; 43 53 } 44 54 45 55 public function getCacheHeaders() {
+25
src/applications/base/controller/404/Phabricator404Controller.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + class Phabricator404Controller extends PhabricatorController { 20 + 21 + public function processRequest() { 22 + return new Aphront404Response(); 23 + } 24 + 25 + }
+13
src/applications/base/controller/404/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'aphront/response/404'); 10 + phutil_require_module('phabricator', 'applications/base/controller/base'); 11 + 12 + 13 + phutil_require_source('Phabricator404Controller.php');
+43
src/view/page/failure/AphrontRequestFailureView.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class AphrontRequestFailureView extends AphrontView { 20 + 21 + private $header; 22 + 23 + public function setHeader($header) { 24 + $this->header = $header; 25 + return $this; 26 + } 27 + 28 + 29 + final public function render() { 30 + require_celerity_resource('aphront-request-failure-view-css'); 31 + 32 + return 33 + '<div class="aphront-request-failure-view">'. 34 + '<div class="aphront-request-failure-head">'. 35 + '<h1>'.phutil_escape_html($this->header).'</h1>'. 36 + '</div>'. 37 + '<div class="aphront-request-failure-body">'. 38 + $this->renderChildren(). 39 + '</div>'. 40 + '</div>'; 41 + } 42 + 43 + }
+14
src/view/page/failure/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'view/base'); 10 + 11 + phutil_require_module('phutil', 'markup'); 12 + 13 + 14 + phutil_require_source('AphrontRequestFailureView.php');
+6
webroot/index.php
··· 55 55 $response->setRequest($request); 56 56 57 57 $response_string = $response->buildResponseString(); 58 + 59 + $code = $response->getHTTPResponseCode(); 60 + if ($code != 200) { 61 + header("HTTP/1.0 {$code}"); 62 + } 63 + 58 64 $headers = $response->getCacheHeaders(); 59 65 $headers = array_merge($headers, $response->getHeaders()); 60 66 foreach ($headers as $header) {
+27
webroot/rsrc/css/aphront/request-failure-view.css
··· 1 + /** 2 + * @provides aphront-request-failure-view-css 3 + */ 4 + 5 + .aphront-request-failure-view { 6 + margin: 2em auto; 7 + background: #eff2f7; 8 + width: 600px; 9 + } 10 + 11 + .aphront-request-failure-view .aphront-request-failure-head { 12 + padding: 1em 2em; 13 + border-bottom: 1px solid #afb2b7; 14 + background: #dfe2e7; 15 + } 16 + 17 + .aphront-request-failure-view .aphront-request-failure-head h1 { 18 + font-size: 24px; 19 + } 20 + 21 + .aphront-request-failure-view .aphront-request-failure-body { 22 + padding: 1em 2em; 23 + } 24 + 25 + .aphront-request-failure-view .aphront-request-failure-body p { 26 + margin: .5em 0 1.25em; 27 + }