@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Pass instance through file transform URIs

Summary:
This makes thumbnail URIs work on instanced, CDN'd installs like Phacility cluster instances.

Some of these transforms can proabably be removed, but the underlying code to generate the transform should be cleaned up too and we have some other tasks filed elsewhere about this anyway.

Test Plan: CDN'd local install now loads thumbnails properly.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11719

+32 -22
+5 -1
src/applications/files/application/PhabricatorFilesApplication.php
··· 84 84 '.*' 85 85 => 'PhabricatorFileDataController', 86 86 'proxy/' => 'PhabricatorFileProxyController', 87 - 'xform/(?P<transform>[^/]+)/(?P<phid>[^/]+)/(?P<key>[^/]+)/' 87 + 'xform/'. 88 + '(?:@(?P<instance>[^/]+)/)?'. 89 + '(?P<transform>[^/]+)/'. 90 + '(?P<phid>[^/]+)/'. 91 + '(?P<key>[^/]+)/' 88 92 => 'PhabricatorFileTransformController', 89 93 'uploaddialog/' => 'PhabricatorFileUploadDialogController', 90 94 'download/(?P<phid>[^/]+)/' => 'PhabricatorFileDialogController',
+27 -21
src/applications/files/storage/PhabricatorFile.php
··· 620 620 return (string) $uri; 621 621 } 622 622 623 - public function getProfileThumbURI() { 624 - $path = '/file/xform/thumb-profile/'.$this->getPHID().'/' 625 - .$this->getSecretKey().'/'; 623 + private function getTransformedURI($transform) { 624 + $parts = array(); 625 + $parts[] = 'file'; 626 + $parts[] = 'xform'; 627 + 628 + $instance = PhabricatorEnv::getEnvConfig('cluster.instance'); 629 + if (strlen($instance)) { 630 + $parts[] = '@'.$instance; 631 + } 632 + 633 + $parts[] = $transform; 634 + $parts[] = $this->getPHID(); 635 + $parts[] = $this->getSecretKey(); 636 + 637 + $path = implode('/', $parts); 638 + $path = $path.'/'; 639 + 626 640 return PhabricatorEnv::getCDNURI($path); 641 + } 642 + 643 + public function getProfileThumbURI() { 644 + return $this->getTransformedURI('thumb-profile'); 627 645 } 628 646 629 647 public function getThumb60x45URI() { 630 - $path = '/file/xform/thumb-60x45/'.$this->getPHID().'/' 631 - .$this->getSecretKey().'/'; 632 - return PhabricatorEnv::getCDNURI($path); 648 + return $this->getTransformedURI('thumb-60x45'); 633 649 } 634 650 635 651 public function getThumb160x120URI() { 636 - $path = '/file/xform/thumb-160x120/'.$this->getPHID().'/' 637 - .$this->getSecretKey().'/'; 638 - return PhabricatorEnv::getCDNURI($path); 652 + return $this->getTransformedURI('thumb-160x120'); 639 653 } 640 654 641 655 public function getPreview100URI() { 642 - $path = '/file/xform/preview-100/'.$this->getPHID().'/' 643 - .$this->getSecretKey().'/'; 644 - return PhabricatorEnv::getCDNURI($path); 656 + return $this->getTransformedURI('preview-100'); 645 657 } 646 658 647 659 public function getPreview220URI() { 648 - $path = '/file/xform/preview-220/'.$this->getPHID().'/' 649 - .$this->getSecretKey().'/'; 650 - return PhabricatorEnv::getCDNURI($path); 660 + return $this->getTransformedURI('preview-220'); 651 661 } 652 662 653 663 public function getThumb220x165URI() { 654 - $path = '/file/xform/thumb-220x165/'.$this->getPHID().'/' 655 - .$this->getSecretKey().'/'; 656 - return PhabricatorEnv::getCDNURI($path); 664 + return $this->getTransfomredURI('thumb-220x165'); 657 665 } 658 666 659 667 public function getThumb280x210URI() { 660 - $path = '/file/xform/thumb-280x210/'.$this->getPHID().'/' 661 - .$this->getSecretKey().'/'; 662 - return PhabricatorEnv::getCDNURI($path); 668 + return $this->getTransformedURI('thumb-280x210'); 663 669 } 664 670 665 671 public function isViewableInBrowser() {