Differential D15857 Diff 38211 src/applications/differential/mail/DifferentialInlineCommentMailView.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/mail/DifferentialInlineCommentMailView.php
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | foreach ($groups as $changeset_id => $group) { | ||||
$patch_html = $this->getPatch($hunk_parser, $comment, true); | $patch_html = $this->getPatch($hunk_parser, $comment, true); | ||||
$context_html = $this->renderPatch($comment, $patch_html, true); | $context_html = $this->renderPatch($comment, $patch_html, true); | ||||
} | } | ||||
$render_text = $this->renderInline($comment, false, false); | $render_text = $this->renderInline($comment, false, false); | ||||
$render_html = $this->renderInline($comment, true, false); | $render_html = $this->renderInline($comment, true, false); | ||||
$section->addPlaintextFragment($context_text); | $section->addPlaintextFragment($context_text); | ||||
$section->addHTMLFragment($context_html); | |||||
$section->addPlaintextFragment($spacer_text); | $section->addPlaintextFragment($spacer_text); | ||||
$section->addPlaintextFragment($render_text); | $section->addPlaintextFragment($render_text); | ||||
$section->addHTMLFragment($render_html); | |||||
$style = array( | |||||
'border: 1px solid #C7CCD9;', | |||||
'border-radius: 3px;', | |||||
); | |||||
$html_fragment = phutil_tag( | |||||
'div', | |||||
array( | |||||
'style' => implode(' ', $style), | |||||
), | |||||
array( | |||||
$context_html, | |||||
$render_html, | |||||
)); | |||||
$section->addHTMLFragment($html_fragment); | |||||
if (!$is_last_group || !$is_last_inline) { | if (!$is_last_group || !$is_last_inline) { | ||||
$section->addPlaintextFragment($spacer_text); | $section->addPlaintextFragment($spacer_text); | ||||
$section->addHTMLFragment($spacer_html); | $section->addHTMLFragment($spacer_html); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | private function renderInline( | ||||
if (!$changeset) { | if (!$changeset) { | ||||
return null; | return null; | ||||
} | } | ||||
$content = $comment->getContent(); | $content = $comment->getContent(); | ||||
$content = $this->renderRemarkupContent($content, $is_html); | $content = $this->renderRemarkupContent($content, $is_html); | ||||
if ($is_quote) { | if ($is_quote) { | ||||
$header = $this->renderHeader($comment, $is_html, true); | |||||
} else { | |||||
$header = null; | |||||
} | |||||
if ($is_html) { | if ($is_html) { | ||||
$style = array( | $style = array( | ||||
'padding: 4px 0;', | 'padding: 8px 12px;', | ||||
); | ); | ||||
if ($is_quote) { | |||||
$style[] = 'color: #74777D;'; | |||||
} | |||||
$content = phutil_tag( | $content = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'style' => implode(' ', $style), | 'style' => implode(' ', $style), | ||||
), | ), | ||||
$content); | $content); | ||||
} | } | ||||
$header = $this->renderHeader($comment, $is_html, true); | |||||
} else { | |||||
$header = null; | |||||
} | |||||
$parts = array( | $parts = array( | ||||
$header, | $header, | ||||
"\n", | "\n", | ||||
$content, | $content, | ||||
); | ); | ||||
if (!$is_html) { | if (!$is_html) { | ||||
Show All 17 Lines | private function renderRemarkupContent($content, $is_html) { | ||||
$production_uri = PhabricatorEnv::getProductionURI('/'); | $production_uri = PhabricatorEnv::getProductionURI('/'); | ||||
if ($is_html) { | if ($is_html) { | ||||
$mode = PhutilRemarkupEngine::MODE_HTML_MAIL; | $mode = PhutilRemarkupEngine::MODE_HTML_MAIL; | ||||
} else { | } else { | ||||
$mode = PhutilRemarkupEngine::MODE_TEXT; | $mode = PhutilRemarkupEngine::MODE_TEXT; | ||||
} | } | ||||
$attributes = array( | |||||
'style' => 'padding: 0; margin: 0;', | |||||
); | |||||
$engine = PhabricatorMarkupEngine::newMarkupEngine(array()) | $engine = PhabricatorMarkupEngine::newMarkupEngine(array()) | ||||
->setConfig('viewer', $viewer) | ->setConfig('viewer', $viewer) | ||||
->setConfig('uri.base', $production_uri) | ->setConfig('uri.base', $production_uri) | ||||
->setConfig('default.p.attributes', $attributes) | |||||
->setMode($mode); | ->setMode($mode); | ||||
try { | try { | ||||
return $engine->markupText($content); | return $engine->markupText($content); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
return $content; | return $content; | ||||
} | } | ||||
} | } | ||||
Show All 15 Lines | foreach ($block as $key => $line) { | ||||
$block[$key] = '> '.$line; | $block[$key] = '> '.$line; | ||||
} | } | ||||
return implode('', $block); | return implode('', $block); | ||||
} | } | ||||
private function quoteHTML($block) { | private function quoteHTML($block) { | ||||
$styles = array( | $styles = array( | ||||
'padding: 4px 8px;', | 'padding: 0;', | ||||
'background: #F8F9FC;', | 'background: #F7F7F7;', | ||||
'border-left: 3px solid #a7b5bf;', | 'border-color: #e3e4e8;', | ||||
'margin: 4px 0 0;', | 'border-style: solid;', | ||||
'border-width: 0 0 1px 0;', | |||||
'margin: 0;', | |||||
); | ); | ||||
$styles = implode(' ', $styles); | $styles = implode(' ', $styles); | ||||
return phutil_tag( | return phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'style' => $styles, | 'style' => $styles, | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | final class DifferentialInlineCommentMailView | ||||
private function renderHeader( | private function renderHeader( | ||||
DifferentialTransactionComment $comment, | DifferentialTransactionComment $comment, | ||||
$is_html, | $is_html, | ||||
$with_author) { | $with_author) { | ||||
$changeset = $this->getChangeset($comment->getChangesetID()); | $changeset = $this->getChangeset($comment->getChangesetID()); | ||||
$path = $changeset->getFilename(); | $path = $changeset->getFilename(); | ||||
// Only show the filename. | |||||
$path = basename($path); | |||||
$start = $comment->getLineNumber(); | $start = $comment->getLineNumber(); | ||||
$length = $comment->getLineLength(); | $length = $comment->getLineLength(); | ||||
if ($length) { | if ($length) { | ||||
$range = pht('%s-%s', $start, $start + $length); | $range = pht('%s-%s', $start, $start + $length); | ||||
} else { | } else { | ||||
$range = $start; | $range = $start; | ||||
} | } | ||||
$header = "{$path}:{$range}"; | $header = "{$path}:{$range}"; | ||||
if ($is_html) { | if ($is_html) { | ||||
$header = phutil_tag( | $header = phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'style' => 'color: #000000', | 'style' => 'color: #4b4d51; font-weight: bold;', | ||||
), | ), | ||||
$header); | $header); | ||||
} | } | ||||
if ($with_author) { | if ($with_author) { | ||||
$author = $this->getAuthor($comment->getAuthorPHID()); | $author = $this->getAuthor($comment->getAuthorPHID()); | ||||
} else { | } else { | ||||
$author = null; | $author = null; | ||||
} | } | ||||
if ($author) { | if ($author) { | ||||
$byline = '@'.$author->getName(); | $byline = $author->getName(); | ||||
if ($is_html) { | if ($is_html) { | ||||
$byline = phutil_tag( | $byline = phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'style' => 'color: #000000', | 'style' => 'color: #4b4d51; font-weight: bold;', | ||||
), | ), | ||||
$byline); | $byline); | ||||
} | } | ||||
$header = pht('%s wrote in %s', $byline, $header); | $header = pht('%s wrote in %s', $byline, $header); | ||||
} else { | |||||
$header = pht('In %s', $header); | |||||
} | } | ||||
if ($is_html) { | if ($is_html) { | ||||
$link_href = $this->getInlineURI($comment); | |||||
if ($link_href) { | |||||
$link_style = array( | |||||
'float: right;', | |||||
); | |||||
$link = phutil_tag( | |||||
'a', | |||||
array( | |||||
'style' => implode(' ', $link_style), | |||||
'href' => $link_href, | |||||
), | |||||
pht('View Inline')); | |||||
} else { | |||||
$link = null; | |||||
} | |||||
$style = array( | |||||
'color: #74777d;', | |||||
'background: #eff2f4;', | |||||
'padding: 4px 8px;', | |||||
epriestley: It's also possible we might want slightly more vertical spacing here, or to try the same… | |||||
epriestleyAuthorUnsubmitted Not Done Inline ActionsYeah, I'll tweak the paragraph style a bit. Box margins are also a little off in Mail.app, although most of it doesn't look too bad to me. The link should also probably have text-decoration: none. epriestley: Yeah, I'll tweak the paragraph style a bit. Box margins are also a little off in Mail.app… | |||||
'overflow: hidden;', | |||||
); | |||||
$header = phutil_tag( | $header = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'style' => 'font-style: italic; color: #74777d', | 'style' => implode(' ', $style), | ||||
), | ), | ||||
$header); | array( | ||||
$link, | |||||
$header, | |||||
)); | |||||
} | } | ||||
return $header; | return $header; | ||||
} | } | ||||
private function getInlineURI(DifferentialTransactionComment $comment) { | |||||
$changeset = $this->getChangeset($comment->getChangesetID()); | |||||
if (!$changeset) { | |||||
return null; | |||||
} | |||||
$diff = $changeset->getDiff(); | |||||
if (!$diff) { | |||||
return null; | |||||
} | |||||
$revision = $diff->getRevision(); | |||||
if (!$revision) { | |||||
return null; | |||||
} | |||||
$link_href = '/'.$revision->getMonogram().'#inline-'.$comment->getID(); | |||||
$link_href = PhabricatorEnv::getProductionURI($link_href); | |||||
return $link_href; | |||||
} | |||||
} | } |
It's also possible we might want slightly more vertical spacing here, or to try the same gold/beige color scheme as the web UI.
Also, maybe nuking the margins/padding on paragraphs completely leaves us with too little space between paragraphs in inline text?