Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18348317
D10859.id26075.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D10859.id26075.diff
View Options
diff --git a/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php b/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php
--- a/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php
+++ b/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php
@@ -33,6 +33,23 @@
return $this;
}
+ public function addRemarkupSection($text) {
+ $engine = PhabricatorMarkupEngine::newMarkupEngine(array());
+ $engine->setConfig('viewer', PhabricatorUser::getOmnipotentUser());
+ $engine->setMode(PhutilRemarkupEngine::MODE_TEXT);
+ $styled_text = $engine->markupText($text);
+ $this->sections[] = $styled_text;
+
+ $mail_engine = PhabricatorMarkupEngine::newMarkupEngine(array());
+ $mail_engine->setConfig('viewer', PhabricatorUser::getOmnipotentUser());
+ $mail_engine->setMode(PhutilRemarkupEngine::MODE_HTML_MAIL);
+ $mail_engine->setConfig('uri.base', PhabricatorEnv::getProductionURI('/'));
+ $html = $mail_engine->markupText($text);
+ $this->htmlSections[] = $html;
+
+ return $this;
+ }
+
public function addRawPlaintextSection($text) {
if (strlen($text)) {
$text = rtrim($text);
diff --git a/src/applications/paste/mail/PasteCreateMailReceiver.php b/src/applications/paste/mail/PasteCreateMailReceiver.php
--- a/src/applications/paste/mail/PasteCreateMailReceiver.php
+++ b/src/applications/paste/mail/PasteCreateMailReceiver.php
@@ -72,7 +72,7 @@
$subject = pht('You successfully created a paste.');
$paste_uri = PhabricatorEnv::getProductionURI($paste->getURI());
$body = new PhabricatorMetaMTAMailBody();
- $body->addRawSection($subject);
+ $body->addRemarkupSection($subject);
$body->addTextSection(pht('PASTE LINK'), $paste_uri);
id(new PhabricatorMetaMTAMail())
diff --git a/src/applications/people/markup/PhabricatorMentionRemarkupRule.php b/src/applications/people/markup/PhabricatorMentionRemarkupRule.php
--- a/src/applications/people/markup/PhabricatorMentionRemarkupRule.php
+++ b/src/applications/people/markup/PhabricatorMentionRemarkupRule.php
@@ -100,11 +100,17 @@
$user = $actual_users[$username];
Javelin::initBehavior('phabricator-hovercards');
+ $user_href = '/p/'.$user->getUserName().'/';
+
+ if ($engine->isHTMLMailMode()) {
+ $user_href = PhabricatorEnv::getProductionURI($user_href);
+ }
+
$tag = id(new PHUITagView())
->setType(PHUITagView::TYPE_PERSON)
->setPHID($user->getPHID())
->setName('@'.$user->getUserName())
- ->setHref('/p/'.$user->getUserName().'/');
+ ->setHref($user_href);
if (!$user->isUserActivated()) {
$tag->setDotColor(PHUITagView::COLOR_GREY);
diff --git a/src/applications/phriction/markup/PhrictionRemarkupRule.php b/src/applications/phriction/markup/PhrictionRemarkupRule.php
--- a/src/applications/phriction/markup/PhrictionRemarkupRule.php
+++ b/src/applications/phriction/markup/PhrictionRemarkupRule.php
@@ -29,9 +29,12 @@
$slug = PhrictionDocument::getSlugURI($slug);
$href = (string)id(new PhutilURI($slug))->setFragment($fragment);
+ $text_mode = $this->getEngine()->isTextMode();
+ $mail_mode = $this->getEngine()->isHTMLMailMode();
+
if ($this->getEngine()->getState('toc')) {
$text = $name;
- } else if ($this->getEngine()->isTextMode()) {
+ } else if ($text_mode || $mail_mode) {
return PhabricatorEnv::getProductionURI($href);
} else {
$text = $this->newTag(
diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
--- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
+++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
@@ -2162,7 +2162,7 @@
$body->addRawSection(implode("\n", $headers));
foreach ($comments as $comment) {
- $body->addRawSection($comment);
+ $body->addRemarkupSection($comment);
}
if ($object instanceof PhabricatorCustomFieldInterface) {
diff --git a/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php b/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php
--- a/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php
+++ b/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php
@@ -44,9 +44,14 @@
return $handle->getURI();
}
- protected function renderObjectRef($object, $handle, $anchor, $id) {
+ protected function renderObjectRefForAnyMedia (
+ $object,
+ $handle,
+ $anchor,
+ $id) {
$href = $this->getObjectHref($object, $handle, $id);
$text = $this->getObjectNamePrefix().$id;
+ $status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
if ($anchor) {
$href = $href.'#'.$anchor;
@@ -55,10 +60,30 @@
if ($this->getEngine()->isTextMode()) {
return PhabricatorEnv::getProductionURI($href);
+ } else if ($this->getEngine()->isHTMLMailMode()) {
+ $href = PhabricatorEnv::getProductionURI($href);
+
+ $strikethrough = $handle->getStatus() == $status_closed ?
+ 'text-decoration: line-through;' :
+ 'text-decoration: none;';
+
+ return $this->renderObjectTagForMail($text, $href, $strikethrough);
}
+ return $this->renderObjectRef($object, $handle, $anchor, $id);
+
+ }
+
+ protected function renderObjectRef($object, $handle, $anchor, $id) {
+ $href = $this->getObjectHref($object, $handle, $id);
+ $text = $this->getObjectNamePrefix().$id;
$status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
+ if ($anchor) {
+ $href = $href.'#'.$anchor;
+ $text = $text.'#'.$anchor;
+ }
+
$attr = array(
'phid' => $handle->getPHID(),
'closed' => ($handle->getStatus() == $status_closed),
@@ -67,15 +92,29 @@
return $this->renderHovertag($text, $href, $attr);
}
- protected function renderObjectEmbed($object, $handle, $options) {
+ protected function renderObjectEmbedForAnyMedia($object, $handle, $options) {
$name = $handle->getFullName();
$href = $handle->getURI();
$status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
if ($this->getEngine()->isTextMode()) {
return $name.' <'.PhabricatorEnv::getProductionURI($href).'>';
+ } else if ($this->getEngine()->isHTMLMailMode()) {
+ $href = PhabricatorEnv::getProductionURI($href);
+ $strikethrough = $handle->getStatus() == $status_closed ?
+ 'text-decoration: line-through;' :
+ 'text-decoration: none;';
+
+ return $this->renderObjectTagForMail($name, $href, $strikethrough);
}
+ return $this->renderObjectEmbed($object, $handle, $options);
+ }
+
+ protected function renderObjectEmbed($object, $handle, $options) {
+ $name = $handle->getFullName();
+ $href = $handle->getURI();
+ $status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
$attr = array(
'phid' => $handle->getPHID(),
'closed' => ($handle->getStatus() == $status_closed),
@@ -84,6 +123,22 @@
return $this->renderHovertag($name, $href, $attr);
}
+ protected function renderObjectTagForMail($text, $href, $strikethrough) {
+ return phutil_tag(
+ 'a',
+ array(
+ 'href' => $href,
+ 'style' => 'background-color: #e7e7e7;
+ border-color: #e7e7e7;
+ border-radius: 3px;
+ padding: 0 4px;
+ font-weight: bold;
+ color: black;'
+ .$strikethrough,
+ ),
+ $text);
+ }
+
protected function renderHovertag($name, $href, array $attr = array()) {
return id(new PHUITagView())
->setName($name)
@@ -282,7 +337,8 @@
$object = $objects[$spec['id']];
switch ($spec['type']) {
case 'ref':
- $view = $this->renderObjectRef(
+
+ $view = $this->renderObjectRefForAnyMedia(
$object,
$handle,
$spec['anchor'],
@@ -290,7 +346,10 @@
break;
case 'embed':
$spec['options'] = $this->assertFlatText($spec['options']);
- $view = $this->renderObjectEmbed($object, $handle, $spec['options']);
+ $view = $this->renderObjectEmbedForAnyMedia(
+ $object,
+ $handle,
+ $spec['options']);
break;
}
$engine->overwriteStoredText($spec['token'], $view);
diff --git a/src/infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php b/src/infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php
--- a/src/infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php
+++ b/src/infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php
@@ -20,8 +20,10 @@
public function markupYoutubeLink() {
$v = idx($this->uri->getQueryParams(), 'v');
+ $text_mode = $this->getEngine()->isTextMode();
+ $mail_mode = $this->getEngine()->isHTMLMailMode();
- if ($this->getEngine()->isTextMode()) {
+ if ($text_mode || $mail_mode) {
return $this->getEngine()->storeText('http://youtu.be/'.$v);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Aug 27 2025, 4:33 PM (7 w, 9 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8425637
Default Alt Text
D10859.id26075.diff (8 KB)
Attached To
Mode
D10859: Process Remarkup in text and HTML email bodies appropriately
Attached
Detach File
Event Timeline
Log In to Comment