Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14398358
D7874.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D7874.diff
View Options
Index: src/applications/phame/skins/PhameBasicTemplateBlogSkin.php
===================================================================
--- src/applications/phame/skins/PhameBasicTemplateBlogSkin.php
+++ src/applications/phame/skins/PhameBasicTemplateBlogSkin.php
@@ -29,7 +29,7 @@
}
}
- $map = CelerityResourceMap::getInstance();
+ $map = CelerityResourceMap::getNamedInstance('phabricator');
$resource_symbol = 'syntax-highlighting-css';
$resource_uri = $map->getURIForSymbol($resource_symbol);
Index: src/infrastructure/celerity/CelerityPhabricatorResourceController.php
===================================================================
--- src/infrastructure/celerity/CelerityPhabricatorResourceController.php
+++ src/infrastructure/celerity/CelerityPhabricatorResourceController.php
@@ -13,9 +13,8 @@
private $path;
private $hash;
- protected function getRootDirectory() {
- $root = dirname(phutil_get_library_root('phabricator'));
- return $root.'/webroot/';
+ public function getCelerityResourceMap() {
+ return CelerityResourceMap::getNamedInstance('phabricator');
}
public function willProcessRequest(array $data) {
@@ -28,12 +27,14 @@
}
protected function buildResourceTransformer() {
- $xformer = new CelerityResourceTransformer();
- $xformer->setMinify(
- !PhabricatorEnv::getEnvConfig('phabricator.developer-mode') &&
- PhabricatorEnv::getEnvConfig('celerity.minify'));
- $xformer->setCelerityMap(CelerityResourceMap::getInstance());
- return $xformer;
+ $minify_on = PhabricatorEnv::getEnvConfig('celerity.minify');
+ $developer_on = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
+
+ $should_minify = ($minify_on && !$developer_on);
+
+ return id(new CelerityResourceTransformer())
+ ->setMinify($should_minify)
+ ->setCelerityMap($this->getCelerityResourceMap());
}
}
Index: src/infrastructure/celerity/CelerityResourceController.php
===================================================================
--- src/infrastructure/celerity/CelerityResourceController.php
+++ src/infrastructure/celerity/CelerityResourceController.php
@@ -14,9 +14,7 @@
return false;
}
- public function getCelerityResourceMap() {
- return CelerityResourceMap::getInstance();
- }
+ abstract public function getCelerityResourceMap();
protected function serveResource($path, $package_hash = null) {
// Sanity checking to keep this from exposing anything sensitive, since it
Index: src/infrastructure/celerity/CelerityResourceMap.php
===================================================================
--- src/infrastructure/celerity/CelerityResourceMap.php
+++ src/infrastructure/celerity/CelerityResourceMap.php
@@ -8,7 +8,7 @@
*/
final class CelerityResourceMap {
- private static $instance;
+ private static $instances = array();
private $resources;
private $symbolMap;
@@ -37,12 +37,20 @@
}
}
- public static function getInstance() {
- if (empty(self::$instance)) {
- $resources = new CelerityPhabricatorResources();
- self::$instance = new CelerityResourceMap($resources);
+ public static function getNamedInstance($name) {
+ if (empty(self::$instances[$name])) {
+ $resources_list = CelerityPhysicalResources::getAll();
+ if (empty($resources_list[$name])) {
+ throw new Exception(
+ pht(
+ 'No resource source exists with name "%s"!', $name));
+ }
+
+ $instance = new CelerityResourceMap($resources_list[$name]);
+ self::$instances[$name] = $instance;
}
- return self::$instance;
+
+ return self::$instances[$name];
}
public function getPackagedNamesForSymbols(array $symbols) {
Index: src/infrastructure/celerity/CelerityResourceTransformer.php
===================================================================
--- src/infrastructure/celerity/CelerityResourceTransformer.php
+++ src/infrastructure/celerity/CelerityResourceTransformer.php
@@ -6,7 +6,6 @@
final class CelerityResourceTransformer {
private $minify;
- private $rawResourceMap;
private $rawURIMap;
private $celerityMap;
private $translateURICallback;
@@ -22,11 +21,6 @@
return $this;
}
- public function setRawResourceMap(array $raw_resource_map) {
- $this->rawResourceMap = $raw_resource_map;
- return $this;
- }
-
public function setCelerityMap(CelerityResourceMap $celerity_map) {
$this->celerityMap = $celerity_map;
return $this;
@@ -122,10 +116,6 @@
if (isset($this->rawURIMap[$uri])) {
$uri = $this->rawURIMap[$uri];
}
- } else if ($this->rawResourceMap) {
- if (isset($this->rawResourceMap[$uri]['uri'])) {
- $uri = $this->rawResourceMap[$uri]['uri'];
- }
} else if ($this->celerityMap) {
$resource_uri = $this->celerityMap->getURIForName($uri);
if ($resource_uri) {
Index: src/infrastructure/celerity/CelerityStaticResourceResponse.php
===================================================================
--- src/infrastructure/celerity/CelerityStaticResourceResponse.php
+++ src/infrastructure/celerity/CelerityStaticResourceResponse.php
@@ -61,7 +61,7 @@
private function resolveResources() {
if ($this->needsResolve) {
- $map = CelerityResourceMap::getInstance();
+ $map = CelerityResourceMap::getNamedInstance('phabricator');
$symbols = array_keys($this->symbols);
$this->packaged = $map->getPackagedNamesForSymbols($symbols);
@@ -71,8 +71,8 @@
return $this;
}
- public function renderSingleResource($symbol) {
- $map = CelerityResourceMap::getInstance();
+ public function renderSingleResource($symbol, $source_name) {
+ $map = CelerityResourceMap::getNamedInstance($source_name);
$packaged = $map->getPackagedNamesForSymbols(array($symbol));
return $this->renderPackagedResources($packaged);
}
@@ -236,7 +236,7 @@
}
private function getURI($name) {
- $map = CelerityResourceMap::getInstance();
+ $map = CelerityResourceMap::getNamedInstance('phabricator');
$uri = $map->getURIForName($name);
// In developer mode, we dump file modification times into the URI. When a
Index: src/infrastructure/celerity/__tests__/CelerityResourceTransformerTestCase.php
===================================================================
--- src/infrastructure/celerity/__tests__/CelerityResourceTransformerTestCase.php
+++ src/infrastructure/celerity/__tests__/CelerityResourceTransformerTestCase.php
@@ -22,11 +22,9 @@
);
$xformer = new CelerityResourceTransformer();
- $xformer->setRawResourceMap(
+ $xformer->setRawURIMap(
array(
- '/rsrc/example.png' => array(
- 'uri' => '/res/hash/example.png',
- ),
+ '/rsrc/example.png' => '/res/hash/example.png',
));
$xformer->setMinify($options['minify']);
Index: src/infrastructure/celerity/api.php
===================================================================
--- src/infrastructure/celerity/api.php
+++ src/infrastructure/celerity/api.php
@@ -49,8 +49,8 @@
*
* @group celerity
*/
-function celerity_get_resource_uri($resource) {
- $map = CelerityResourceMap::getInstance();
+function celerity_get_resource_uri($resource, $source = 'phabricator') {
+ $map = CelerityResourceMap::getNamedInstance($source);
$uri = $map->getURIForName($resource);
if ($uri) {
Index: src/infrastructure/lint/linter/PhabricatorJavelinLinter.php
===================================================================
--- src/infrastructure/lint/linter/PhabricatorJavelinLinter.php
+++ src/infrastructure/lint/linter/PhabricatorJavelinLinter.php
@@ -139,7 +139,7 @@
}
}
- $celerity = CelerityResourceMap::getInstance();
+ $celerity = CelerityResourceMap::getNamedInstance('phabricator');
$path = preg_replace(
'@^externals/javelinjs/src/@',
Index: src/view/page/PhabricatorStandardPageView.php
===================================================================
--- src/view/page/PhabricatorStandardPageView.php
+++ src/view/page/PhabricatorStandardPageView.php
@@ -255,7 +255,7 @@
parent::getHead(),
phutil_safe_html($monospaced),
phutil_safe_html($monospaced_win),
- $response->renderSingleResource('javelin-magical-init'));
+ $response->renderSingleResource('javelin-magical-init', 'phabricator'));
}
public function setGlyph($glyph) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 1:44 PM (17 h, 50 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6921341
Default Alt Text
D7874.diff (8 KB)
Attached To
Mode
D7874: Move Celerity gradually toward multiple source support
Attached
Detach File
Event Timeline
Log In to Comment