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;
|
|
|
|
}
|
|
|
|
|
2015-03-05 23:01:52 +01:00
|
|
|
protected function getRendererTableClass() {
|
|
|
|
return 'diff-1up';
|
|
|
|
}
|
|
|
|
|
Make "Show Context" persist rendering, whitespace, encoding, etc
Summary:
Ref T2009. Currently, we do not persist view parameters when making context rendering requests.
The big one is the renderer (1up vs 2up). This makes context on unified diffs come in with too many columns.
However, it impacts other parameters too. For example, at HEAD, if you change highlighting to "rainbow" and then load more context, the context uses the original highlighter instead of the rainbow highlighter.
This moves context loads into ChangesetViewManager, which maintains view parameters and can provide them correctly.
- This removes "ref"; it is no longer required, as the ChangesetViewManager tracks it.
- This removes URI management from `behavior-show-more`; it is no longer required, since the ChangesetViewManager knows how to render.
- This removes "whitespace" since this is handled properly by the view manager.
Test Plan:
- Used "Show Top" / "Show All" / "Show Bottom" in 1-up and 2-up views.
- Changed file highlighting to rainbow, loaded stuff, saw rainbow stick.
- Used "Show Entire File" in 1-up and 2-up views.
- Saw loading chrome.
- No loading chrome normally.
- Made inlines, verified `copyRows()` code runs.
- Poked around Diffusion -- it is missing some parameter handling, but works OK.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T2009
Differential Revision: https://secure.phabricator.com/D11977
2015-03-05 23:03:00 +01:00
|
|
|
public function getRendererKey() {
|
|
|
|
return '1up';
|
|
|
|
}
|
|
|
|
|
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')),
|
2015-03-05 23:11:36 +01:00
|
|
|
phutil_tag('col', array('class' => 'copy')),
|
2014-11-15 01:58:24 +01:00
|
|
|
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);
|
|
|
|
|
2015-03-05 23:03:57 +01:00
|
|
|
list($left_prefix, $right_prefix) = $this->getLineIDPrefixes();
|
|
|
|
|
2015-03-05 23:11:36 +01:00
|
|
|
$no_copy = phutil_tag('td', array('class' => 'copy'));
|
|
|
|
$no_coverage = null;
|
|
|
|
|
|
|
|
$column_width = 4;
|
|
|
|
|
2013-01-14 23:20:35 +01:00
|
|
|
$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';
|
|
|
|
}
|
2015-03-05 23:03:57 +01:00
|
|
|
|
|
|
|
if ($left_prefix) {
|
|
|
|
$left_id = $left_prefix.$p['line'];
|
|
|
|
} else {
|
|
|
|
$left_id = null;
|
|
|
|
}
|
|
|
|
$out[] = phutil_tag('th', array('id' => $left_id), $p['line']);
|
|
|
|
|
2013-11-11 18:23:23 +01:00
|
|
|
$out[] = phutil_tag('th', array());
|
2015-03-05 23:11:36 +01:00
|
|
|
$out[] = $no_copy;
|
2013-11-11 18:23:23 +01:00
|
|
|
$out[] = phutil_tag('td', array('class' => $class), $p['render']);
|
2015-03-05 23:11:36 +01:00
|
|
|
$out[] = $no_coverage;
|
2015-03-05 23:03:57 +01:00
|
|
|
} else {
|
2013-01-14 23:20:35 +01:00
|
|
|
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';
|
2015-03-05 23:03:57 +01:00
|
|
|
if ($left_prefix) {
|
|
|
|
$left_id = $left_prefix.$p['oline'];
|
|
|
|
} else {
|
|
|
|
$left_id = null;
|
|
|
|
}
|
|
|
|
$out[] = phutil_tag('th', array('id' => $left_id), $p['oline']);
|
2013-01-14 23:20:35 +01:00
|
|
|
}
|
2015-03-05 23:03:57 +01:00
|
|
|
|
|
|
|
if ($right_prefix) {
|
|
|
|
$right_id = $right_prefix.$p['line'];
|
|
|
|
} else {
|
|
|
|
$right_id = null;
|
|
|
|
}
|
|
|
|
$out[] = phutil_tag('th', array('id' => $right_id), $p['line']);
|
|
|
|
|
2015-03-05 23:11:36 +01:00
|
|
|
|
|
|
|
$out[] = $no_copy;
|
2013-11-11 18:23:23 +01:00
|
|
|
$out[] = phutil_tag('td', array('class' => $class), $p['render']);
|
2015-03-05 23:11:36 +01:00
|
|
|
$out[] = $no_coverage;
|
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-01-14 23:20:54 +01:00
|
|
|
$inline = $this->buildInlineComment(
|
|
|
|
$p['comment'],
|
|
|
|
$p['right']);
|
2015-03-06 14:51:37 +01:00
|
|
|
$out[] = $this->getRowScaffoldForInline($inline);
|
2013-01-14 23:20:35 +01:00
|
|
|
break;
|
2015-03-05 23:01:39 +01:00
|
|
|
case 'no-context':
|
2015-03-05 23:11:36 +01:00
|
|
|
$out[] = phutil_tag(
|
|
|
|
'tr',
|
|
|
|
array(),
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'class' => 'show-more',
|
|
|
|
'colspan' => $column_width,
|
|
|
|
),
|
|
|
|
pht('Context not available.')));
|
2015-03-05 23:01:39 +01:00
|
|
|
break;
|
2015-03-05 23:02:29 +01:00
|
|
|
case 'context':
|
|
|
|
$top = $p['top'];
|
|
|
|
$len = $p['len'];
|
|
|
|
|
|
|
|
$links = $this->renderShowContextLinks($top, $len, $rows);
|
|
|
|
|
|
|
|
$out[] = javelin_tag(
|
|
|
|
'tr',
|
|
|
|
array(
|
|
|
|
'sigil' => 'context-target',
|
|
|
|
),
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'class' => 'show-more',
|
2015-03-05 23:11:36 +01:00
|
|
|
'colspan' => $column_width,
|
2015-03-05 23:02:29 +01:00
|
|
|
),
|
|
|
|
$links));
|
|
|
|
break;
|
2013-01-14 23:20:35 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-03-06 14:44:36 +01:00
|
|
|
public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) {
|
|
|
|
return id(new PHUIDiffOneUpInlineCommentRowScaffold())
|
|
|
|
->addInlineView($view);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|