Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15334209
D7868.id17807.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D7868.id17807.diff
View Options
Index: src/applications/phame/skins/PhameBasicTemplateBlogSkin.php
===================================================================
--- src/applications/phame/skins/PhameBasicTemplateBlogSkin.php
+++ src/applications/phame/skins/PhameBasicTemplateBlogSkin.php
@@ -30,14 +30,15 @@
}
$map = CelerityResourceMap::getInstance();
- $symbol_info = $map->lookupSymbolInformation('syntax-highlighting-css');
+ $resource_symbol = 'syntax-highlighting-css';
+ $resource_uri = $map->getFullyQualifiedURIForSymbol($resource_symbol);
$this->cssResources[] = phutil_tag(
'link',
array(
'rel' => 'stylesheet',
'type' => 'text/css',
- 'href' => PhabricatorEnv::getCDNURI($symbol_info['uri']),
+ 'href' => $resource_uri,
));
$this->cssResources = phutil_implode_html("\n", $this->cssResources);
Index: src/infrastructure/celerity/CelerityResourceMap.php
===================================================================
--- src/infrastructure/celerity/CelerityResourceMap.php
+++ src/infrastructure/celerity/CelerityResourceMap.php
@@ -104,7 +104,7 @@
return $paths;
}
- public function lookupSymbolInformation($symbol) {
+ private function lookupSymbolInformation($symbol) {
return idx($this->resourceMap, $symbol);
}
@@ -121,11 +121,45 @@
/**
+ * Get the epoch timestamp of the last modification time of a symbol.
+ *
+ * @param string Resource symbol to lookup.
+ * @return int Epoch timestamp of last resource modification.
+ */
+ public function getModifiedTimeForSymbol($symbol) {
+ $info = $this->lookupSymbolInformation($symbol);
+ if ($info) {
+ $root = dirname(phutil_get_library_root('phabricator')).'/webroot';
+ return (int)filemtime($root.$info['disk']);
+ }
+ return 0;
+ }
+
+
+ /**
+ * Return the fully-qualified, absolute URI for the resource associated with
+ * a symbol. This method is fairly low-level and ignores packaging.
+ *
+ * @param string Resource symbol to lookup.
+ * @return string|null Fully-qualified resource URI, or null if the symbol
+ * is unknown.
+ */
+ public function getFullyQualifiedURIForSymbol($symbol) {
+ $info = $this->lookupSymbolInformation($symbol);
+ if ($info) {
+ return idx($info, 'uri');
+ }
+ return null;
+ }
+
+
+ /**
* Return the fully-qualified, absolute URI for the resource associated with
* a resource name. This method is fairly low-level and ignores packaging.
*
* @param string Resource name to lookup.
- * @return string Fully-qualified resource URI.
+ * @return string|null Fully-qualified resource URI, or null if the name
+ * is unknown.
*/
public function getFullyQualifiedURIForName($name) {
$info = $this->lookupFileInformation($name);
@@ -140,7 +174,8 @@
* Return the resource symbols required by a named resource.
*
* @param string Resource name to lookup.
- * @return list<string> List of required symbols.
+ * @return list<string>|null List of required symbols, or null if the name
+ * is unknown.
*/
public function getRequiredSymbolsForName($name) {
$info = $this->lookupFileInformation($name);
@@ -151,4 +186,19 @@
}
+ /**
+ * Return the resource name for a given symbol.
+ *
+ * @param string Resource symbol to lookup.
+ * @return string|null Resource name, or null if the symbol is unknown.
+ */
+ public function getResourceNameForSymbol($symbol) {
+ $info = $this->lookupSymbolInformation($symbol);
+ if ($info) {
+ return idx($info, 'disk');
+ }
+ return null;
+ }
+
+
}
Index: src/infrastructure/celerity/CelerityStaticResourceResponse.php
===================================================================
--- src/infrastructure/celerity/CelerityStaticResourceResponse.php
+++ src/infrastructure/celerity/CelerityStaticResourceResponse.php
@@ -249,8 +249,7 @@
$mtime = 0;
foreach ($resource['symbols'] as $symbol) {
$map = CelerityResourceMap::getInstance();
- $symbol_info = $map->lookupSymbolInformation($symbol);
- $mtime = max($mtime, (int)filemtime($root.$symbol_info['disk']));
+ $mtime = max($mtime, $map->getModifiedTimeForSymbol($symbol));
}
}
Index: src/infrastructure/lint/linter/PhabricatorJavelinLinter.php
===================================================================
--- src/infrastructure/lint/linter/PhabricatorJavelinLinter.php
+++ src/infrastructure/lint/linter/PhabricatorJavelinLinter.php
@@ -153,24 +153,24 @@
$requires = array();
}
- foreach ($requires as $key => $symbol_name) {
- $symbol_info = $celerity->lookupSymbolInformation($symbol_name);
- if (!$symbol_info) {
+ foreach ($requires as $key => $requires_symbol) {
+ $requires_name = $celerity->getResourceNameForSymbol($requires_symbol);
+ if ($requires_name === null) {
$this->raiseLintAtLine(
0,
0,
self::LINT_UNKNOWN_DEPENDENCY,
- "This file @requires component '{$symbol_name}', but it does not ".
- "exist. You may need to rebuild the Celerity map.");
+ "This file @requires component '{$requires_symbol}', but it does ".
+ "not exist. You may need to rebuild the Celerity map.");
unset($requires[$key]);
continue;
}
- if (preg_match('/\\.css$/', $symbol_info['disk'])) {
+ if (preg_match('/\\.css$/', $requires_name)) {
// If JS requires CSS, just assume everything is fine.
unset($requires[$key]);
} else {
- $symbol_path = 'webroot'.$symbol_info['disk'];
+ $symbol_path = 'webroot'.$requires_name;
list($ignored, $req_install) = $this->getUsedAndInstalledSymbolsForPath(
$symbol_path);
if (array_intersect_key($req_install, $external_classes)) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 9, 7:33 AM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7387396
Default Alt Text
D7868.id17807.diff (5 KB)
Attached To
Mode
D7868: Make lookupSymbolInformation() a private API on CelerityResourceMap
Attached
Detach File
Event Timeline
Log In to Comment