public function processRequest()
 {
     $root = dirname(phutil_get_library_root('phabricator'));
     require_once $root . '/support/phame/libskin.php';
     $this->cssResources = array();
     $css = $this->getPath('css/');
     if (Filesystem::pathExists($css)) {
         foreach (Filesystem::listDirectory($css) as $path) {
             if (!preg_match('/.css$/', $path)) {
                 continue;
             }
             $this->cssResources[] = phutil_tag('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $this->getResourceURI('css/' . $path)));
         }
     }
     $map = CelerityResourceMap::getNamedInstance('phabricator');
     $resource_symbol = 'syntax-highlighting-css';
     $resource_uri = $map->getURIForSymbol($resource_symbol);
     $this->cssResources[] = phutil_tag('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => PhabricatorEnv::getCDNURI($resource_uri)));
     $this->cssResources = phutil_implode_html("\n", $this->cssResources);
     $request = $this->getRequest();
     // Render page parts in order so the templates execute in order, if we're
     // using templates.
     $header = $this->renderHeader();
     $content = $this->renderContent($request);
     $footer = $this->renderFooter();
     if (!$content) {
         $content = $this->render404Page();
     }
     $content = array($header, $content, $footer);
     $response = new AphrontWebpageResponse();
     $response->setContent(phutil_implode_html("\n", $content));
     return $response;
 }
 public function getViewURI()
 {
     if (!$this->getPHID()) {
         throw new Exception("You must save a file before you can generate a view URI.");
     }
     $name = phutil_escape_uri($this->getName());
     $path = '/file/data/' . $this->getSecretKey() . '/' . $this->getPHID() . '/' . $name;
     return PhabricatorEnv::getCDNURI($path);
 }
 /**
  * Get a version identifier for a user's profile image.
  *
  * This version will change if the image changes, or if any of the
  * environment configuration which goes into generating a URI changes.
  *
  * @return string Cache version.
  * @task image-cache
  */
 private function getProfileImageVersion()
 {
     $parts = array(PhabricatorEnv::getCDNURI('/'), PhabricatorEnv::getEnvConfig('cluster.instance'), $this->getProfileImagePHID());
     $parts = serialize($parts);
     return PhabricatorHash::digestForIndex($parts);
 }
 public function getURI(CelerityResourceMap $map, $name, $use_primary_domain = false)
 {
     $uri = $map->getURIForName($name);
     // If we have a postprocessor selected, add it to the URI.
     $postprocessor_key = $this->getPostprocessorKey();
     if ($postprocessor_key) {
         $uri = preg_replace('@^/res/@', '/res/' . $postprocessor_key . 'X/', $uri);
     }
     // In developer mode, we dump file modification times into the URI. When a
     // page is reloaded in the browser, any resources brought in by Ajax calls
     // do not trigger revalidation, so without this it's very difficult to get
     // changes to Ajaxed-in CSS to work (you must clear your cache or rerun
     // the map script). In production, we can assume the map script gets run
     // after changes, and safely skip this.
     if (PhabricatorEnv::getEnvConfig('phabricator.developer-mode')) {
         $mtime = $map->getModifiedTimeForName($name);
         $uri = preg_replace('@^/res/@', '/res/' . $mtime . 'T/', $uri);
     }
     if ($use_primary_domain) {
         return PhabricatorEnv::getURI($uri);
     } else {
         return PhabricatorEnv::getCDNURI($uri);
     }
 }
 private function getTransformedURI($transform)
 {
     $parts = array();
     $parts[] = 'file';
     $parts[] = 'xform';
     $instance = PhabricatorEnv::getEnvConfig('cluster.instance');
     if (strlen($instance)) {
         $parts[] = '@' . $instance;
     }
     $parts[] = $transform;
     $parts[] = $this->getPHID();
     $parts[] = $this->getSecretKey();
     $path = implode('/', $parts);
     $path = $path . '/';
     return PhabricatorEnv::getCDNURI($path);
 }
 public final function getResourceURI($resource)
 {
     $root = $this->getSpecification()->getRootDirectory();
     $path = $root . DIRECTORY_SEPARATOR . $resource;
     $data = Filesystem::readFile($path);
     $hash = PhabricatorHash::digest($data);
     $hash = substr($hash, 0, 6);
     $id = $this->getBlog()->getID();
     $uri = '/phame/r/' . $id . '/' . $hash . '/' . $resource;
     $uri = PhabricatorEnv::getCDNURI($uri);
     return $uri;
 }