From 7ce58539368524f11fa4bbf29cdd20a366d942a8 Mon Sep 17 00:00:00 2001 From: Josh Cox Date: Mon, 29 Aug 2016 20:41:14 -0400 Subject: [PATCH] Start actually showing the phurl urls to users Summary: Fixes T10679. Added a 'short url' field to the phurl link page and changed the "view url" button to link to the shortened version Test Plan: Create a phurl link (or navigate to an existing one) and note that there is now a field for "Short URL". Also verified that the "Visit URL" button in the top right still works as intended Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley, yelirekim Maniphest Tasks: T10679 Differential Revision: https://secure.phabricator.com/D16473 --- .../controller/PhabricatorPhurlURLViewController.php | 6 +++++- .../phurl/storage/PhabricatorPhurlURL.php | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php b/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php index 1c9a66f237..4e79670143 100644 --- a/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php +++ b/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php @@ -86,7 +86,7 @@ final class PhabricatorPhurlURLViewController ->setTag('a') ->setText(pht('Visit URL')) ->setIcon('fa-external-link') - ->setHref("u/{$id}") + ->setHref($url->getRedirectURI()) ->setDisabled(!$url->isValid()); $header = id(new PHUIHeaderView()) @@ -129,6 +129,10 @@ final class PhabricatorPhurlURLViewController $properties = id(new PHUIPropertyListView()) ->setUser($viewer); + $properties->addProperty( + pht('Short URL'), + $url->getRedirectURI()); + $properties->addProperty( pht('Original URL'), $url->getLongURL()); diff --git a/src/applications/phurl/storage/PhabricatorPhurlURL.php b/src/applications/phurl/storage/PhabricatorPhurlURL.php index 19d5968b0c..db82e20baf 100644 --- a/src/applications/phurl/storage/PhabricatorPhurlURL.php +++ b/src/applications/phurl/storage/PhabricatorPhurlURL.php @@ -99,10 +99,18 @@ final class PhabricatorPhurlURL extends PhabricatorPhurlDAO public function getRedirectURI() { if (strlen($this->getAlias())) { - return '/u/'.$this->getAlias(); + $path = '/u/'.$this->getAlias(); } else { - return '/u/'.$this->getID(); + $path = '/u/'.$this->getID(); } + $short_domain = PhabricatorEnv::getEnvConfig('phurl.short-uri'); + if (!$short_domain) { + return $path; + } + + $uri = new PhutilURI($short_domain); + $uri->setPath($path); + return (string)$uri; } /* -( PhabricatorPolicyInterface )----------------------------------------- */