Skip to content

Commit 39cb5e7

Browse files
author
epriestley
committedJun 2, 2016
Improve some Phame custom domain remarkup and link behaviors
Summary: Ref T6299. This makes more of the links point to the right places. Not covered yet: - Projects and subscribers don't point to the right place (this is a little tricky to fix, I think). - `[[ #anchor ]]`s won't do the right thing in, uh, email, I guess, since `uri.here` is not set. This is also a little tricky. Possibly we should just remove subscribers (although also kind of tricky). Test Plan: On a custom-domain blog, observed that fewer things were broken. Reviewers: chad Reviewed By: chad Maniphest Tasks: T6299 Differential Revision: https://secure.phabricator.com/D16007
1 parent 8b7f8cb commit 39cb5e7

File tree

5 files changed

+40
-11
lines changed

5 files changed

+40
-11
lines changed
 

‎src/applications/people/markup/PhabricatorMentionRemarkupRule.php

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ public function didMarkupText() {
136136
),
137137
'@'.$user->getUserName());
138138
} else {
139+
if ($engine->getConfig('uri.full')) {
140+
$user_href = PhabricatorEnv::getURI($user_href);
141+
}
142+
139143
$tag = id(new PHUITagView())
140144
->setType(PHUITagView::TYPE_PERSON)
141145
->setPHID($user->getPHID())

‎src/applications/phame/controller/post/PhamePostViewController.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,14 @@ public function handleRequest(AphrontRequest $request) {
7878
->executeOne();
7979
$blogger_profile = $blogger->loadUserProfile();
8080

81+
82+
$author_uri = '/p/'.$blogger->getUsername().'/';
83+
$author_uri = PhabricatorEnv::getURI($author_uri);
84+
8185
$author = phutil_tag(
8286
'a',
8387
array(
84-
'href' => '/p/'.$blogger->getUsername().'/',
88+
'href' => $author_uri,
8589
),
8690
$blogger->getUsername());
8791

@@ -105,7 +109,7 @@ public function handleRequest(AphrontRequest $request) {
105109
$blogger_profile->getTitle(),
106110
))
107111
->setImage($blogger->getProfileImageURI())
108-
->setImageHref('/p/'.$blogger->getUsername());
112+
->setImageHref($author_uri);
109113

110114
$timeline = $this->buildTransactionTimeline(
111115
$post,
@@ -128,10 +132,10 @@ public function handleRequest(AphrontRequest $request) {
128132

129133
$next_view = new PhameNextPostView();
130134
if ($next) {
131-
$next_view->setNext($next->getTitle(), $next->getViewURI());
135+
$next_view->setNext($next->getTitle(), $next->getLiveURI());
132136
}
133137
if ($prev) {
134-
$next_view->setPrevious($prev->getTitle(), $prev->getViewURI());
138+
$next_view->setPrevious($prev->getTitle(), $prev->getLiveURI());
135139
}
136140

137141
$document->setFoot($next_view);

‎src/applications/phame/view/PhamePostListView.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,19 @@ protected function getTagContent() {
6262

6363
$list = array();
6464
foreach ($posts as $post) {
65-
$blogger = $handles[$post->getBloggerPHID()]->renderLink();
65+
$blogger_name = $handles[$post->getBloggerPHID()]->getName();
6666
$blogger_uri = $handles[$post->getBloggerPHID()]->getURI();
67+
$blogger_uri = PhabricatorEnv::getURI($blogger_uri);
68+
69+
// Render a link manually to make sure we point at the correct domain.
70+
$blogger = phutil_tag(
71+
'a',
72+
array(
73+
'href' => $blogger_uri,
74+
),
75+
$blogger_name);
76+
$blogger = phutil_tag('strong', array(), $blogger);
77+
6778
$blogger_image = $handles[$post->getBloggerPHID()]->getImageURI();
6879

6980
$phame_post = null;
@@ -74,7 +85,6 @@ protected function getTagContent() {
7485
$phame_post = phutil_tag('em', array(), pht('(Empty Post)'));
7586
}
7687

77-
$blogger = phutil_tag('strong', array(), $blogger);
7888
$date = phabricator_datetime($post->getDatePublished(), $viewer);
7989

8090
$blog = $post->getBlog();

‎src/infrastructure/markup/PhabricatorMarkupEngine.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,13 @@ public static function newPhrictionMarkupEngine() {
351351
* @task engine
352352
*/
353353
public static function newPhameMarkupEngine() {
354-
return self::newMarkupEngine(array(
355-
'macros' => false,
356-
'uri.full' => true,
357-
));
354+
return self::newMarkupEngine(
355+
array(
356+
'macros' => false,
357+
'uri.full' => true,
358+
'uri.same-window' => true,
359+
'uri.base' => PhabricatorEnv::getURI('/'),
360+
));
358361
}
359362

360363

@@ -487,6 +490,14 @@ public static function newMarkupEngine(array $options) {
487490

488491
$engine->setConfig('uri.full', $options['uri.full']);
489492

493+
if (isset($options['uri.base'])) {
494+
$engine->setConfig('uri.base', $options['uri.base']);
495+
}
496+
497+
if (isset($options['uri.same-window'])) {
498+
$engine->setConfig('uri.same-window', $options['uri.same-window']);
499+
}
500+
490501
$rules = array();
491502
$rules[] = new PhutilRemarkupEscapeRemarkupRule();
492503
$rules[] = new PhutilRemarkupMonospaceRule();

‎src/infrastructure/markup/view/PHUIRemarkupView.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function getEngine() {
8282
$engine_key = PhabricatorHash::digestForIndex($engine_key);
8383

8484
$cache = PhabricatorCaches::getRequestCache();
85-
$cache_key = "remarkup.engine({$viewer}, {$engine_key})";
85+
$cache_key = "remarkup.engine({$viewer_key}, {$engine_key})";
8686

8787
$engine = $cache->getKey($cache_key);
8888
if (!$engine) {

0 commit comments

Comments
 (0)
Failed to load comments.