@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.

Make images work in the unified diff view

Summary: Ref T2009. Still a touch glitch-ish but essentially functional now.

Test Plan: Viewed image diffs in 1up and 2up views. Made inline comments on them.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2009

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

+96 -35
+13
src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
··· 575 575 return array($left_prefix, $right_prefix); 576 576 } 577 577 578 + protected function renderImageStage(PhabricatorFile $file) { 579 + return phutil_tag( 580 + 'div', 581 + array( 582 + 'class' => 'differential-image-stage', 583 + ), 584 + phutil_tag( 585 + 'img', 586 + array( 587 + 'src' => $file->getBestURI(), 588 + ))); 589 + } 590 + 578 591 }
+81 -15
src/applications/differential/render/DifferentialChangesetOneUpRenderer.php
··· 30 30 $rows) { 31 31 32 32 $primitives = $this->buildPrimitives($range_start, $range_len); 33 + return $this->renderPrimitives($primitives, $rows); 34 + } 33 35 36 + protected function renderPrimitives(array $primitives, $rows) { 34 37 list($left_prefix, $right_prefix) = $this->getLineIDPrefixes(); 35 38 36 39 $no_copy = phutil_tag('td', array('class' => 'copy')); ··· 44 47 switch ($type) { 45 48 case 'old': 46 49 case 'new': 47 - $out[] = hsprintf('<tr>'); 48 - if ($type == 'old') { 50 + case 'old-file': 51 + case 'new-file': 52 + $is_old = ($type == 'old' || $type == 'old-file'); 53 + 54 + $cells = array(); 55 + if ($is_old) { 49 56 if ($p['htype']) { 50 57 $class = 'left old'; 51 58 } else { 52 59 $class = 'left'; 53 60 } 54 61 62 + if ($type == 'old-file') { 63 + $class = "{$class} differential-old-image"; 64 + } 65 + 55 66 if ($left_prefix) { 56 67 $left_id = $left_prefix.$p['line']; 57 68 } else { 58 69 $left_id = null; 59 70 } 60 - $out[] = phutil_tag('th', array('id' => $left_id), $p['line']); 71 + $cells[] = phutil_tag('th', array('id' => $left_id), $p['line']); 61 72 62 - $out[] = phutil_tag('th', array()); 63 - $out[] = $no_copy; 64 - $out[] = phutil_tag('td', array('class' => $class), $p['render']); 65 - $out[] = $no_coverage; 73 + $cells[] = phutil_tag('th', array()); 74 + $cells[] = $no_copy; 75 + $cells[] = phutil_tag('td', array('class' => $class), $p['render']); 76 + $cells[] = $no_coverage; 66 77 } else { 67 78 if ($p['htype']) { 68 79 $class = 'right new'; 69 - $out[] = phutil_tag('th', array()); 80 + $cells[] = phutil_tag('th', array()); 70 81 } else { 71 82 $class = 'right'; 72 83 if ($left_prefix) { ··· 74 85 } else { 75 86 $left_id = null; 76 87 } 77 - $out[] = phutil_tag('th', array('id' => $left_id), $p['oline']); 88 + $cells[] = phutil_tag('th', array('id' => $left_id), $p['oline']); 89 + } 90 + 91 + if ($type == 'new-file') { 92 + $class = "{$class} differential-new-image"; 78 93 } 79 94 80 95 if ($right_prefix) { ··· 82 97 } else { 83 98 $right_id = null; 84 99 } 85 - $out[] = phutil_tag('th', array('id' => $right_id), $p['line']); 100 + $cells[] = phutil_tag('th', array('id' => $right_id), $p['line']); 86 101 87 102 88 - $out[] = $no_copy; 89 - $out[] = phutil_tag('td', array('class' => $class), $p['render']); 90 - $out[] = $no_coverage; 103 + $cells[] = $no_copy; 104 + $cells[] = phutil_tag('td', array('class' => $class), $p['render']); 105 + $cells[] = $no_coverage; 91 106 } 92 - $out[] = hsprintf('</tr>'); 107 + 108 + $out[] = phutil_tag('tr', array(), $cells); 109 + 93 110 break; 94 111 case 'inline': 95 112 $inline = $this->buildInlineComment( ··· 137 154 if ($out) { 138 155 return $this->wrapChangeInTable(phutil_implode_html('', $out)); 139 156 } 157 + 140 158 return null; 141 159 } 142 160 ··· 146 164 $id = 0, 147 165 $vs = 0) { 148 166 149 - throw new PhutilMethodNotImplementedException(); 167 + // TODO: This should eventually merge into the normal primitives pathway, 168 + // but fake it for now and just share as much code as possible. 169 + 170 + $primitives = array(); 171 + if ($old_file) { 172 + $primitives[] = array( 173 + 'type' => 'old-file', 174 + 'htype' => ($new_file ? 'new-file' : null), 175 + 'file' => $old_file, 176 + 'line' => 1, 177 + 'render' => $this->renderImageStage($old_file), 178 + ); 179 + } 180 + 181 + if ($new_file) { 182 + $primitives[] = array( 183 + 'type' => 'new-file', 184 + 'htype' => ($old_file ? 'old-file' : null), 185 + 'file' => $new_file, 186 + 'line' => 1, 187 + 'oline' => ($old_file ? 1 : null), 188 + 'render' => $this->renderImageStage($old_file), 189 + ); 190 + } 191 + 192 + // TODO: We'd like to share primitive code here, but buildPrimitives() 193 + // currently chokes on changesets with no textual data. 194 + foreach ($this->getOldComments() as $line => $group) { 195 + foreach ($group as $comment) { 196 + $primitives[] = array( 197 + 'type' => 'inline', 198 + 'comment' => $comment, 199 + 'right' => false, 200 + ); 201 + } 202 + } 203 + 204 + foreach ($this->getNewComments() as $line => $group) { 205 + foreach ($group as $comment) { 206 + $primitives[] = array( 207 + 'type' => 'inline', 208 + 'comment' => $comment, 209 + 'right' => true, 210 + ); 211 + } 212 + } 213 + 214 + $output = $this->renderPrimitives($primitives, 1); 215 + return $this->renderChangesetTable($output); 150 216 } 151 217 152 218 public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) {
+2 -20
src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
··· 304 304 $vs = 0) { 305 305 $old = null; 306 306 if ($old_file) { 307 - $old = phutil_tag( 308 - 'div', 309 - array( 310 - 'class' => 'differential-image-stage', 311 - ), 312 - phutil_tag( 313 - 'img', 314 - array( 315 - 'src' => $old_file->getBestURI(), 316 - ))); 307 + $old = $this->renderImageStage($old_file); 317 308 } 318 309 319 310 $new = null; 320 311 if ($new_file) { 321 - $new = phutil_tag( 322 - 'div', 323 - array( 324 - 'class' => 'differential-image-stage', 325 - ), 326 - phutil_tag( 327 - 'img', 328 - array( 329 - 'src' => $new_file->getBestURI(), 330 - ))); 312 + $new = $this->renderImageStage($new_file); 331 313 } 332 314 333 315 $html_old = array();