summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2013-02-17 18:26:39 +0000
committerChristopher Smith <chris@jalakai.co.uk>2013-02-17 18:26:39 +0000
commit333ef4f3bdb4c2b3332744e3f894d9990d3c24e8 (patch)
tree79922c3878a4b0bf2a0a147cc972a1d54ec8794d
parent60056e697fb1666e9b491b6f9f5654b694e3b8c9 (diff)
parenta69506c52fbd9c92500be4f380acc7e68d4d6560 (diff)
downloadrpg-333ef4f3bdb4c2b3332744e3f894d9990d3c24e8.tar.gz
rpg-333ef4f3bdb4c2b3332744e3f894d9990d3c24e8.tar.bz2
Merge remote-tracking branch 'whoopdedo/diffmarkup' into FS#2720
-rw-r--r--inc/DifferenceEngine.php21
-rw-r--r--inc/html.php27
-rw-r--r--lib/tpl/default/design.css12
-rw-r--r--lib/tpl/dokuwiki/css/_diff.css12
4 files changed, 55 insertions, 17 deletions
diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php
index 42975b208..f6ed9aa13 100644
--- a/inc/DifferenceEngine.php
+++ b/inc/DifferenceEngine.php
@@ -1081,14 +1081,16 @@ class TableDiffFormatter extends DiffFormatter {
if (!$escaped){
$line = $this->_escape($line);
}
- return '<td>+</td><td '.HTMLDiff::css('diff-addedline').'>' . $line.'</td>';
+ return '<td '.HTMLDiff::css('diff-lineheader').'>+</td>'.
+ '<td '.HTMLDiff::css('diff-addedline').'>' . $line.'</td>';
}
function deletedLine($line,$escaped=false) {
if (!$escaped){
$line = $this->_escape($line);
}
- return '<td>-</td><td '.HTMLDiff::css('diff-deletedline').'>' . $line.'</td>';
+ return '<td '.HTMLDiff::css('diff-lineheader').'>-</td>'.
+ '<td '.HTMLDiff::css('diff-deletedline').'>' . $line.'</td>';
}
function emptyLine() {
@@ -1096,7 +1098,8 @@ class TableDiffFormatter extends DiffFormatter {
}
function contextLine($line) {
- return '<td> </td><td '.HTMLDiff::css('diff-context').'>'.$this->_escape($line).'</td>';
+ return '<td '.HTMLDiff::css('diff-lineheader').'>&#160;</td>'.
+ '<td '.HTMLDiff::css('diff-context').'>'.$this->_escape($line).'</td>';
}
function _added($lines) {
@@ -1143,7 +1146,7 @@ class TableDiffFormatter extends DiffFormatter {
*
*/
class InlineDiffFormatter extends DiffFormatter {
- var $colspan = 4;
+ var $colspan = 2;
function __construct() {
$this->leading_context_lines = 2;
@@ -1170,7 +1173,7 @@ class InlineDiffFormatter extends DiffFormatter {
$xbeg .= "," . $xlen;
if ($ylen != 1)
$ybeg .= "," . $ylen;
- $r = '<tr><td colspan="'.$this->colspan.'" '.HTMLDiff::css('diff-blockheader').'>@@ '.$lang['line']." -$xbeg +$ybeg @@";
+ $r = '<tr><td colspan="2" '.HTMLDiff::css('diff-blockheader').'>@@ '.$lang['line']." -$xbeg +$ybeg @@";
$r .= ' <span '.HTMLDiff::css('diff-deletedline').'><del>'.$lang['deleted'].'</del></span>';
$r .= ' <span '.HTMLDiff::css('diff-addedline').'>'.$lang['created'].'</span>';
$r .= "</td></tr>\n";
@@ -1189,19 +1192,19 @@ class InlineDiffFormatter extends DiffFormatter {
function _added($lines) {
foreach ($lines as $line) {
- print('<tr><td colspan="'.$this->colspan.'" '.HTMLDiff::css('diff-addedline').'>'. $this->_escape($line) . "</td></tr>\n");
+ print('<tr><td '.HTMLDiff::css('diff-lineheader').'>&#160;</td><td '.HTMLDiff::css('diff-addedline').'>'. $this->_escape($line) . "</td></tr>\n");
}
}
function _deleted($lines) {
foreach ($lines as $line) {
- print('<tr><td colspan="'.$this->colspan.'" '.HTMLDiff::css('diff-deletedline').'><del>' . $this->_escape($line) . "</del></td></tr>\n");
+ print('<tr><td '.HTMLDiff::css('diff-lineheader').'>&#160;</td><td '.HTMLDiff::css('diff-deletedline').'><del>' . $this->_escape($line) . "</del></td></tr>\n");
}
}
function _context($lines) {
foreach ($lines as $line) {
- print('<tr><td colspan="'.$this->colspan.'" '.HTMLDiff::css('diff-context').'>'.$this->_escape($line)."</td></tr>\n");
+ print('<tr><td '.HTMLDiff::css('diff-lineheader').'>&#160;</td><td '.HTMLDiff::css('diff-context').'>'. $this->_escape($line) ."</td></tr>\n");
}
}
@@ -1210,7 +1213,7 @@ class InlineDiffFormatter extends DiffFormatter {
$add = $diff->inline();
foreach ($add as $line)
- print('<tr><td colspan="'.$this->colspan.'">'.$line."</td></tr>\n");
+ print('<tr><td '.HTMLDiff::css('diff-lineheader').'>&#160;</td><td>'.$line."</td></tr>\n");
}
function _escape($str) {
diff --git a/inc/html.php b/inc/html.php
index 6c42f6e7b..59415f7da 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 ? ' ' : '<br />';
$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 = '<a class="wikilink1" href="'.$ml_or_wl($id,"rev=$l_rev").'">'.
$l_head_title.'</a>'.
- '<br />'.$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 = '<a class="wikilink1" href="'.$ml_or_wl($id,"rev=$r_rev").'">'.
$r_head_title.'</a>'.
- '<br />'.$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 = '<a class="wikilink1" href="'.$ml_or_wl($id).'">'.
$r_head_title.'</a> '.
'('.$lang['current'].')'.
- '<br />'.$_user.' '.$_sum;
+ $head_separator.$_user.' '.$_sum;
}else{
$r_head = '&mdash; ('.$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",$l_text),explode("\n",$r_text));
@@ -1205,6 +1207,18 @@ function html_diff($text='',$intro=true,$type=null){
?>
<div class="table">
<table class="diff diff_<?php echo $type?>">
+ <?php if ($type == 'inline') { ?>
+ <tr>
+ <th class="diff-lineheader">-</th><th <?php echo $l_minor?>>
+ <?php echo $l_head?>
+ </th>
+ </tr>
+ <tr>
+ <th class="diff-lineheader">+</th><th <?php echo $r_minor?>>
+ <?php echo $r_head?>
+ </th>
+ </tr>
+ <?php } else { ?>
<tr>
<th colspan="2" <?php echo $l_minor?>>
<?php echo $l_head?>
@@ -1213,7 +1227,8 @@ function html_diff($text='',$intro=true,$type=null){
<?php echo $r_head?>
</th>
</tr>
- <?php echo html_insert_softbreaks($tdf->format($df)); ?>
+ <?php }
+ echo html_insert_softbreaks($tdf->format($df)); ?>
</table>
</div>
<?php
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;
}