1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32: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 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 ------------------------------------------------------------- //
// Is Recaptcha enabled? If disabled, captchas will not appear.
@ -247,11 +238,18 @@ return array(
//
// The keys in this array are viewable mime types; the values are the mime
// types they will be delivered as when they are viewed in the browser.
'files.viewable-mime-types' => array(
'files.viewable-mime-types' => array(
'image/jpeg' => 'image/jpeg',
'image/jpg' => 'image/jpg',
'image/png' => 'image/png',
'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',
'AphrontQueryParameterException' => 'storage/exception/parameter',
'AphrontQueryRecoverableException' => 'storage/exception/recoverable',
'AphrontReactiveListView' => 'view/reactive/list',
'AphrontReactiveObjectView' => 'view/reactive/object',
'AphrontRedirectException' => 'aphront/exception/redirect',
'AphrontRedirectResponse' => 'aphront/response/redirect',
'AphrontRequest' => 'aphront/request',
@ -163,6 +165,12 @@ phutil_register_library_map(array(
'ManiphestTransactionType' => 'applications/maniphest/constants/transactiontype',
'Phabricator404Controller' => 'applications/base/controller/404',
'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',
'PhabricatorConduitConnectionLog' => 'applications/conduit/storage/connectionlog',
'PhabricatorConduitConsoleController' => 'applications/conduit/controller/console',
@ -342,6 +350,8 @@ phutil_register_library_map(array(
'AphrontQueryObjectMissingException' => 'AphrontQueryException',
'AphrontQueryParameterException' => 'AphrontQueryException',
'AphrontQueryRecoverableException' => 'AphrontQueryException',
'AphrontReactiveListView' => 'AphrontView',
'AphrontReactiveObjectView' => 'AphrontView',
'AphrontRedirectException' => 'AphrontException',
'AphrontRedirectResponse' => 'AphrontResponse',
'AphrontRequestFailureView' => 'AphrontView',
@ -419,6 +429,12 @@ phutil_register_library_map(array(
'ManiphestTransactionSaveController' => 'ManiphestController',
'Phabricator404Controller' => 'PhabricatorController',
'PhabricatorAuthController' => 'PhabricatorController',
'PhabricatorCacophonyController' => 'PhabricatorController',
'PhabricatorCacophonyDAO' => 'PhabricatorLiskDAO',
'PhabricatorCacophonyMessage' => 'PhabricatorCacophonyDAO',
'PhabricatorCacophonyMessageSaveController' => 'PhabricatorCacophonyController',
'PhabricatorCacophonyTopic' => 'PhabricatorCacophonyDAO',
'PhabricatorCacophonyTopicViewController' => 'PhabricatorCacophonyController',
'PhabricatorConduitAPIController' => 'PhabricatorConduitController',
'PhabricatorConduitConnectionLog' => 'PhabricatorConduitDAO',
'PhabricatorConduitConsoleController' => 'PhabricatorConduitController',

View file

@ -22,12 +22,16 @@
class AphrontDefaultApplicationConfiguration
extends AphrontApplicationConfiguration {
public function __construct() {
}
public function getApplicationName() {
return 'aphront-default';
}
public function getURIMap() {
return array(
return $this->getResourceURIMapRules() + array(
'/' => array(
'$' => 'PhabricatorDirectoryMainController',
),
@ -100,11 +104,6 @@ class AphrontDefaultApplicationConfiguration
=> 'DifferentialSubscribeController',
),
'/res/' => array(
'(?P<package>pkg/)?(?P<hash>[a-f0-9]{8})/(?P<path>.+\.(?:css|js))$'
=> 'CelerityResourceController',
),
'/typeahead/' => array(
'common/(?P<type>\w+)/$'
=> 'PhabricatorTypeaheadCommonDatasourceController',
@ -124,11 +123,8 @@ class AphrontDefaultApplicationConfiguration
'email/$' => 'PhabricatorEmailLoginController',
'etoken/(?P<token>\w+)/$' => 'PhabricatorEmailTokenController',
),
'/logout/$' => 'PhabricatorLogoutController',
'/facebook-auth/' => array(
'$' => 'PhabricatorFacebookAuthController',
'diagnose/$' => 'PhabricatorFacebookAuthDiagnosticsController',
),
'/oauth/' => array(
'(?P<provider>github|facebook)/' => array(
@ -184,7 +180,17 @@ class AphrontDefaultApplicationConfiguration
'view/(?P<id>\d+)/$' => 'PhabricatorProjectProfileController',
'affiliation/(?P<id>\d+)/$'
=> '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);
$env = getenv('PHABRICATOR_ENV');
$env = getenv('PHABRICATOR_ENV'); // Apache
if (!$env) {
header('Content-Type: text/plain');
die(
"CONFIG ERROR: ".
if (isset($_SERVER['PHABRICATOR_ENV'])) {
$env = $_SERVER['PHABRICATOR_ENV']; // HipHop
}
}
if (!$env) {
phabricator_fatal_config_error(
"The 'PHABRICATOR_ENV' environmental variable is not defined. Modify ".
"your httpd.conf to include 'SetEnv PHABRICATOR_ENV <env>', where '<env>' ".
"is one of 'development', 'production', or a custom environment.");
}
if (!function_exists('mysql_connect')) {
header('Content-Type: text/plain');
die(
"CONFIG ERROR: ".
"the PHP MySQL extension is not installed. This extension is required.");
phabricator_fatal_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';
@ -52,18 +59,20 @@ phutil_require_module('phabricator', 'aphront/console/plugin/errorlog/api');
set_error_handler(array('DarkConsoleErrorLogPluginAPI', 'handleError'));
set_exception_handler(array('DarkConsoleErrorLogPluginAPI', 'handleException'));
foreach (PhabricatorEnv::getEnvConfig('load-libraries') as $library) {
phutil_load_library($library);
}
$host = $_SERVER['HTTP_HOST'];
$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) {
default:
phutil_require_module('phutil', 'autoload');
phutil_autoload_class('AphrontDefaultApplicationConfiguration');
$application = new AphrontDefaultApplicationConfiguration();
$config_key = 'aphront.default-application-configuration-class';
$config_class = PhabricatorEnv::getEnvConfig($config_key);
PhutilSymbolLoader::loadClass($config_class);
$application = newv($config_class, array());
break;
}
@ -103,6 +112,7 @@ foreach ($headers as $header) {
header("{$header}: {$value}");
}
// TODO: This shouldn't be possible in a production-configured environment.
if (isset($_REQUEST['__profile__']) &&
($_REQUEST['__profile__'] == 'all')) {
$profile = DarkConsoleXHProfPluginAPI::stopProfiler();
@ -133,7 +143,7 @@ function setup_aphront_basics() {
$aphront_root = dirname(dirname(__FILE__));
$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';
if (!@constant('__LIBPHUTIL__')) {
echo "ERROR: Unable to load libphutil. Update your PHP 'include_path' to ".
@ -141,14 +151,24 @@ function setup_aphront_basics() {
exit(1);
}
if (!ini_get('date.timezone')) {
date_default_timezone_set('America/Los_Angeles');
}
phutil_load_library($libraries_root.'/arcanist/src');
// Load Phabricator itself using the absolute path, so we never end up doing
// anything surprising (loading index.php and libraries from different
// directories).
phutil_load_library($aphront_root.'/src');
phutil_load_library('arcanist/src');
}
function __autoload($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();
}