@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Render sometimes-legible prose diffs in the Phabricator UI

Summary:
Ref T3353. This hooks the prose engine up to the UI and throws away the hard-wrapping hacks.

These are likely still very rough in many cases, but are hopefully a big step forward from the old version in the vast majority of cases.

Test Plan: {F1677809}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T3353

Differential Revision: https://secure.phabricator.com/D16056

+61 -40
+6 -6
resources/celerity/map.php
··· 10 10 'core.pkg.css' => '8aeacc63', 11 11 'core.pkg.js' => '3f15fa62', 12 12 'darkconsole.pkg.js' => 'e7393ebb', 13 - 'differential.pkg.css' => 'a3a7e5df', 13 + 'differential.pkg.css' => 'f5569f20', 14 14 'differential.pkg.js' => '4b7d8f19', 15 15 'diffusion.pkg.css' => '91c5d3a6', 16 16 'diffusion.pkg.js' => '3a9a8bfa', ··· 57 57 'rsrc/css/application/dashboard/dashboard.css' => 'bc6f2127', 58 58 'rsrc/css/application/diff/inline-comment-summary.css' => '51efda3a', 59 59 'rsrc/css/application/differential/add-comment.css' => 'c47f8c40', 60 - 'rsrc/css/application/differential/changeset-view.css' => 'febd2372', 60 + 'rsrc/css/application/differential/changeset-view.css' => '3f49a4bd', 61 61 'rsrc/css/application/differential/core.css' => '5b7b8ff4', 62 62 'rsrc/css/application/differential/phui-inline-comment.css' => '5953c28e', 63 63 'rsrc/css/application/differential/revision-comment.css' => '14b8565a', ··· 552 552 'conpherence-update-css' => 'faf6be09', 553 553 'conpherence-widget-pane-css' => '775eaaba', 554 554 'd3' => 'a11a5ff2', 555 - 'differential-changeset-view-css' => 'febd2372', 555 + 'differential-changeset-view-css' => '3f49a4bd', 556 556 'differential-core-view-css' => '5b7b8ff4', 557 557 'differential-inline-comment-editor' => '64a5550f', 558 558 'differential-revision-add-comment-css' => 'c47f8c40', ··· 1157 1157 'javelin-util', 1158 1158 'javelin-uri', 1159 1159 ), 1160 + '3f49a4bd' => array( 1161 + 'phui-inline-comment-view-css', 1162 + ), 1160 1163 '3f5d6dbf' => array( 1161 1164 'javelin-behavior', 1162 1165 'javelin-dom', ··· 2199 2202 ), 2200 2203 'fea0eb47' => array( 2201 2204 'javelin-install', 2202 - ), 2203 - 'febd2372' => array( 2204 - 'phui-inline-comment-view-css', 2205 2205 ), 2206 2206 ), 2207 2207 'packages' => array(
+1 -2
src/applications/transactions/controller/PhabricatorApplicationTransactionDetailController.php
··· 24 24 25 25 return $this->newDialog() 26 26 ->setTitle(pht('Change Details')) 27 - ->setWidth(AphrontDialogView::WIDTH_FULL) 28 - ->setFlush(true) 27 + ->setWidth(AphrontDialogView::WIDTH_FORM) 29 28 ->appendChild($details) 30 29 ->addCancelButton($cancel_uri); 31 30 }
+37 -30
src/applications/transactions/view/PhabricatorApplicationTransactionTextDiffDetailView.php
··· 17 17 } 18 18 19 19 public function render() { 20 - $old = $this->oldText; 21 - $new = $this->newText; 20 + $diff = $this->buildDiff(); 22 21 23 - // TODO: On mobile, or perhaps by default, we should switch to 1-up once 24 - // that is built. 22 + require_celerity_resource('differential-changeset-view-css'); 25 23 26 - if (strlen($old)) { 27 - $old = phutil_utf8_hard_wrap($old, 80); 28 - $old = implode("\n", $old)."\n"; 24 + $result = array(); 25 + foreach ($diff->getParts() as $part) { 26 + $type = $part['type']; 27 + $text = $part['text']; 28 + switch ($type) { 29 + case '-': 30 + $result[] = phutil_tag( 31 + 'span', 32 + array( 33 + 'class' => 'old', 34 + ), 35 + $text); 36 + break; 37 + case '+': 38 + $result[] = phutil_tag( 39 + 'span', 40 + array( 41 + 'class' => 'new', 42 + ), 43 + $text); 44 + break; 45 + case '=': 46 + $result[] = $text; 47 + break; 48 + } 29 49 } 30 50 31 - if (strlen($new)) { 32 - $new = phutil_utf8_hard_wrap($new, 80); 33 - $new = implode("\n", $new)."\n"; 34 - } 51 + return phutil_tag( 52 + 'div', 53 + array( 54 + 'class' => 'prose-diff', 55 + ), 56 + $result); 57 + } 35 58 36 - try { 37 - $engine = new PhabricatorDifferenceEngine(); 38 - $changeset = $engine->generateChangesetFromFileContent($old, $new); 39 - 40 - $whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL; 41 - 42 - $markup_engine = new PhabricatorMarkupEngine(); 43 - $markup_engine->setViewer($this->getUser()); 44 - 45 - $parser = new DifferentialChangesetParser(); 46 - $parser->setUser($this->getUser()); 47 - $parser->setChangeset($changeset); 48 - $parser->setMarkupEngine($markup_engine); 49 - $parser->setWhitespaceMode($whitespace_mode); 50 - 51 - return $parser->render(0, PHP_INT_MAX, array()); 52 - } catch (Exception $ex) { 53 - return $ex->getMessage(); 54 - } 59 + private function buildDiff() { 60 + $engine = new PhutilProseDifferenceEngine(); 61 + return $engine->getDiff($this->oldText, $this->newText); 55 62 } 56 63 57 64 }
+17 -2
webroot/rsrc/css/application/differential/changeset-view.css
··· 93 93 user-select: none; 94 94 } 95 95 96 + .prose-diff span.old, 97 + .prose-diff span.new { 98 + padding: 0 2px; 99 + } 100 + 101 + .prose-diff span.old { 102 + color: {$redtext}; 103 + } 104 + 105 + .prose-diff span.new { 106 + color: {$greentext}; 107 + } 108 + 96 109 .differential-diff th.selected { 97 110 background-color: {$sh-yellowbackground}; 98 111 } ··· 118 131 } 119 132 120 133 .differential-diff td.old-full, 121 - .differential-diff td.old span.bright { 134 + .differential-diff td.old span.bright, 135 + .prose-diff span.old { 122 136 background: rgba(251, 175, 175, .7); 123 137 } 124 138 125 139 .differential-diff td.new-full, 126 - .differential-diff td.new span.bright { 140 + .differential-diff td.new span.bright, 141 + .prose-diff span.new { 127 142 background: rgba(151, 234, 151, .6); 128 143 } 129 144