Skip to content

Commit 7ce5853

Browse files
author
Josh Cox
committed
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
1 parent f5537fd commit 7ce5853

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/applications/phurl/controller/PhabricatorPhurlURLViewController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function buildHeaderView(PhabricatorPhurlURL $url) {
8686
->setTag('a')
8787
->setText(pht('Visit URL'))
8888
->setIcon('fa-external-link')
89-
->setHref("u/{$id}")
89+
->setHref($url->getRedirectURI())
9090
->setDisabled(!$url->isValid());
9191

9292
$header = id(new PHUIHeaderView())
@@ -129,6 +129,10 @@ private function buildPropertySectionView(PhabricatorPhurlURL $url) {
129129
$properties = id(new PHUIPropertyListView())
130130
->setUser($viewer);
131131

132+
$properties->addProperty(
133+
pht('Short URL'),
134+
$url->getRedirectURI());
135+
132136
$properties->addProperty(
133137
pht('Original URL'),
134138
$url->getLongURL());

src/applications/phurl/storage/PhabricatorPhurlURL.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,18 @@ public function getDisplayName() {
9999

100100
public function getRedirectURI() {
101101
if (strlen($this->getAlias())) {
102-
return '/u/'.$this->getAlias();
102+
$path = '/u/'.$this->getAlias();
103103
} else {
104-
return '/u/'.$this->getID();
104+
$path = '/u/'.$this->getID();
105105
}
106+
$short_domain = PhabricatorEnv::getEnvConfig('phurl.short-uri');
107+
if (!$short_domain) {
108+
return $path;
109+
}
110+
111+
$uri = new PhutilURI($short_domain);
112+
$uri->setPath($path);
113+
return (string)$uri;
106114
}
107115

108116
/* -( PhabricatorPolicyInterface )----------------------------------------- */

0 commit comments

Comments
 (0)