mirror of
https://we.phorge.it/source/phorge.git
synced 2025-04-09 10:58:34 +02:00
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
This commit is contained in:
parent
f9cb366f00
commit
68fa70eacb
3 changed files with 96 additions and 35 deletions
|
@ -575,4 +575,17 @@ abstract class DifferentialChangesetHTMLRenderer
|
||||||
return array($left_prefix, $right_prefix);
|
return array($left_prefix, $right_prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function renderImageStage(PhabricatorFile $file) {
|
||||||
|
return phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'differential-image-stage',
|
||||||
|
),
|
||||||
|
phutil_tag(
|
||||||
|
'img',
|
||||||
|
array(
|
||||||
|
'src' => $file->getBestURI(),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,10 @@ final class DifferentialChangesetOneUpRenderer
|
||||||
$rows) {
|
$rows) {
|
||||||
|
|
||||||
$primitives = $this->buildPrimitives($range_start, $range_len);
|
$primitives = $this->buildPrimitives($range_start, $range_len);
|
||||||
|
return $this->renderPrimitives($primitives, $rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderPrimitives(array $primitives, $rows) {
|
||||||
list($left_prefix, $right_prefix) = $this->getLineIDPrefixes();
|
list($left_prefix, $right_prefix) = $this->getLineIDPrefixes();
|
||||||
|
|
||||||
$no_copy = phutil_tag('td', array('class' => 'copy'));
|
$no_copy = phutil_tag('td', array('class' => 'copy'));
|
||||||
|
@ -44,29 +47,37 @@ final class DifferentialChangesetOneUpRenderer
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'old':
|
case 'old':
|
||||||
case 'new':
|
case 'new':
|
||||||
$out[] = hsprintf('<tr>');
|
case 'old-file':
|
||||||
if ($type == 'old') {
|
case 'new-file':
|
||||||
|
$is_old = ($type == 'old' || $type == 'old-file');
|
||||||
|
|
||||||
|
$cells = array();
|
||||||
|
if ($is_old) {
|
||||||
if ($p['htype']) {
|
if ($p['htype']) {
|
||||||
$class = 'left old';
|
$class = 'left old';
|
||||||
} else {
|
} else {
|
||||||
$class = 'left';
|
$class = 'left';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($type == 'old-file') {
|
||||||
|
$class = "{$class} differential-old-image";
|
||||||
|
}
|
||||||
|
|
||||||
if ($left_prefix) {
|
if ($left_prefix) {
|
||||||
$left_id = $left_prefix.$p['line'];
|
$left_id = $left_prefix.$p['line'];
|
||||||
} else {
|
} else {
|
||||||
$left_id = null;
|
$left_id = null;
|
||||||
}
|
}
|
||||||
$out[] = phutil_tag('th', array('id' => $left_id), $p['line']);
|
$cells[] = phutil_tag('th', array('id' => $left_id), $p['line']);
|
||||||
|
|
||||||
$out[] = phutil_tag('th', array());
|
$cells[] = phutil_tag('th', array());
|
||||||
$out[] = $no_copy;
|
$cells[] = $no_copy;
|
||||||
$out[] = phutil_tag('td', array('class' => $class), $p['render']);
|
$cells[] = phutil_tag('td', array('class' => $class), $p['render']);
|
||||||
$out[] = $no_coverage;
|
$cells[] = $no_coverage;
|
||||||
} else {
|
} else {
|
||||||
if ($p['htype']) {
|
if ($p['htype']) {
|
||||||
$class = 'right new';
|
$class = 'right new';
|
||||||
$out[] = phutil_tag('th', array());
|
$cells[] = phutil_tag('th', array());
|
||||||
} else {
|
} else {
|
||||||
$class = 'right';
|
$class = 'right';
|
||||||
if ($left_prefix) {
|
if ($left_prefix) {
|
||||||
|
@ -74,7 +85,11 @@ final class DifferentialChangesetOneUpRenderer
|
||||||
} else {
|
} else {
|
||||||
$left_id = null;
|
$left_id = null;
|
||||||
}
|
}
|
||||||
$out[] = phutil_tag('th', array('id' => $left_id), $p['oline']);
|
$cells[] = phutil_tag('th', array('id' => $left_id), $p['oline']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type == 'new-file') {
|
||||||
|
$class = "{$class} differential-new-image";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($right_prefix) {
|
if ($right_prefix) {
|
||||||
|
@ -82,14 +97,16 @@ final class DifferentialChangesetOneUpRenderer
|
||||||
} else {
|
} else {
|
||||||
$right_id = null;
|
$right_id = null;
|
||||||
}
|
}
|
||||||
$out[] = phutil_tag('th', array('id' => $right_id), $p['line']);
|
$cells[] = phutil_tag('th', array('id' => $right_id), $p['line']);
|
||||||
|
|
||||||
|
|
||||||
$out[] = $no_copy;
|
$cells[] = $no_copy;
|
||||||
$out[] = phutil_tag('td', array('class' => $class), $p['render']);
|
$cells[] = phutil_tag('td', array('class' => $class), $p['render']);
|
||||||
$out[] = $no_coverage;
|
$cells[] = $no_coverage;
|
||||||
}
|
}
|
||||||
$out[] = hsprintf('</tr>');
|
|
||||||
|
$out[] = phutil_tag('tr', array(), $cells);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'inline':
|
case 'inline':
|
||||||
$inline = $this->buildInlineComment(
|
$inline = $this->buildInlineComment(
|
||||||
|
@ -137,6 +154,7 @@ final class DifferentialChangesetOneUpRenderer
|
||||||
if ($out) {
|
if ($out) {
|
||||||
return $this->wrapChangeInTable(phutil_implode_html('', $out));
|
return $this->wrapChangeInTable(phutil_implode_html('', $out));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +164,55 @@ final class DifferentialChangesetOneUpRenderer
|
||||||
$id = 0,
|
$id = 0,
|
||||||
$vs = 0) {
|
$vs = 0) {
|
||||||
|
|
||||||
throw new PhutilMethodNotImplementedException();
|
// TODO: This should eventually merge into the normal primitives pathway,
|
||||||
|
// but fake it for now and just share as much code as possible.
|
||||||
|
|
||||||
|
$primitives = array();
|
||||||
|
if ($old_file) {
|
||||||
|
$primitives[] = array(
|
||||||
|
'type' => 'old-file',
|
||||||
|
'htype' => ($new_file ? 'new-file' : null),
|
||||||
|
'file' => $old_file,
|
||||||
|
'line' => 1,
|
||||||
|
'render' => $this->renderImageStage($old_file),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($new_file) {
|
||||||
|
$primitives[] = array(
|
||||||
|
'type' => 'new-file',
|
||||||
|
'htype' => ($old_file ? 'old-file' : null),
|
||||||
|
'file' => $new_file,
|
||||||
|
'line' => 1,
|
||||||
|
'oline' => ($old_file ? 1 : null),
|
||||||
|
'render' => $this->renderImageStage($old_file),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: We'd like to share primitive code here, but buildPrimitives()
|
||||||
|
// currently chokes on changesets with no textual data.
|
||||||
|
foreach ($this->getOldComments() as $line => $group) {
|
||||||
|
foreach ($group as $comment) {
|
||||||
|
$primitives[] = array(
|
||||||
|
'type' => 'inline',
|
||||||
|
'comment' => $comment,
|
||||||
|
'right' => false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->getNewComments() as $line => $group) {
|
||||||
|
foreach ($group as $comment) {
|
||||||
|
$primitives[] = array(
|
||||||
|
'type' => 'inline',
|
||||||
|
'comment' => $comment,
|
||||||
|
'right' => true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = $this->renderPrimitives($primitives, 1);
|
||||||
|
return $this->renderChangesetTable($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) {
|
public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) {
|
||||||
|
|
|
@ -304,30 +304,12 @@ final class DifferentialChangesetTwoUpRenderer
|
||||||
$vs = 0) {
|
$vs = 0) {
|
||||||
$old = null;
|
$old = null;
|
||||||
if ($old_file) {
|
if ($old_file) {
|
||||||
$old = phutil_tag(
|
$old = $this->renderImageStage($old_file);
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'differential-image-stage',
|
|
||||||
),
|
|
||||||
phutil_tag(
|
|
||||||
'img',
|
|
||||||
array(
|
|
||||||
'src' => $old_file->getBestURI(),
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$new = null;
|
$new = null;
|
||||||
if ($new_file) {
|
if ($new_file) {
|
||||||
$new = phutil_tag(
|
$new = $this->renderImageStage($new_file);
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'differential-image-stage',
|
|
||||||
),
|
|
||||||
phutil_tag(
|
|
||||||
'img',
|
|
||||||
array(
|
|
||||||
'src' => $new_file->getBestURI(),
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$html_old = array();
|
$html_old = array();
|
||||||
|
|
Loading…
Add table
Reference in a new issue