From f76724a46dee840092905f3d819423ffd556f14e Mon Sep 17 00:00:00 2001 From: Tom N Harris Date: Sat, 16 Feb 2013 16:07:00 -0500 Subject: Move inline diff headers into a vertical column. --- inc/DifferenceEngine.php | 19 +++++++++++-------- inc/html.php | 27 +++++++++++++++++++++------ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index 1b68cf6d3..1099f40eb 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -1070,11 +1070,13 @@ class TableDiffFormatter extends DiffFormatter { } function addedLine($line) { - return '+' . $line.''; + return '+'. + '' . $line.''; } function deletedLine($line) { - return '-' . $line.''; + return '-'. + '' . $line.''; } function emptyLine() { @@ -1082,7 +1084,8 @@ class TableDiffFormatter extends DiffFormatter { } function contextLine($line) { - return ' '.$line.''; + return ' '. + ''.$line.''; } function _added($lines) { @@ -1121,7 +1124,7 @@ class TableDiffFormatter extends DiffFormatter { * */ class InlineDiffFormatter extends DiffFormatter { - var $colspan = 4; + var $colspan = 2; function __construct() { $this->leading_context_lines = 2; @@ -1167,19 +1170,19 @@ class InlineDiffFormatter extends DiffFormatter { function _added($lines) { foreach ($lines as $line) { - print(''. $line . "\n"); + print('+'. $line . "\n"); } } function _deleted($lines) { foreach ($lines as $line) { - print('' . $line . "\n"); + print('-' . $line . "\n"); } } function _context($lines) { foreach ($lines as $line) { - print(''.$line."\n"); + print(' '.$line."\n"); } } @@ -1188,7 +1191,7 @@ class InlineDiffFormatter extends DiffFormatter { $add = $diff->inline(); foreach ($add as $line) - print(''.$line."\n"); + print('!'.$line."\n"); } } diff --git a/inc/html.php b/inc/html.php index c2723bceb..78042cb8b 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1003,14 +1003,16 @@ function html_backlinks(){ * @param string $r_rev Right revision * @param string $id Page id, if null $ID is used * @param bool $media If it is for media files + * @param bool $inline Return the header on a single line * @return array HTML snippets for diff header */ -function html_diff_head($l_rev, $r_rev, $id = null, $media = false) { +function html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = false) { global $lang; if ($id === null) { global $ID; $id = $ID; } + $head_separator = $inline ? ' ' : '
'; $media_or_wikiFN = $media ? 'mediaFN' : 'wikiFN'; $ml_or_wl = $media ? 'ml' : 'wl'; $l_minor = $r_minor = ''; @@ -1032,7 +1034,7 @@ function html_diff_head($l_rev, $r_rev, $id = null, $media = false) { $l_head_title = ($media) ? dformat($l_rev) : $id.' ['.dformat($l_rev).']'; $l_head = ''. $l_head_title.''. - '
'.$l_user.' '.$l_sum; + $head_separator.$l_user.' '.$l_sum; } if($r_rev){ @@ -1050,7 +1052,7 @@ function html_diff_head($l_rev, $r_rev, $id = null, $media = false) { $r_head_title = ($media) ? dformat($r_rev) : $id.' ['.dformat($r_rev).']'; $r_head = ''. $r_head_title.''. - '
'.$r_user.' '.$r_sum; + $head_separator.$r_user.' '.$r_sum; }elseif($_rev = @filemtime($media_or_wikiFN($id))){ $_info = getRevisionInfo($id,$_rev,true, $media); if($_info['user']){ @@ -1067,7 +1069,7 @@ function html_diff_head($l_rev, $r_rev, $id = null, $media = false) { $r_head = ''. $r_head_title.' '. '('.$lang['current'].')'. - '
'.$_user.' '.$_sum; + $head_separator.$_user.' '.$_sum; }else{ $r_head = '— ('.$lang['current'].')'; } @@ -1160,7 +1162,7 @@ function html_diff($text='',$intro=true,$type=null){ } $r_text = rawWiki($ID,$r_rev); - list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev); + list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev, null, false, $type == 'inline'); } $df = new Diff(explode("\n",hsc($l_text)),explode("\n",hsc($r_text))); @@ -1205,6 +1207,18 @@ function html_diff($text='',$intro=true,$type=null){ ?>
+ + + + + + + + - format($df)); ?> + format($df)); ?>
---> + +
+++> + +
> @@ -1213,7 +1227,8 @@ function html_diff($text='',$intro=true,$type=null){
Date: Sat, 16 Feb 2013 16:28:01 -0500 Subject: Monospace font for header prefix. --- inc/html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/html.php b/inc/html.php index 78042cb8b..420efd633 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1209,12 +1209,12 @@ function html_diff($text='',$intro=true,$type=null){ - - -- cgit v1.2.3 From 56133a04d1c5dcd4825f4c0c978b8a9336d603d0 Mon Sep 17 00:00:00 2001 From: Tom N Harris Date: Sat, 16 Feb 2013 18:15:13 -0500 Subject: Fix width of indicator column. --- inc/DifferenceEngine.php | 10 +++++----- inc/html.php | 4 ++-- lib/tpl/default/design.css | 12 +++++++++++- lib/tpl/dokuwiki/css/_diff.css | 12 +++++++++++- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index 1099f40eb..2125ad879 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -1151,7 +1151,7 @@ class InlineDiffFormatter extends DiffFormatter { $xbeg .= "," . $xlen; if ($ylen != 1) $ybeg .= "," . $ylen; - $r = '\n"; @@ -1170,19 +1170,19 @@ class InlineDiffFormatter extends DiffFormatter { function _added($lines) { foreach ($lines as $line) { - print('\n"); + print('\n"); } } function _deleted($lines) { foreach ($lines as $line) { - print('\n"); + print('\n"); } } function _context($lines) { foreach ($lines as $line) { - print('\n"); + print('\n"); } } @@ -1191,7 +1191,7 @@ class InlineDiffFormatter extends DiffFormatter { $add = $diff->inline(); foreach ($add as $line) - print('\n"); + print('\n"); } } diff --git a/inc/html.php b/inc/html.php index 420efd633..e657d2c78 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1209,12 +1209,12 @@ function html_diff($text='',$intro=true,$type=null){
---> + --->
+++> + +++>
@@ '.$lang['line']." -$xbeg +$ybeg @@"; + $r = '
@@ '.$lang['line']." -$xbeg +$ybeg @@"; $r .= ' '.$lang['deleted'].''; $r .= ' '.$lang['created'].''; $r .= "
+'. $line . "
+'. $line . "
-' . $line . "
-' . $line . "
 '.$line."
 '.$line."
!'.$line."
!'.$line."
- - diff --git a/lib/tpl/default/design.css b/lib/tpl/default/design.css index 3405ec258..4772fd2a5 100644 --- a/lib/tpl/default/design.css +++ b/lib/tpl/default/design.css @@ -632,7 +632,6 @@ div.dokuwiki td.diff-blockheader { div.dokuwiki table.diff th { border-bottom: 1px solid __border__; font-size: 110%; - width: 50%; font-weight: normal; text-align: left; } @@ -650,6 +649,17 @@ div.dokuwiki table.diff th span.sum { div.dokuwiki table.diff th.minor { font-style: italic; } +.dokuwiki table.diff_sidebyside th { + width: 50%; +} +.dokuwiki table.diff .diff-lineheader { + width: .7em; + text-align: right; +} +[dir=rtl] .dokuwiki table.diff .diff-lineheader { + text-align: left; +} +.dokuwiki table.diff .diff-lineheader, div.dokuwiki table.diff td { font-family: monospace; font-size: 100%; diff --git a/lib/tpl/dokuwiki/css/_diff.css b/lib/tpl/dokuwiki/css/_diff.css index 62f831213..58c24b5c7 100644 --- a/lib/tpl/dokuwiki/css/_diff.css +++ b/lib/tpl/dokuwiki/css/_diff.css @@ -21,7 +21,6 @@ .dokuwiki table.diff th { border-bottom: 1px solid __border__; font-size: 110%; - width: 50%; font-weight: normal; } .dokuwiki table.diff th a { @@ -37,8 +36,19 @@ .dokuwiki table.diff th.minor { color: #999; } +.dokuwiki table.diff_sidebyside th { + width: 50%; +} /* table body */ +.dokuwiki table.diff .diff-lineheader { + width: .7em; + text-align: right; +} +[dir=rtl] .dokuwiki table.diff .diff-lineheader { + text-align: left; +} +.dokuwiki table.diff .diff-lineheader, .dokuwiki table.diff td { font-family: Consolas, "Andale Mono WT", "Andale Mono", "Bitstream Vera Sans Mono", "Nimbus Mono L", Monaco, "Courier New", monospace; } -- cgit v1.2.3 From a69506c52fbd9c92500be4f380acc7e68d4d6560 Mon Sep 17 00:00:00 2001 From: Tom N Harris Date: Sat, 16 Feb 2013 18:27:12 -0500 Subject: Remove the prefix from inline diffs. The line prefix was not actually indicating what it should indicate. In particular, anything in a "changed" block would show a "!" even if the entire line was added or deleted. Better to print nothing than something that's wrong. --- inc/DifferenceEngine.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index 2125ad879..c15c8b163 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -1170,13 +1170,13 @@ class InlineDiffFormatter extends DiffFormatter { function _added($lines) { foreach ($lines as $line) { - print('\n"); + print('\n"); } } function _deleted($lines) { foreach ($lines as $line) { - print('\n"); + print('\n"); } } @@ -1191,7 +1191,7 @@ class InlineDiffFormatter extends DiffFormatter { $add = $diff->inline(); foreach ($add as $line) - print('\n"); + print('\n"); } } -- cgit v1.2.3
---> + ->
+++> + +>
+'. $line . "
 '. $line . "
-' . $line . "
 ' . $line . "
!'.$line."
 '.$line."