diff --git a/src/IDF/Diff.php b/src/IDF/Diff.php index 8ab78b1..798b0a8 100644 --- a/src/IDF/Diff.php +++ b/src/IDF/Diff.php @@ -169,8 +169,7 @@ class IDF_Diff } $offsets[] = sprintf('%s%s', $left, $right); - $content = Pluf_esc($content); - $content = IDF_FileUtil::emphasizeControlCharacters($content); + $content = IDF_FileUtil::emphasizeControlCharacters(Pluf_esc($content)); $contents[] = sprintf('%s', $class, $pretty, $content); } if (count($file['chunks']) > $cc) { @@ -208,7 +207,7 @@ class IDF_Diff '' ."\n". '' ."\n"; - $out .= '' ."\n". + $out .= '
' ."\n". '' ."\n". ''. ''. @@ -354,31 +353,108 @@ class IDF_Diff if (IDF_FileUtil::isSupportedExtension($fileinfo[2])) { $pretty = ' prettyprint'; } - $out = ''; + $cc = 1; - $i = 0; + $left_offsets = array(); + $left_contents = array(); + $right_offsets = array(); + $right_contents = array(); + + $max_lineno_left = $max_lineno_right = 0; + foreach ($chunks as $chunk) { foreach ($chunk as $line) { - $line1 = ' '; - $line2 = ' '; - $line[2] = (strlen($line[2])) ? IDF_FileUtil::emphasizeControlCharacters(Pluf_esc($line[2])) : ' '; + $left = ''; + $right = ''; + $content = IDF_FileUtil::emphasizeControlCharacters(Pluf_esc($line[2])); + if ($line[0] and $line[1]) { - $class = 'diff-c'; - $line1 = $line2 = $line[2]; + $class = 'context'; + $left = $right = $content; } elseif ($line[0]) { - $class = 'diff-r'; - $line1 = $line[2]; + $class = 'removed'; + $left = $content; } else { - $class = 'diff-a'; - $line2 = $line[2]; + $class = 'added'; + $right = $content; } - $out .= sprintf(''."\n", $line[0], $class, $pretty, $line1, $line[1], $class, $pretty, $line2); + + $left_offsets[] = sprintf('', $line[0]); + $right_offsets[] = sprintf('', $line[1]); + $left_contents[] = sprintf('', $class, $pretty, $left); + $right_contents[] = sprintf('', $class, $pretty, $right); + + $max_lineno_left = max($max_lineno_left, $line[0]); + $max_lineno_right = max($max_lineno_right, $line[1]); + } + + if (count($chunks) > $cc) { + $left_offsets[] = ''; + $right_offsets[] = ''; + $left_contents[] = ''; + $right_contents[] = ''; } - if (count($chunks) > $cc) - $out .= ''."\n"; $cc++; - $i++; } + + $leftwidth = 1; + if ($max_lineno_left > 0) + $leftwidth = ((ceil(log10($max_lineno_left)) + 1) * 8) + 12; + + $rightwidth = 1; + if ($max_lineno_right > 0) + $rightwidth = ((ceil(log10($max_lineno_right)) + 1) * 8) + 12; + + $inner_linecounts_left = + '
'.Pluf_esc($filename).'
%s%s%s%s
%s%s%s%s......
... ... 
' ."\n". + '' ."\n". + '' . + implode(''."\n".'', $left_offsets). + '' ."\n". + '
' ."\n"; + + $inner_linecounts_right = + '' ."\n". + '' ."\n". + '' . + implode(''."\n".'', $right_offsets). + '' ."\n". + '
' ."\n"; + + $inner_contents_left = + '' ."\n". + '' . + implode(''."\n".'', $left_contents) . + '' ."\n". + '
' ."\n"; + + $inner_contents_right = + '' ."\n". + '' . + implode(''."\n".'', $right_contents) . + '' ."\n". + '
' ."\n"; + + $out = + '' ."\n". + '' . + '' . + '' . + '' ."\n". + ''. + ''. + '' ."\n". + '' . + '' . + ''. + '' . + ''. "\n". + ''. "\n". + ''. "\n". + ''. "\n". + '' ."\n". + '
'.Pluf_esc($filename).'
'.__('Old').''.__('New').'
'. $inner_linecounts_left .'
'. $inner_contents_left .'
'. $inner_linecounts_right .'
'. $inner_contents_right .'
' ."\n"; + return Pluf_Template::markSafe($out); } } diff --git a/src/IDF/templates/idf/review/view.html b/src/IDF/templates/idf/review/view.html index d655083..41d368b 100644 --- a/src/IDF/templates/idf/review/view.html +++ b/src/IDF/templates/idf/review/view.html @@ -10,8 +10,26 @@ {/if} {/if} - - -
+{if !$user.isAnonymous()} +
+

{trans 'How to Participate in a Code Review'}

+ +

{blocktrans}Code review is a process in which +after or before changes are commited into the code repository, +different people discuss the code changes. The goal is +to improve the quality of the code and the +contributions, as such, you must be pragmatic when writing +your review. Correctly mention the line numbers (in the old or in the +new file) and try to keep a good balance between seriousness and fun. +{/blocktrans}

+

{blocktrans} +Proposing code for review is intimidating, you know +you will receive critics, so please, as a reviewer, keep this +process fun, use it to help your contributor learn your +coding standards and the structure of the code and make them want +to propose more contributions. +{/blocktrans}

+{/if} @@ -45,39 +63,12 @@
{trans 'Created:'}{$patch.creation_dtime|date:"%Y-%m-%d %H:%M:%S"} ({$patch.creation_dtime|dateago}) {trans 'Archive'} {trans 'Download the corresponding diff file'}
-
-{if !$user.isAnonymous()} -
-

{trans 'How to Participate in a Code Review'}

- -

{blocktrans}Code review is a process in which -after or before changes are commited into the code repository, -different people discuss the code changes. The goal is -to improve the quality of the code and the -contributions, as such, you must be pragmatic when writing -your review. Correctly mention the line numbers (in the old or in the -new file) and try to keep a good balance between seriousness and fun. -{/blocktrans}

-

{blocktrans} -Proposing code for review is intimidating, you know -you will receive critics, so please, as a reviewer, keep this -process fun, use it to help your contributor learn your -coding standards and the structure of the code and make them want -to propose more contributions. -{/blocktrans}

-{/if} -
{foreach $files as $file=>$def} - - - - -{$def[0]} - -
{$file}
{trans 'Old'}{trans 'New'}
+ + {$def[0]} + {assign $fcomments = $def[2]} {assign $nc = $fcomments.count()} {assign $i = 1} diff --git a/www/media/idf/css/style.css b/www/media/idf/css/style.css index 075c76e..eff8a28 100644 --- a/www/media/idf/css/style.css +++ b/www/media/idf/css/style.css @@ -600,8 +600,9 @@ table.diff td { padding: 0; } -table.diff > tbody > tr > td + td { - border-right: 1px solid #d3d7cf; +table.diff.unified > tbody > tr > td + td, +table.diff.context > tbody > tr > td + td + td + td { + border-right: 1px solid #d3d7cf; } table.diff th {