1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Improve some of the top-level application hooks and setup messages.

Summary:

Test Plan:

Reviewers:

CC:
This commit is contained in:
epriestley 2011-02-24 14:52:57 -08:00
parent dbb4653be3
commit 0114a29681
4 changed files with 82 additions and 42 deletions

View file

@ -200,15 +200,6 @@ return array(
'github.application-secret' => null, 'github.application-secret' => null,
// Github Authorize URI. You don't need to change this unless Github changes
// its API in the future (this is unlikely).
'github.authorize-uri' => 'https://github.com/login/oauth/authorize',
// Github Access Token URI. You don't need to change this unless Github
// changes its API in the future (this is unlikely).
'github.access-token-uri' => 'https://github.com/login/oauth/access_token',
// -- Recaptcha ------------------------------------------------------------- // // -- Recaptcha ------------------------------------------------------------- //
// Is Recaptcha enabled? If disabled, captchas will not appear. // Is Recaptcha enabled? If disabled, captchas will not appear.
@ -254,4 +245,11 @@ return array(
'text/plain' => 'text/plain; charset=utf-8', 'text/plain' => 'text/plain; charset=utf-8',
), ),
// -- Customization --------------------------------------------------------- //
// Paths to additional phutil libraries to load.
'load-libraries' => array(),
'aphront.default-application-configuration-class' =>
'AphrontDefaultApplicationConfiguration',
); );

View file

@ -49,6 +49,8 @@ phutil_register_library_map(array(
'AphrontQueryObjectMissingException' => 'storage/exception/objectmissing', 'AphrontQueryObjectMissingException' => 'storage/exception/objectmissing',
'AphrontQueryParameterException' => 'storage/exception/parameter', 'AphrontQueryParameterException' => 'storage/exception/parameter',
'AphrontQueryRecoverableException' => 'storage/exception/recoverable', 'AphrontQueryRecoverableException' => 'storage/exception/recoverable',
'AphrontReactiveListView' => 'view/reactive/list',
'AphrontReactiveObjectView' => 'view/reactive/object',
'AphrontRedirectException' => 'aphront/exception/redirect', 'AphrontRedirectException' => 'aphront/exception/redirect',
'AphrontRedirectResponse' => 'aphront/response/redirect', 'AphrontRedirectResponse' => 'aphront/response/redirect',
'AphrontRequest' => 'aphront/request', 'AphrontRequest' => 'aphront/request',
@ -163,6 +165,12 @@ phutil_register_library_map(array(
'ManiphestTransactionType' => 'applications/maniphest/constants/transactiontype', 'ManiphestTransactionType' => 'applications/maniphest/constants/transactiontype',
'Phabricator404Controller' => 'applications/base/controller/404', 'Phabricator404Controller' => 'applications/base/controller/404',
'PhabricatorAuthController' => 'applications/auth/controller/base', 'PhabricatorAuthController' => 'applications/auth/controller/base',
'PhabricatorCacophonyController' => 'applications/cacophony/controller/base',
'PhabricatorCacophonyDAO' => 'applications/cacophony/storage/base',
'PhabricatorCacophonyMessage' => 'applications/cacophony/storage/message',
'PhabricatorCacophonyMessageSaveController' => 'applications/cacophony/controller/messagesave',
'PhabricatorCacophonyTopic' => 'applications/cacophony/storage/topic',
'PhabricatorCacophonyTopicViewController' => 'applications/cacophony/controller/topicview',
'PhabricatorConduitAPIController' => 'applications/conduit/controller/api', 'PhabricatorConduitAPIController' => 'applications/conduit/controller/api',
'PhabricatorConduitConnectionLog' => 'applications/conduit/storage/connectionlog', 'PhabricatorConduitConnectionLog' => 'applications/conduit/storage/connectionlog',
'PhabricatorConduitConsoleController' => 'applications/conduit/controller/console', 'PhabricatorConduitConsoleController' => 'applications/conduit/controller/console',
@ -342,6 +350,8 @@ phutil_register_library_map(array(
'AphrontQueryObjectMissingException' => 'AphrontQueryException', 'AphrontQueryObjectMissingException' => 'AphrontQueryException',
'AphrontQueryParameterException' => 'AphrontQueryException', 'AphrontQueryParameterException' => 'AphrontQueryException',
'AphrontQueryRecoverableException' => 'AphrontQueryException', 'AphrontQueryRecoverableException' => 'AphrontQueryException',
'AphrontReactiveListView' => 'AphrontView',
'AphrontReactiveObjectView' => 'AphrontView',
'AphrontRedirectException' => 'AphrontException', 'AphrontRedirectException' => 'AphrontException',
'AphrontRedirectResponse' => 'AphrontResponse', 'AphrontRedirectResponse' => 'AphrontResponse',
'AphrontRequestFailureView' => 'AphrontView', 'AphrontRequestFailureView' => 'AphrontView',
@ -419,6 +429,12 @@ phutil_register_library_map(array(
'ManiphestTransactionSaveController' => 'ManiphestController', 'ManiphestTransactionSaveController' => 'ManiphestController',
'Phabricator404Controller' => 'PhabricatorController', 'Phabricator404Controller' => 'PhabricatorController',
'PhabricatorAuthController' => 'PhabricatorController', 'PhabricatorAuthController' => 'PhabricatorController',
'PhabricatorCacophonyController' => 'PhabricatorController',
'PhabricatorCacophonyDAO' => 'PhabricatorLiskDAO',
'PhabricatorCacophonyMessage' => 'PhabricatorCacophonyDAO',
'PhabricatorCacophonyMessageSaveController' => 'PhabricatorCacophonyController',
'PhabricatorCacophonyTopic' => 'PhabricatorCacophonyDAO',
'PhabricatorCacophonyTopicViewController' => 'PhabricatorCacophonyController',
'PhabricatorConduitAPIController' => 'PhabricatorConduitController', 'PhabricatorConduitAPIController' => 'PhabricatorConduitController',
'PhabricatorConduitConnectionLog' => 'PhabricatorConduitDAO', 'PhabricatorConduitConnectionLog' => 'PhabricatorConduitDAO',
'PhabricatorConduitConsoleController' => 'PhabricatorConduitController', 'PhabricatorConduitConsoleController' => 'PhabricatorConduitController',

View file

@ -22,12 +22,16 @@
class AphrontDefaultApplicationConfiguration class AphrontDefaultApplicationConfiguration
extends AphrontApplicationConfiguration { extends AphrontApplicationConfiguration {
public function __construct() {
}
public function getApplicationName() { public function getApplicationName() {
return 'aphront-default'; return 'aphront-default';
} }
public function getURIMap() { public function getURIMap() {
return array( return $this->getResourceURIMapRules() + array(
'/' => array( '/' => array(
'$' => 'PhabricatorDirectoryMainController', '$' => 'PhabricatorDirectoryMainController',
), ),
@ -100,11 +104,6 @@ class AphrontDefaultApplicationConfiguration
=> 'DifferentialSubscribeController', => 'DifferentialSubscribeController',
), ),
'/res/' => array(
'(?P<package>pkg/)?(?P<hash>[a-f0-9]{8})/(?P<path>.+\.(?:css|js))$'
=> 'CelerityResourceController',
),
'/typeahead/' => array( '/typeahead/' => array(
'common/(?P<type>\w+)/$' 'common/(?P<type>\w+)/$'
=> 'PhabricatorTypeaheadCommonDatasourceController', => 'PhabricatorTypeaheadCommonDatasourceController',
@ -124,11 +123,8 @@ class AphrontDefaultApplicationConfiguration
'email/$' => 'PhabricatorEmailLoginController', 'email/$' => 'PhabricatorEmailLoginController',
'etoken/(?P<token>\w+)/$' => 'PhabricatorEmailTokenController', 'etoken/(?P<token>\w+)/$' => 'PhabricatorEmailTokenController',
), ),
'/logout/$' => 'PhabricatorLogoutController', '/logout/$' => 'PhabricatorLogoutController',
'/facebook-auth/' => array(
'$' => 'PhabricatorFacebookAuthController',
'diagnose/$' => 'PhabricatorFacebookAuthDiagnosticsController',
),
'/oauth/' => array( '/oauth/' => array(
'(?P<provider>github|facebook)/' => array( '(?P<provider>github|facebook)/' => array(
@ -184,7 +180,17 @@ class AphrontDefaultApplicationConfiguration
'view/(?P<id>\d+)/$' => 'PhabricatorProjectProfileController', 'view/(?P<id>\d+)/$' => 'PhabricatorProjectProfileController',
'affiliation/(?P<id>\d+)/$' 'affiliation/(?P<id>\d+)/$'
=> 'PhabricatorProjectAffiliationEditController', => 'PhabricatorProjectAffiliationEditController',
) ),
);
}
protected function getResourceURIMapRules() {
return array(
'/res/' => array(
'(?P<package>pkg/)?(?P<hash>[a-f0-9]{8})/(?P<path>.+\.(?:css|js))$'
=> 'CelerityResourceController',
),
); );
} }

View file

@ -18,21 +18,28 @@
error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
$env = getenv('PHABRICATOR_ENV'); $env = getenv('PHABRICATOR_ENV'); // Apache
if (!$env) { if (!$env) {
header('Content-Type: text/plain'); if (isset($_SERVER['PHABRICATOR_ENV'])) {
die( $env = $_SERVER['PHABRICATOR_ENV']; // HipHop
"CONFIG ERROR: ". }
}
if (!$env) {
phabricator_fatal_config_error(
"The 'PHABRICATOR_ENV' environmental variable is not defined. Modify ". "The 'PHABRICATOR_ENV' environmental variable is not defined. Modify ".
"your httpd.conf to include 'SetEnv PHABRICATOR_ENV <env>', where '<env>' ". "your httpd.conf to include 'SetEnv PHABRICATOR_ENV <env>', where '<env>' ".
"is one of 'development', 'production', or a custom environment."); "is one of 'development', 'production', or a custom environment.");
} }
if (!function_exists('mysql_connect')) { if (!function_exists('mysql_connect')) {
header('Content-Type: text/plain'); phabricator_fatal_config_error(
die( "The PHP MySQL extension is not installed. This extension is required.");
"CONFIG ERROR: ". }
"the PHP MySQL extension is not installed. This extension is required.");
if (!isset($_REQUEST['__path__'])) {
phabricator_fatal_config_error(
"__path__ is not set. Your rewrite rules are not configured correctly.");
} }
require_once dirname(dirname(__FILE__)).'/conf/__init_conf__.php'; require_once dirname(dirname(__FILE__)).'/conf/__init_conf__.php';
@ -52,18 +59,20 @@ phutil_require_module('phabricator', 'aphront/console/plugin/errorlog/api');
set_error_handler(array('DarkConsoleErrorLogPluginAPI', 'handleError')); set_error_handler(array('DarkConsoleErrorLogPluginAPI', 'handleError'));
set_exception_handler(array('DarkConsoleErrorLogPluginAPI', 'handleException')); set_exception_handler(array('DarkConsoleErrorLogPluginAPI', 'handleException'));
foreach (PhabricatorEnv::getEnvConfig('load-libraries') as $library) {
phutil_load_library($library);
}
$host = $_SERVER['HTTP_HOST']; $host = $_SERVER['HTTP_HOST'];
$path = $_REQUEST['__path__']; $path = $_REQUEST['__path__'];
// Based on the host and path, choose which application should serve the
// request. The default is the Aphront demo, but you'll want to replace this
// with whichever other applications you're running.
switch ($host) { switch ($host) {
default: default:
phutil_require_module('phutil', 'autoload'); $config_key = 'aphront.default-application-configuration-class';
phutil_autoload_class('AphrontDefaultApplicationConfiguration'); $config_class = PhabricatorEnv::getEnvConfig($config_key);
$application = new AphrontDefaultApplicationConfiguration(); PhutilSymbolLoader::loadClass($config_class);
$application = newv($config_class, array());
break; break;
} }
@ -103,6 +112,7 @@ foreach ($headers as $header) {
header("{$header}: {$value}"); header("{$header}: {$value}");
} }
// TODO: This shouldn't be possible in a production-configured environment.
if (isset($_REQUEST['__profile__']) && if (isset($_REQUEST['__profile__']) &&
($_REQUEST['__profile__'] == 'all')) { ($_REQUEST['__profile__'] == 'all')) {
$profile = DarkConsoleXHProfPluginAPI::stopProfiler(); $profile = DarkConsoleXHProfPluginAPI::stopProfiler();
@ -133,7 +143,7 @@ function setup_aphront_basics() {
$aphront_root = dirname(dirname(__FILE__)); $aphront_root = dirname(dirname(__FILE__));
$libraries_root = dirname($aphront_root); $libraries_root = dirname($aphront_root);
ini_set('include_path', ini_get('include_path').':'.$libraries_root.'/'); ini_set('include_path', $libraries_root.':'.ini_get('include_path'));
@include_once 'libphutil/src/__phutil_library_init__.php'; @include_once 'libphutil/src/__phutil_library_init__.php';
if (!@constant('__LIBPHUTIL__')) { if (!@constant('__LIBPHUTIL__')) {
echo "ERROR: Unable to load libphutil. Update your PHP 'include_path' to ". echo "ERROR: Unable to load libphutil. Update your PHP 'include_path' to ".
@ -141,14 +151,24 @@ function setup_aphront_basics() {
exit(1); exit(1);
} }
if (!ini_get('date.timezone')) { // Load Phabricator itself using the absolute path, so we never end up doing
date_default_timezone_set('America/Los_Angeles'); // anything surprising (loading index.php and libraries from different
} // directories).
phutil_load_library($libraries_root.'/arcanist/src');
phutil_load_library($aphront_root.'/src'); phutil_load_library($aphront_root.'/src');
phutil_load_library('arcanist/src');
} }
function __autoload($class_name) { function __autoload($class_name) {
PhutilSymbolLoader::loadClass($class_name); PhutilSymbolLoader::loadClass($class_name);
} }
function phabricator_fatal_config_error($msg) {
header('Content-Type: text/plain', $replace = true, $http_error = 500);
$error = "CONFIG ERROR: ".$msg."\n";
error_log($error);
echo $error;
die();
}