1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

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
This commit is contained in:
epriestley 2016-05-22 09:13:45 -07:00
parent 8b7f8cb61f
commit 39cb5e7211
5 changed files with 40 additions and 11 deletions

View file

@ -136,6 +136,10 @@ final class PhabricatorMentionRemarkupRule extends PhutilRemarkupRule {
),
'@'.$user->getUserName());
} else {
if ($engine->getConfig('uri.full')) {
$user_href = PhabricatorEnv::getURI($user_href);
}
$tag = id(new PHUITagView())
->setType(PHUITagView::TYPE_PERSON)
->setPHID($user->getPHID())

View file

@ -78,10 +78,14 @@ final class PhamePostViewController
->executeOne();
$blogger_profile = $blogger->loadUserProfile();
$author_uri = '/p/'.$blogger->getUsername().'/';
$author_uri = PhabricatorEnv::getURI($author_uri);
$author = phutil_tag(
'a',
array(
'href' => '/p/'.$blogger->getUsername().'/',
'href' => $author_uri,
),
$blogger->getUsername());
@ -105,7 +109,7 @@ final class PhamePostViewController
$blogger_profile->getTitle(),
))
->setImage($blogger->getProfileImageURI())
->setImageHref('/p/'.$blogger->getUsername());
->setImageHref($author_uri);
$timeline = $this->buildTransactionTimeline(
$post,
@ -128,10 +132,10 @@ final class PhamePostViewController
$next_view = new PhameNextPostView();
if ($next) {
$next_view->setNext($next->getTitle(), $next->getViewURI());
$next_view->setNext($next->getTitle(), $next->getLiveURI());
}
if ($prev) {
$next_view->setPrevious($prev->getTitle(), $prev->getViewURI());
$next_view->setPrevious($prev->getTitle(), $prev->getLiveURI());
}
$document->setFoot($next_view);

View file

@ -62,8 +62,19 @@ final class PhamePostListView extends AphrontTagView {
$list = array();
foreach ($posts as $post) {
$blogger = $handles[$post->getBloggerPHID()]->renderLink();
$blogger_name = $handles[$post->getBloggerPHID()]->getName();
$blogger_uri = $handles[$post->getBloggerPHID()]->getURI();
$blogger_uri = PhabricatorEnv::getURI($blogger_uri);
// Render a link manually to make sure we point at the correct domain.
$blogger = phutil_tag(
'a',
array(
'href' => $blogger_uri,
),
$blogger_name);
$blogger = phutil_tag('strong', array(), $blogger);
$blogger_image = $handles[$post->getBloggerPHID()]->getImageURI();
$phame_post = null;
@ -74,7 +85,6 @@ final class PhamePostListView extends AphrontTagView {
$phame_post = phutil_tag('em', array(), pht('(Empty Post)'));
}
$blogger = phutil_tag('strong', array(), $blogger);
$date = phabricator_datetime($post->getDatePublished(), $viewer);
$blog = $post->getBlog();

View file

@ -351,10 +351,13 @@ final class PhabricatorMarkupEngine extends Phobject {
* @task engine
*/
public static function newPhameMarkupEngine() {
return self::newMarkupEngine(array(
'macros' => false,
'uri.full' => true,
));
return self::newMarkupEngine(
array(
'macros' => false,
'uri.full' => true,
'uri.same-window' => true,
'uri.base' => PhabricatorEnv::getURI('/'),
));
}
@ -487,6 +490,14 @@ final class PhabricatorMarkupEngine extends Phobject {
$engine->setConfig('uri.full', $options['uri.full']);
if (isset($options['uri.base'])) {
$engine->setConfig('uri.base', $options['uri.base']);
}
if (isset($options['uri.same-window'])) {
$engine->setConfig('uri.same-window', $options['uri.same-window']);
}
$rules = array();
$rules[] = new PhutilRemarkupEscapeRemarkupRule();
$rules[] = new PhutilRemarkupMonospaceRule();

View file

@ -82,7 +82,7 @@ final class PHUIRemarkupView extends AphrontView {
$engine_key = PhabricatorHash::digestForIndex($engine_key);
$cache = PhabricatorCaches::getRequestCache();
$cache_key = "remarkup.engine({$viewer}, {$engine_key})";
$cache_key = "remarkup.engine({$viewer_key}, {$engine_key})";
$engine = $cache->getKey($cache_key);
if (!$engine) {