Implement basic one-up and test renderers
Summary:
This is a half-step toward one-up and test renderers. This is mostly a structural change, and has no user-facing impact. It splits the rendering hierarchy like this:
- Renderer (more methods are abstract than before)
- HTML Renderer (most HTML stuff has moved down from the base to here)
- HTML 1-up (placeholder only -- not yet a functional implementation)
- HTML 2-up (minimal changes, uses mostly old code)
- Test Renderer (unit-testable renderer base, implements text versions of the HTML stuff)
- Test 1-up (selects 1-up mode for test rendering)
- Test 2-up (selects 2-up mode for test rendering)
Broadly, I'm trying to share as much code as possible by splitting rendering into more, smaller stages. Specifically, we do this:
- Combine the various sorts of inputs (changes, context, inlines, etc.) into a single, relatively homogenous list of "primitives". This happens in the base class.
- The primitive types are: old (diff left side), new (diff right side), context ("show more context"), no-context ("context not available") and inline (inline comment).
- Possibly, apply a filtering/reordering step to the primitives to get them ready for 1-up rendering. This mostly removes information, and does a small amount of reordering. This also happens in the base class.
- Pass the primitives to the actual renderer, to convert them into HTML, text, or whatever else. This happens in the leaf class.
The primitive implementation is not yet complete (it doesn't attach as much information to the primitives as it should -- stuff like coverage and copies), but covers the basics.
The existing HTMLTwoUp renderer does not use the primitive path; instead, it still goes down the old path.
Test Plan: Ran unit tests, looked at a bunch of diffs.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D4421
2013-01-14 23:20:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialChangesetOneUpRenderer
|
|
|
|
extends DifferentialChangesetHTMLRenderer {
|
|
|
|
|
|
|
|
public function isOneUpRenderer() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-15 01:58:24 +01:00
|
|
|
protected function renderColgroup() {
|
|
|
|
return phutil_tag('colgroup', array(), array(
|
|
|
|
phutil_tag('col', array('class' => 'num')),
|
|
|
|
phutil_tag('col', array('class' => 'num')),
|
|
|
|
phutil_tag('col', array('class' => 'unified')),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
Implement basic one-up and test renderers
Summary:
This is a half-step toward one-up and test renderers. This is mostly a structural change, and has no user-facing impact. It splits the rendering hierarchy like this:
- Renderer (more methods are abstract than before)
- HTML Renderer (most HTML stuff has moved down from the base to here)
- HTML 1-up (placeholder only -- not yet a functional implementation)
- HTML 2-up (minimal changes, uses mostly old code)
- Test Renderer (unit-testable renderer base, implements text versions of the HTML stuff)
- Test 1-up (selects 1-up mode for test rendering)
- Test 2-up (selects 2-up mode for test rendering)
Broadly, I'm trying to share as much code as possible by splitting rendering into more, smaller stages. Specifically, we do this:
- Combine the various sorts of inputs (changes, context, inlines, etc.) into a single, relatively homogenous list of "primitives". This happens in the base class.
- The primitive types are: old (diff left side), new (diff right side), context ("show more context"), no-context ("context not available") and inline (inline comment).
- Possibly, apply a filtering/reordering step to the primitives to get them ready for 1-up rendering. This mostly removes information, and does a small amount of reordering. This also happens in the base class.
- Pass the primitives to the actual renderer, to convert them into HTML, text, or whatever else. This happens in the leaf class.
The primitive implementation is not yet complete (it doesn't attach as much information to the primitives as it should -- stuff like coverage and copies), but covers the basics.
The existing HTMLTwoUp renderer does not use the primitive path; instead, it still goes down the old path.
Test Plan: Ran unit tests, looked at a bunch of diffs.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D4421
2013-01-14 23:20:06 +01:00
|
|
|
public function renderTextChange(
|
|
|
|
$range_start,
|
|
|
|
$range_len,
|
|
|
|
$rows) {
|
2013-01-14 23:20:35 +01:00
|
|
|
|
|
|
|
$primitives = $this->buildPrimitives($range_start, $range_len);
|
|
|
|
|
|
|
|
$out = array();
|
|
|
|
foreach ($primitives as $p) {
|
|
|
|
$type = $p['type'];
|
|
|
|
switch ($type) {
|
|
|
|
case 'old':
|
|
|
|
case 'new':
|
2013-02-13 23:50:15 +01:00
|
|
|
$out[] = hsprintf('<tr>');
|
2013-01-14 23:20:35 +01:00
|
|
|
if ($type == 'old') {
|
|
|
|
if ($p['htype']) {
|
|
|
|
$class = 'left old';
|
|
|
|
} else {
|
|
|
|
$class = 'left';
|
|
|
|
}
|
2013-11-11 18:23:23 +01:00
|
|
|
$out[] = phutil_tag('th', array(), $p['line']);
|
|
|
|
$out[] = phutil_tag('th', array());
|
|
|
|
$out[] = phutil_tag('td', array('class' => $class), $p['render']);
|
2013-01-14 23:20:35 +01:00
|
|
|
} else if ($type == 'new') {
|
|
|
|
if ($p['htype']) {
|
|
|
|
$class = 'right new';
|
2013-11-11 18:23:23 +01:00
|
|
|
$out[] = phutil_tag('th', array());
|
2013-01-14 23:20:35 +01:00
|
|
|
} else {
|
|
|
|
$class = 'right';
|
2013-11-11 18:23:23 +01:00
|
|
|
$out[] = phutil_tag('th', array(), $p['oline']);
|
2013-01-14 23:20:35 +01:00
|
|
|
}
|
2013-11-11 18:23:23 +01:00
|
|
|
$out[] = phutil_tag('th', array(), $p['line']);
|
|
|
|
$out[] = phutil_tag('td', array('class' => $class), $p['render']);
|
2013-01-14 23:20:35 +01:00
|
|
|
}
|
2013-02-13 23:50:15 +01:00
|
|
|
$out[] = hsprintf('</tr>');
|
2013-01-14 23:20:35 +01:00
|
|
|
break;
|
|
|
|
case 'inline':
|
2013-02-13 23:50:15 +01:00
|
|
|
$out[] = hsprintf('<tr><th /><th />');
|
|
|
|
$out[] = hsprintf('<td>');
|
2013-01-14 23:20:35 +01:00
|
|
|
|
2013-01-14 23:20:54 +01:00
|
|
|
$inline = $this->buildInlineComment(
|
|
|
|
$p['comment'],
|
|
|
|
$p['right']);
|
|
|
|
$inline->setBuildScaffolding(false);
|
|
|
|
$out[] = $inline->render();
|
2013-01-14 23:20:35 +01:00
|
|
|
|
2013-02-13 23:50:15 +01:00
|
|
|
$out[] = hsprintf('</td></tr>');
|
2013-01-14 23:20:35 +01:00
|
|
|
break;
|
|
|
|
default:
|
2013-02-13 23:50:15 +01:00
|
|
|
$out[] = hsprintf('<tr><th /><th /><td>%s</td></tr>', $type);
|
2013-01-14 23:20:35 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($out) {
|
2013-02-13 23:50:15 +01:00
|
|
|
return $this->wrapChangeInTable(phutil_implode_html('', $out));
|
2013-01-14 23:20:35 +01:00
|
|
|
}
|
|
|
|
return null;
|
Implement basic one-up and test renderers
Summary:
This is a half-step toward one-up and test renderers. This is mostly a structural change, and has no user-facing impact. It splits the rendering hierarchy like this:
- Renderer (more methods are abstract than before)
- HTML Renderer (most HTML stuff has moved down from the base to here)
- HTML 1-up (placeholder only -- not yet a functional implementation)
- HTML 2-up (minimal changes, uses mostly old code)
- Test Renderer (unit-testable renderer base, implements text versions of the HTML stuff)
- Test 1-up (selects 1-up mode for test rendering)
- Test 2-up (selects 2-up mode for test rendering)
Broadly, I'm trying to share as much code as possible by splitting rendering into more, smaller stages. Specifically, we do this:
- Combine the various sorts of inputs (changes, context, inlines, etc.) into a single, relatively homogenous list of "primitives". This happens in the base class.
- The primitive types are: old (diff left side), new (diff right side), context ("show more context"), no-context ("context not available") and inline (inline comment).
- Possibly, apply a filtering/reordering step to the primitives to get them ready for 1-up rendering. This mostly removes information, and does a small amount of reordering. This also happens in the base class.
- Pass the primitives to the actual renderer, to convert them into HTML, text, or whatever else. This happens in the leaf class.
The primitive implementation is not yet complete (it doesn't attach as much information to the primitives as it should -- stuff like coverage and copies), but covers the basics.
The existing HTMLTwoUp renderer does not use the primitive path; instead, it still goes down the old path.
Test Plan: Ran unit tests, looked at a bunch of diffs.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D4421
2013-01-14 23:20:06 +01:00
|
|
|
}
|
|
|
|
|
2014-07-21 17:47:00 +02:00
|
|
|
public function renderFileChange(
|
|
|
|
$old_file = null,
|
|
|
|
$new_file = null,
|
|
|
|
$id = 0,
|
|
|
|
$vs = 0) {
|
|
|
|
|
|
|
|
throw new PhutilMethodNotImplementedException();
|
Implement basic one-up and test renderers
Summary:
This is a half-step toward one-up and test renderers. This is mostly a structural change, and has no user-facing impact. It splits the rendering hierarchy like this:
- Renderer (more methods are abstract than before)
- HTML Renderer (most HTML stuff has moved down from the base to here)
- HTML 1-up (placeholder only -- not yet a functional implementation)
- HTML 2-up (minimal changes, uses mostly old code)
- Test Renderer (unit-testable renderer base, implements text versions of the HTML stuff)
- Test 1-up (selects 1-up mode for test rendering)
- Test 2-up (selects 2-up mode for test rendering)
Broadly, I'm trying to share as much code as possible by splitting rendering into more, smaller stages. Specifically, we do this:
- Combine the various sorts of inputs (changes, context, inlines, etc.) into a single, relatively homogenous list of "primitives". This happens in the base class.
- The primitive types are: old (diff left side), new (diff right side), context ("show more context"), no-context ("context not available") and inline (inline comment).
- Possibly, apply a filtering/reordering step to the primitives to get them ready for 1-up rendering. This mostly removes information, and does a small amount of reordering. This also happens in the base class.
- Pass the primitives to the actual renderer, to convert them into HTML, text, or whatever else. This happens in the leaf class.
The primitive implementation is not yet complete (it doesn't attach as much information to the primitives as it should -- stuff like coverage and copies), but covers the basics.
The existing HTMLTwoUp renderer does not use the primitive path; instead, it still goes down the old path.
Test Plan: Ran unit tests, looked at a bunch of diffs.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D4421
2013-01-14 23:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|