@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.

Allow a domain other than the install domain to serve as a short Phurl domain

Summary: Ref T8995, config option for Phurl short domain to share shortened URL's

Test Plan:
- Configure Phurl short domain to something like "zz.us"
- Navigate to `zz.us`; get 404
- Navigate to `zz.us/u/3` or `zz.us/u/alias` where `U3` is an existing Phurl; redirect to correct destination

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T8995

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

+130 -1
+8
src/__phutil_library_map__.php
··· 2641 2641 'PhabricatorPhrictionApplication' => 'applications/phriction/application/PhabricatorPhrictionApplication.php', 2642 2642 'PhabricatorPhrictionConfigOptions' => 'applications/phriction/config/PhabricatorPhrictionConfigOptions.php', 2643 2643 'PhabricatorPhurlApplication' => 'applications/phurl/application/PhabricatorPhurlApplication.php', 2644 + 'PhabricatorPhurlConfigOptions' => 'applications/config/option/PhabricatorPhurlConfigOptions.php', 2644 2645 'PhabricatorPhurlController' => 'applications/phurl/controller/PhabricatorPhurlController.php', 2645 2646 'PhabricatorPhurlDAO' => 'applications/phurl/storage/PhabricatorPhurlDAO.php', 2646 2647 'PhabricatorPhurlLinkRemarkupRule' => 'applications/phurl/remarkup/PhabricatorPhurlLinkRemarkupRule.php', 2647 2648 'PhabricatorPhurlRemarkupRule' => 'applications/phurl/remarkup/PhabricatorPhurlRemarkupRule.php', 2648 2649 'PhabricatorPhurlSchemaSpec' => 'applications/phurl/storage/PhabricatorPhurlSchemaSpec.php', 2650 + 'PhabricatorPhurlShortURLController' => 'applications/phurl/controller/PhabricatorPhurlShortURLController.php', 2651 + 'PhabricatorPhurlShortURLDefaultController' => 'applications/phurl/controller/PhabricatorPhurlShortURLDefaultController.php', 2649 2652 'PhabricatorPhurlURL' => 'applications/phurl/storage/PhabricatorPhurlURL.php', 2650 2653 'PhabricatorPhurlURLAccessController' => 'applications/phurl/controller/PhabricatorPhurlURLAccessController.php', 2651 2654 'PhabricatorPhurlURLEditController' => 'applications/phurl/controller/PhabricatorPhurlURLEditController.php', ··· 2954 2957 'PhabricatorSetupIssue' => 'applications/config/issue/PhabricatorSetupIssue.php', 2955 2958 'PhabricatorSetupIssueUIExample' => 'applications/uiexample/examples/PhabricatorSetupIssueUIExample.php', 2956 2959 'PhabricatorSetupIssueView' => 'applications/config/view/PhabricatorSetupIssueView.php', 2960 + 'PhabricatorShortSite' => 'aphront/site/PhabricatorShortSite.php', 2957 2961 'PhabricatorSimpleEditType' => 'applications/transactions/edittype/PhabricatorSimpleEditType.php', 2958 2962 'PhabricatorSite' => 'aphront/site/PhabricatorSite.php', 2959 2963 'PhabricatorSlowvoteApplication' => 'applications/slowvote/application/PhabricatorSlowvoteApplication.php', ··· 6774 6778 'PhabricatorPhrictionApplication' => 'PhabricatorApplication', 6775 6779 'PhabricatorPhrictionConfigOptions' => 'PhabricatorApplicationConfigOptions', 6776 6780 'PhabricatorPhurlApplication' => 'PhabricatorApplication', 6781 + 'PhabricatorPhurlConfigOptions' => 'PhabricatorApplicationConfigOptions', 6777 6782 'PhabricatorPhurlController' => 'PhabricatorController', 6778 6783 'PhabricatorPhurlDAO' => 'PhabricatorLiskDAO', 6779 6784 'PhabricatorPhurlLinkRemarkupRule' => 'PhutilRemarkupRule', 6780 6785 'PhabricatorPhurlRemarkupRule' => 'PhabricatorObjectRemarkupRule', 6781 6786 'PhabricatorPhurlSchemaSpec' => 'PhabricatorConfigSchemaSpec', 6787 + 'PhabricatorPhurlShortURLController' => 'PhabricatorPhurlController', 6788 + 'PhabricatorPhurlShortURLDefaultController' => 'PhabricatorPhurlController', 6782 6789 'PhabricatorPhurlURL' => array( 6783 6790 'PhabricatorPhurlDAO', 6784 6791 'PhabricatorPolicyInterface', ··· 7167 7174 'PhabricatorSetupIssue' => 'Phobject', 7168 7175 'PhabricatorSetupIssueUIExample' => 'PhabricatorUIExample', 7169 7176 'PhabricatorSetupIssueView' => 'AphrontView', 7177 + 'PhabricatorShortSite' => 'PhabricatorSite', 7170 7178 'PhabricatorSimpleEditType' => 'PhabricatorEditType', 7171 7179 'PhabricatorSite' => 'AphrontSite', 7172 7180 'PhabricatorSlowvoteApplication' => 'PhabricatorApplication',
+44
src/aphront/site/PhabricatorShortSite.php
··· 1 + <?php 2 + 3 + final class PhabricatorShortSite extends PhabricatorSite { 4 + 5 + public function getDescription() { 6 + return pht('Serves shortened URLs.'); 7 + } 8 + 9 + public function getPriority() { 10 + return 2500; 11 + } 12 + 13 + public function newSiteForRequest(AphrontRequest $request) { 14 + $host = $request->getHost(); 15 + 16 + $uri = PhabricatorEnv::getEnvConfig('phurl.short-uri'); 17 + if (!strlen($uri)) { 18 + return null; 19 + } 20 + 21 + $phurl_installed = PhabricatorApplication::isClassInstalled( 22 + 'PhabricatorPhurlApplication'); 23 + if (!$phurl_installed) { 24 + return false; 25 + } 26 + 27 + if ($this->isHostMatch($host, array($uri))) { 28 + return new PhabricatorShortSite(); 29 + } 30 + 31 + return null; 32 + } 33 + 34 + public function getRoutingMaps() { 35 + $app = PhabricatorApplication::getByClass('PhabricatorPhurlApplication'); 36 + 37 + $maps = array(); 38 + $maps[] = $this->newRoutingMap() 39 + ->setApplication($app) 40 + ->setRoutes($app->getShortRoutes()); 41 + return $maps; 42 + } 43 + 44 + }
+35
src/applications/config/option/PhabricatorPhurlConfigOptions.php
··· 1 + <?php 2 + 3 + final class PhabricatorPhurlConfigOptions 4 + extends PhabricatorApplicationConfigOptions { 5 + 6 + public function getName() { 7 + return pht('Phurl'); 8 + } 9 + 10 + public function getDescription() { 11 + return pht('Options for Phurl.'); 12 + } 13 + 14 + public function getFontIcon() { 15 + return 'fa-link'; 16 + } 17 + 18 + public function getGroup() { 19 + return 'phurl'; 20 + } 21 + 22 + public function getOptions() { 23 + return array( 24 + $this->newOption('phurl.short-uri', 'string', null) 25 + ->setLocked(true) 26 + ->setSummary(pht('URI that Phurl will use to shorten URLs.')) 27 + ->setDescription( 28 + pht( 29 + 'Set the URI that Phurl will use to share shortened URLs.')) 30 + ->addExample( 31 + 'https://some-very-short-domain.museum/', 32 + pht('Valid Setting')), 33 + ); 34 + } 35 + }
+7
src/applications/phurl/application/PhabricatorPhurlApplication.php
··· 51 51 ); 52 52 } 53 53 54 + public function getShortRoutes() { 55 + return array( 56 + '/u/(?P<append>[^/]+)' => 'PhabricatorPhurlShortURLController', 57 + '.*' => 'PhabricatorPhurlShortURLDefaultController', 58 + ); 59 + } 60 + 54 61 }
+19
src/applications/phurl/controller/PhabricatorPhurlShortURLController.php
··· 1 + <?php 2 + 3 + final class PhabricatorPhurlShortURLController 4 + extends PhabricatorPhurlController { 5 + 6 + public function shouldRequireLogin() { 7 + return false; 8 + } 9 + 10 + public function handleRequest(AphrontRequest $request) { 11 + $viewer = $this->getViewer(); 12 + $append = $request->getURIData('append'); 13 + $main_domain_uri = PhabricatorEnv::getProductionURI('/u/'.$append); 14 + 15 + return id(new AphrontRedirectResponse()) 16 + ->setIsExternal(true) 17 + ->setURI($main_domain_uri); 18 + } 19 + }
+13
src/applications/phurl/controller/PhabricatorPhurlShortURLDefaultController.php
··· 1 + <?php 2 + 3 + final class PhabricatorPhurlShortURLDefaultController 4 + extends PhabricatorPhurlController { 5 + 6 + public function shouldRequireLogin() { 7 + return false; 8 + } 9 + 10 + public function handleRequest(AphrontRequest $request) { 11 + return new Aphront404Response(); 12 + } 13 + }
+4 -1
src/applications/phurl/controller/PhabricatorPhurlURLAccessController.php
··· 3 3 final class PhabricatorPhurlURLAccessController 4 4 extends PhabricatorPhurlController { 5 5 6 + public function shouldAllowPublic() { 7 + return true; 8 + } 9 + 6 10 public function handleRequest(AphrontRequest $request) { 7 11 $viewer = $this->getViewer(); 8 12 $id = $request->getURIData('id'); ··· 32 36 return id(new AphrontRedirectResponse())->setURI('/'.$url->getMonogram()); 33 37 } 34 38 } 35 - 36 39 }