From 02877c600a750173c66ff88b67f35bac5befc931 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 6 Jun 2016 13:59:03 -0700 Subject: [PATCH] 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 --- .../controller/PhrictionDiffController.php | 65 ++++--------------- .../differential/changeset-view.css | 8 +++ 2 files changed, 20 insertions(+), 53 deletions(-) diff --git a/src/applications/phriction/controller/PhrictionDiffController.php b/src/applications/phriction/controller/PhrictionDiffController.php index 5b1a81f940..8ae9618bbd 100644 --- a/src/applications/phriction/controller/PhrictionDiffController.php +++ b/src/applications/phriction/controller/PhrictionDiffController.php @@ -45,61 +45,20 @@ final class PhrictionDiffController extends PhrictionController { $text_l = $content_l->getContent(); $text_r = $content_r->getContent(); - $text_l = phutil_utf8_hard_wrap($text_l, 80); - $text_l = implode("\n", $text_l); - $text_r = phutil_utf8_hard_wrap($text_r, 80); - $text_r = implode("\n", $text_r); + $diff_view = id(new PhabricatorApplicationTransactionTextDiffDetailView()) + ->setOldText($text_l) + ->setNewText($text_r); - $engine = new PhabricatorDifferenceEngine(); - $changeset = $engine->generateChangesetFromFileContent($text_l, $text_r); - - $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')) + $changes = id(new PHUIObjectBoxView()) + ->setHeaderText(pht('Content Changes')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setParser($parser); + ->appendChild( + phutil_tag( + 'div', + array( + 'class' => 'prose-diff-frame', + ), + $diff_view)); require_celerity_resource('phriction-document-css'); diff --git a/webroot/rsrc/css/application/differential/changeset-view.css b/webroot/rsrc/css/application/differential/changeset-view.css index 10b5e4962e..e6ee35e9b9 100644 --- a/webroot/rsrc/css/application/differential/changeset-view.css +++ b/webroot/rsrc/css/application/differential/changeset-view.css @@ -93,6 +93,14 @@ user-select: none; } +.prose-diff { + white-space: pre-wrap; +} + +.prose-diff-frame { + padding: 12px; +} + .prose-diff span.old, .prose-diff span.new { padding: 0 2px;