From 11f8fffe5bb7da1cbcd0c71c27c129ebe3801629 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 20 Apr 2016 06:00:10 -0700 Subject: [PATCH] Fix Phriction document linking in mail bodies Summary: Fixes T10840. When rendering mail, this rule wasn't falling through in quite the right way. Also adjust where the rules are for this so the special styles show up in Maniphest, etc. Test Plan: Made this comment: {F1238266} Which produced this HTML: {F1238267} ...and sent this mail: {F1238283} Reviewers: hach-que, chad Reviewed By: chad Maniphest Tasks: T10840 Differential Revision: https://secure.phabricator.com/D15767 --- resources/celerity/map.php | 10 +++++----- .../phriction/markup/PhrictionRemarkupRule.php | 16 ++++++++++++++-- .../phriction/phriction-document-css.css | 14 -------------- webroot/rsrc/css/core/remarkup.css | 12 ++++++++++++ 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 49f38b3c51..5cc7b4c250 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -7,7 +7,7 @@ */ return array( 'names' => array( - 'core.pkg.css' => 'ce06b6f6', + 'core.pkg.css' => '31417876', 'core.pkg.js' => '37344f3c', 'darkconsole.pkg.js' => 'e7393ebb', 'differential.pkg.css' => '7ba78475', @@ -88,7 +88,7 @@ return array( 'rsrc/css/application/phortune/phortune-credit-card-form.css' => '8391eb02', 'rsrc/css/application/phortune/phortune.css' => '9149f103', 'rsrc/css/application/phrequent/phrequent.css' => 'ffc185ad', - 'rsrc/css/application/phriction/phriction-document-css.css' => '55446c91', + 'rsrc/css/application/phriction/phriction-document-css.css' => '4282e4ad', 'rsrc/css/application/policy/policy-edit.css' => '815c66f7', 'rsrc/css/application/policy/policy-transaction-detail.css' => '82100a43', 'rsrc/css/application/policy/policy.css' => '957ea14c', @@ -104,7 +104,7 @@ return array( 'rsrc/css/application/tokens/tokens.css' => '3d0f239e', 'rsrc/css/application/uiexample/example.css' => '528b19de', 'rsrc/css/core/core.css' => 'd0801452', - 'rsrc/css/core/remarkup.css' => '2c9ed46f', + 'rsrc/css/core/remarkup.css' => '6aae5360', 'rsrc/css/core/syntax.css' => '9fd11da8', 'rsrc/css/core/z-index.css' => '5b6fcf3f', 'rsrc/css/diviner/diviner-shared.css' => 'aa3656aa', @@ -777,7 +777,7 @@ return array( 'phabricator-object-selector-css' => '85ee8ce6', 'phabricator-phtize' => 'd254d646', 'phabricator-prefab' => 'e67df814', - 'phabricator-remarkup-css' => '2c9ed46f', + 'phabricator-remarkup-css' => '6aae5360', 'phabricator-search-results-css' => '7dea472c', 'phabricator-shaped-request' => '7cbe244b', 'phabricator-side-menu-view-css' => '3a3d9f41', @@ -807,7 +807,7 @@ return array( 'phortune-credit-card-form-css' => '8391eb02', 'phortune-css' => '9149f103', 'phrequent-css' => 'ffc185ad', - 'phriction-document-css' => '55446c91', + 'phriction-document-css' => '4282e4ad', 'phui-action-panel-css' => '91c7b835', 'phui-badge-view-css' => '3baef8db', 'phui-big-info-view-css' => 'bd903741', diff --git a/src/applications/phriction/markup/PhrictionRemarkupRule.php b/src/applications/phriction/markup/PhrictionRemarkupRule.php index 2c9ab76284..5f5a91a280 100644 --- a/src/applications/phriction/markup/PhrictionRemarkupRule.php +++ b/src/applications/phriction/markup/PhrictionRemarkupRule.php @@ -107,6 +107,10 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule { $name = $spec['explicitName']; $class = 'phriction-link'; + // If the name is something meaningful to humans, we'll render this + // in text as: "Title" . Otherwise, we'll just render: . + $is_interesting_name = (bool)strlen($name); + if (idx($existant_documents, $link) === null) { // The target document doesn't exist. if ($name === null) { @@ -127,6 +131,8 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule { $name = $visible_documents[$link] ->getContent() ->getTitle(); + + $is_interesting_name = true; } } @@ -143,7 +149,12 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule { if ($this->getEngine()->getState('toc')) { $text = $name; } else if ($text_mode || $mail_mode) { - return PhabricatorEnv::getProductionURI($href); + $href = PhabricatorEnv::getProductionURI($href); + if ($is_interesting_name) { + $text = pht('"%s" <%s>', $name, $href); + } else { + $text = pht('<%s>', $href); + } } else { if ($class === 'phriction-link-lock') { $name = array( @@ -164,8 +175,9 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule { 'class' => $class, ), $name); - $this->getEngine()->overwriteStoredText($spec['token'], $text); } + + $this->getEngine()->overwriteStoredText($spec['token'], $text); } } diff --git a/webroot/rsrc/css/application/phriction/phriction-document-css.css b/webroot/rsrc/css/application/phriction/phriction-document-css.css index 7728c8dd77..228515b3b3 100644 --- a/webroot/rsrc/css/application/phriction/phriction-document-css.css +++ b/webroot/rsrc/css/application/phriction/phriction-document-css.css @@ -32,17 +32,3 @@ .phriction-history-nav-table td.nav-next { text-align: right; } - -.phui-document-content .phriction-link { - font-weight: bold; -} - -.phui-document-content .phriction-link-missing { - font-weight: bold; - color: {$red}; -} - -.phui-document-content .phriction-link-lock { - font-weight: bold; - color: {$greytext}; -} diff --git a/webroot/rsrc/css/core/remarkup.css b/webroot/rsrc/css/core/remarkup.css index 2313939f4c..8f48d7228b 100644 --- a/webroot/rsrc/css/core/remarkup.css +++ b/webroot/rsrc/css/core/remarkup.css @@ -234,6 +234,18 @@ background: #ffaaaa; } +.phabricator-remarkup .phriction-link { + font-weight: bold; +} + +.phabricator-remarkup .phriction-link-missing { + color: {$red}; +} + +.phabricator-remarkup .phriction-link-lock { + color: {$greytext}; +} + .phabricator-remarkup-mention-nopermission .phui-tag-core { background: {$lightgreybackground}; color: {$lightgreytext};