mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-18 17:58:37 +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:
parent
8b7f8cb61f
commit
39cb5e7211
5 changed files with 40 additions and 11 deletions
|
@ -136,6 +136,10 @@ final class PhabricatorMentionRemarkupRule extends PhutilRemarkupRule {
|
||||||
),
|
),
|
||||||
'@'.$user->getUserName());
|
'@'.$user->getUserName());
|
||||||
} else {
|
} else {
|
||||||
|
if ($engine->getConfig('uri.full')) {
|
||||||
|
$user_href = PhabricatorEnv::getURI($user_href);
|
||||||
|
}
|
||||||
|
|
||||||
$tag = id(new PHUITagView())
|
$tag = id(new PHUITagView())
|
||||||
->setType(PHUITagView::TYPE_PERSON)
|
->setType(PHUITagView::TYPE_PERSON)
|
||||||
->setPHID($user->getPHID())
|
->setPHID($user->getPHID())
|
||||||
|
|
|
@ -78,10 +78,14 @@ final class PhamePostViewController
|
||||||
->executeOne();
|
->executeOne();
|
||||||
$blogger_profile = $blogger->loadUserProfile();
|
$blogger_profile = $blogger->loadUserProfile();
|
||||||
|
|
||||||
|
|
||||||
|
$author_uri = '/p/'.$blogger->getUsername().'/';
|
||||||
|
$author_uri = PhabricatorEnv::getURI($author_uri);
|
||||||
|
|
||||||
$author = phutil_tag(
|
$author = phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => '/p/'.$blogger->getUsername().'/',
|
'href' => $author_uri,
|
||||||
),
|
),
|
||||||
$blogger->getUsername());
|
$blogger->getUsername());
|
||||||
|
|
||||||
|
@ -105,7 +109,7 @@ final class PhamePostViewController
|
||||||
$blogger_profile->getTitle(),
|
$blogger_profile->getTitle(),
|
||||||
))
|
))
|
||||||
->setImage($blogger->getProfileImageURI())
|
->setImage($blogger->getProfileImageURI())
|
||||||
->setImageHref('/p/'.$blogger->getUsername());
|
->setImageHref($author_uri);
|
||||||
|
|
||||||
$timeline = $this->buildTransactionTimeline(
|
$timeline = $this->buildTransactionTimeline(
|
||||||
$post,
|
$post,
|
||||||
|
@ -128,10 +132,10 @@ final class PhamePostViewController
|
||||||
|
|
||||||
$next_view = new PhameNextPostView();
|
$next_view = new PhameNextPostView();
|
||||||
if ($next) {
|
if ($next) {
|
||||||
$next_view->setNext($next->getTitle(), $next->getViewURI());
|
$next_view->setNext($next->getTitle(), $next->getLiveURI());
|
||||||
}
|
}
|
||||||
if ($prev) {
|
if ($prev) {
|
||||||
$next_view->setPrevious($prev->getTitle(), $prev->getViewURI());
|
$next_view->setPrevious($prev->getTitle(), $prev->getLiveURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
$document->setFoot($next_view);
|
$document->setFoot($next_view);
|
||||||
|
|
|
@ -62,8 +62,19 @@ final class PhamePostListView extends AphrontTagView {
|
||||||
|
|
||||||
$list = array();
|
$list = array();
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
$blogger = $handles[$post->getBloggerPHID()]->renderLink();
|
$blogger_name = $handles[$post->getBloggerPHID()]->getName();
|
||||||
$blogger_uri = $handles[$post->getBloggerPHID()]->getURI();
|
$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();
|
$blogger_image = $handles[$post->getBloggerPHID()]->getImageURI();
|
||||||
|
|
||||||
$phame_post = null;
|
$phame_post = null;
|
||||||
|
@ -74,7 +85,6 @@ final class PhamePostListView extends AphrontTagView {
|
||||||
$phame_post = phutil_tag('em', array(), pht('(Empty Post)'));
|
$phame_post = phutil_tag('em', array(), pht('(Empty Post)'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$blogger = phutil_tag('strong', array(), $blogger);
|
|
||||||
$date = phabricator_datetime($post->getDatePublished(), $viewer);
|
$date = phabricator_datetime($post->getDatePublished(), $viewer);
|
||||||
|
|
||||||
$blog = $post->getBlog();
|
$blog = $post->getBlog();
|
||||||
|
|
|
@ -351,10 +351,13 @@ final class PhabricatorMarkupEngine extends Phobject {
|
||||||
* @task engine
|
* @task engine
|
||||||
*/
|
*/
|
||||||
public static function newPhameMarkupEngine() {
|
public static function newPhameMarkupEngine() {
|
||||||
return self::newMarkupEngine(array(
|
return self::newMarkupEngine(
|
||||||
'macros' => false,
|
array(
|
||||||
'uri.full' => true,
|
'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']);
|
$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 = array();
|
||||||
$rules[] = new PhutilRemarkupEscapeRemarkupRule();
|
$rules[] = new PhutilRemarkupEscapeRemarkupRule();
|
||||||
$rules[] = new PhutilRemarkupMonospaceRule();
|
$rules[] = new PhutilRemarkupMonospaceRule();
|
||||||
|
|
|
@ -82,7 +82,7 @@ final class PHUIRemarkupView extends AphrontView {
|
||||||
$engine_key = PhabricatorHash::digestForIndex($engine_key);
|
$engine_key = PhabricatorHash::digestForIndex($engine_key);
|
||||||
|
|
||||||
$cache = PhabricatorCaches::getRequestCache();
|
$cache = PhabricatorCaches::getRequestCache();
|
||||||
$cache_key = "remarkup.engine({$viewer}, {$engine_key})";
|
$cache_key = "remarkup.engine({$viewer_key}, {$engine_key})";
|
||||||
|
|
||||||
$engine = $cache->getKey($cache_key);
|
$engine = $cache->getKey($cache_key);
|
||||||
if (!$engine) {
|
if (!$engine) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue