mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-13 00:01:03 +01:00
Use prose diffs in Phriction
Summary: Ref T3353. This improves whitespace display of prose diffs and uses them in Phriction. Test Plan: {F1677957} Reviewers: chad, avivey Reviewed By: avivey Subscribers: avivey Maniphest Tasks: T3353 Differential Revision: https://secure.phabricator.com/D16062
This commit is contained in:
parent
e1a9473eda
commit
02877c600a
2 changed files with 20 additions and 53 deletions
|
@ -45,61 +45,20 @@ final class PhrictionDiffController extends PhrictionController {
|
||||||
$text_l = $content_l->getContent();
|
$text_l = $content_l->getContent();
|
||||||
$text_r = $content_r->getContent();
|
$text_r = $content_r->getContent();
|
||||||
|
|
||||||
$text_l = phutil_utf8_hard_wrap($text_l, 80);
|
$diff_view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
||||||
$text_l = implode("\n", $text_l);
|
->setOldText($text_l)
|
||||||
$text_r = phutil_utf8_hard_wrap($text_r, 80);
|
->setNewText($text_r);
|
||||||
$text_r = implode("\n", $text_r);
|
|
||||||
|
|
||||||
$engine = new PhabricatorDifferenceEngine();
|
$changes = id(new PHUIObjectBoxView())
|
||||||
$changeset = $engine->generateChangesetFromFileContent($text_l, $text_r);
|
->setHeaderText(pht('Content Changes'))
|
||||||
|
|
||||||
$changeset->setFilename($content_r->getTitle());
|
|
||||||
|
|
||||||
$changeset->setOldProperties(
|
|
||||||
array(
|
|
||||||
'Title' => $content_l->getTitle(),
|
|
||||||
));
|
|
||||||
$changeset->setNewProperties(
|
|
||||||
array(
|
|
||||||
'Title' => $content_r->getTitle(),
|
|
||||||
));
|
|
||||||
|
|
||||||
$whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
|
|
||||||
|
|
||||||
$parser = id(new DifferentialChangesetParser())
|
|
||||||
->setUser($viewer)
|
|
||||||
->setChangeset($changeset)
|
|
||||||
->setRenderingReference("{$l},{$r}");
|
|
||||||
|
|
||||||
$parser->readParametersFromRequest($request);
|
|
||||||
$parser->setWhitespaceMode($whitespace_mode);
|
|
||||||
|
|
||||||
$engine = new PhabricatorMarkupEngine();
|
|
||||||
$engine->setViewer($viewer);
|
|
||||||
$engine->process();
|
|
||||||
$parser->setMarkupEngine($engine);
|
|
||||||
|
|
||||||
$spec = $request->getStr('range');
|
|
||||||
list($range_s, $range_e, $mask) =
|
|
||||||
DifferentialChangesetParser::parseRangeSpecification($spec);
|
|
||||||
|
|
||||||
$parser->setRange($range_s, $range_e);
|
|
||||||
$parser->setMask($mask);
|
|
||||||
|
|
||||||
if ($request->isAjax()) {
|
|
||||||
return id(new PhabricatorChangesetResponse())
|
|
||||||
->setRenderedChangeset($parser->renderChangeset());
|
|
||||||
}
|
|
||||||
|
|
||||||
$changes = id(new DifferentialChangesetListView())
|
|
||||||
->setUser($this->getViewer())
|
|
||||||
->setChangesets(array($changeset))
|
|
||||||
->setVisibleChangesets(array($changeset))
|
|
||||||
->setRenderingReferences(array("{$l},{$r}"))
|
|
||||||
->setRenderURI('/phriction/diff/'.$document->getID().'/')
|
|
||||||
->setTitle(pht('Changes'))
|
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
->setParser($parser);
|
->appendChild(
|
||||||
|
phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'prose-diff-frame',
|
||||||
|
),
|
||||||
|
$diff_view));
|
||||||
|
|
||||||
require_celerity_resource('phriction-document-css');
|
require_celerity_resource('phriction-document-css');
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,14 @@
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.prose-diff {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose-diff-frame {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.prose-diff span.old,
|
.prose-diff span.old,
|
||||||
.prose-diff span.new {
|
.prose-diff span.new {
|
||||||
padding: 0 2px;
|
padding: 0 2px;
|
||||||
|
|
Loading…
Reference in a new issue