diff --git a/src/aphront/configuration/AphrontApplicationConfiguration.php b/src/aphront/configuration/AphrontApplicationConfiguration.php
index 1d785557ed..e9dabb6695 100644
--- a/src/aphront/configuration/AphrontApplicationConfiguration.php
+++ b/src/aphront/configuration/AphrontApplicationConfiguration.php
@@ -160,8 +160,8 @@ abstract class AphrontApplicationConfiguration {
$path = '/phame/posts/'.trim($path, '/').'/';
}
- // TODO - now we need to tell Celerity to render static resources with
- // full URIs like secure.phabricator.org/rsrc/blahblah
+ $celerity = CelerityAPI::getStaticResourceResponse();
+ $celerity->setUseFullURI(true);
}
list($controller, $uri_data) = $this->buildControllerForPath($path);
diff --git a/src/infrastructure/celerity/CelerityStaticResourceResponse.php b/src/infrastructure/celerity/CelerityStaticResourceResponse.php
index c9416f8e5d..93e1734bab 100644
--- a/src/infrastructure/celerity/CelerityStaticResourceResponse.php
+++ b/src/infrastructure/celerity/CelerityStaticResourceResponse.php
@@ -33,6 +33,7 @@ final class CelerityStaticResourceResponse {
private $metadataBlock = 0;
private $behaviors = array();
private $hasRendered = array();
+ private $useFullURI = false;
public function __construct() {
if (isset($_REQUEST['__metablock__'])) {
@@ -85,6 +86,19 @@ final class CelerityStaticResourceResponse {
return $this;
}
+ /**
+ * If set to true, Celerity will print full URIs (including the domain)
+ * for static resources.
+ */
+ public function setUseFullURI($should) {
+ $this->useFullURI = $should;
+ return $this;
+ }
+
+ private function shouldUseFullURI() {
+ return $this->useFullURI;
+ }
+
public function renderSingleResource($symbol) {
$map = CelerityResourceMap::getInstance();
$resolved = $map->resolveResources(array($symbol));
@@ -119,18 +133,27 @@ final class CelerityStaticResourceResponse {
}
private function renderResource(array $resource) {
+ $uri = $this->getURI($resource['uri']);
switch ($resource['type']) {
case 'css':
- $path = phutil_escape_html($resource['uri']);
- return '';
+ return '';
case 'js':
- $path = phutil_escape_html($resource['uri']);
- return '';
}
throw new Exception("Unable to render resource.");
}
+ private function getURI($path) {
+ $path = phutil_escape_html($path);
+ if ($this->shouldUseFullURI()) {
+ $uri = PhabricatorEnv::getCDNURI($path);
+ } else {
+ $uri = $path;
+ }
+ return $uri;
+ }
+
public function renderHTMLFooter() {
$data = array();
if ($this->metadata) {