mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 00:02:41 +01:00
bd9bcaa8ff
Summary: Fixes T9790. This uses a simple renderer, like the inline context renderer, that emphasizes getting a quick glance at small changes and working reasonably on mobile devices. Test Plan: - Set `inline` setting to `9999`. - Created a diff. - Saw it render reasonably in HTML mail. - Also tested text mail to make sure I didn't break that. {F1310137, size=full} Reviewers: chad Reviewed By: chad Maniphest Tasks: T9790 Differential Revision: https://secure.phabricator.com/D15901
77 lines
1.6 KiB
PHP
77 lines
1.6 KiB
PHP
<?php
|
|
|
|
final class DifferentialChangeDetailMailView
|
|
extends DifferentialMailView {
|
|
|
|
private $viewer;
|
|
private $diff;
|
|
private $patch;
|
|
|
|
public function setViewer(PhabricatorUser $viewer) {
|
|
$this->viewer = $viewer;
|
|
return $this;
|
|
}
|
|
|
|
public function getViewer() {
|
|
return $this->viewer;
|
|
}
|
|
|
|
public function setDiff(DifferentialDiff $diff) {
|
|
$this->diff = $diff;
|
|
return $this;
|
|
}
|
|
|
|
public function getDiff() {
|
|
return $this->diff;
|
|
}
|
|
|
|
public function setPatch($patch) {
|
|
$this->patch = $patch;
|
|
return $this;
|
|
}
|
|
|
|
public function getPatch() {
|
|
return $this->patch;
|
|
}
|
|
|
|
public function buildMailSection() {
|
|
$viewer = $this->getViewer();
|
|
|
|
$diff = $this->getDiff();
|
|
|
|
$engine = new PhabricatorMarkupEngine();
|
|
|
|
$out = array();
|
|
foreach ($diff->getChangesets() as $changeset) {
|
|
$parser = id(new DifferentialChangesetParser())
|
|
->setUser($viewer)
|
|
->setChangeset($changeset)
|
|
->setLinesOfContext(2)
|
|
->setMarkupEngine($engine);
|
|
|
|
$parser->setRenderer(new DifferentialChangesetOneUpMailRenderer());
|
|
$block = $parser->render();
|
|
|
|
$filename = $changeset->getFilename();
|
|
$filename = $this->renderHeaderBold($filename);
|
|
$header = $this->renderHeaderBlock($filename);
|
|
|
|
$out[] = $this->renderContentBox(
|
|
array(
|
|
$header,
|
|
$this->renderCodeBlock($block),
|
|
));
|
|
}
|
|
|
|
$out = phutil_implode_html(phutil_tag('br'), $out);
|
|
|
|
$patch_html = $out;
|
|
|
|
$patch_text = $this->getPatch();
|
|
|
|
return id(new PhabricatorMetaMTAMailSection())
|
|
->addPlaintextFragment($patch_text)
|
|
->addHTMLFragment($patch_html);
|
|
}
|
|
|
|
}
|