enhanced the full diff view slightly

This commit is contained in:
hyung-hwan 2015-01-27 13:01:33 +00:00
parent 11e60639af
commit 5fc888924c
3 changed files with 191 additions and 4 deletions

View File

@ -262,7 +262,7 @@ class Code extends Controller
{ {
$data['message'] = 'DATABASE ERROR'; $data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data); $this->load->view ($this->VIEW_ERROR, $data);
} }
else if ($project === NULL) else if ($project === NULL)
{ {
$data['message'] = $data['message'] =
@ -395,6 +395,7 @@ class Code extends Controller
$data['revision1'] = $rev1; $data['revision1'] = $rev1;
$data['revision2'] = $rev2; $data['revision2'] = $rev2;
$data['file'] = $file; $data['file'] = $file;
$data['fullview'] = $full;
$this->load->view ($this->VIEW_DIFF, $data); $this->load->view ($this->VIEW_DIFF, $data);
} }
} }

View File

@ -91,6 +91,21 @@ $this->load->view (
$this->lang->line('Blame')); $this->lang->line('Blame'));
print ' | '; print ' | ';
if (!$fullview)
{
print anchor (
"code/fulldiff/{$project->id}/{$xpar}{$revreq}",
$this->lang->line('Full Difference'));
}
else
{
print anchor (
"code/diff/{$project->id}/{$xpar}{$revreq}",
$this->lang->line('Difference'));
}
print ' | ';
if ($revision1 > 0) if ($revision1 > 0)
{ {
@ -115,9 +130,10 @@ $this->load->view (
?> ?>
<div id="code_diff_mainarea_result"> <div id="code_diff_mainarea_result">
<table id="code_diff_mainarea_result_table">
<?php <?php
if (!$fullview)
{
print '<table id="code_diff_mainarea_result_table">';
/* /*
print '<pre>'; print '<pre>';
print_r ($file['content']); print_r ($file['content']);
@ -237,8 +253,109 @@ $this->load->view (
print '</tr>'; print '</tr>';
} }
} }
print '</table>';
}
else
{
print '<div style="width: 100%; overflow: hidden;" id="code_diff_mainarea_result_fullview">';
if (empty($file['content']))
{
print htmlspecialchars ($this->lang->line('MSG_NO_DIFF'));
}
else
{
print ("<div style='float:left; width: 49%;'>");
print "<div class='navigator'>";
$currev = $file['created_rev'];
$prevrev = $file['against']['prev_rev'];
$prevanc = "code/fulldiff/{$project->id}/{$xpar}/{$currev}/{$prevrev}";
print anchor ($prevanc, '<<');
print '&nbsp;&nbsp;&nbsp;';
print $this->lang->line('Revision');
print ' ';
print $file['against']['created_rev'];
$currev = $file['created_rev'];
$nextrev = $file['against']['next_rev'];
$nextanc = "code/fulldiff/{$project->id}/{$xpar}/{$currev}/{$nextrev}";
print '&nbsp;&nbsp;&nbsp;';
print anchor ($nextanc, '>>');
print "</div>";
print "<pre class='prettyprint lang-{$fileext}' style='width: 100%' id='code_diff_mainarea_result_fulldiffold'>";
foreach ($file['content'] as $x)
{
if (array_key_exists('rev1line', $x))
{
$diffclass = array_key_exists('rev1diffclass', $x)? $x['rev1diffclass']: 'diff';
print "<span class='{$diffclass}'>";
if ($x['rev1line'] == '') print '&nbsp;';
else print htmlspecialchars($x['rev1line']);
print "</span>";
}
else
{
print $x['rev1lineno'];
}
print "\n";
}
printf ("</div>");
print '</pre>';
print ("<div style='float:left; width: 49%;'>");
print "<div class='navigator'>";
$currev = $file['against']['created_rev'];
$prevrev = $file['prev_rev'];
$prevanc = "code/fulldiff/{$project->id}/{$xpar}/{$prevrev}/{$currev}";
print anchor ($prevanc, '<<');
print '&nbsp;&nbsp;&nbsp;';
print $this->lang->line('Revision');
print ' ';
print $file['created_rev'];
$currev = $file['against']['created_rev'];
$nextrev = $file['next_rev'];
$nextanc = "code/fulldiff/{$project->id}/{$xpar}/{$nextrev}/{$currev}";
print '&nbsp;&nbsp;&nbsp;';
print anchor ($nextanc, '>>');
print "</div>";
print "<pre class='prettyprint lang-{$fileext}' style='width: 100%' id='code_diff_mainarea_result_fulldiffnew'>";
foreach ($file['content'] as $x)
{
if (array_key_exists('rev2line', $x))
{
$diffclass = array_key_exists('rev2diffclass', $x)? $x['rev2diffclass']: 'diff';
print "<span class='{$diffclass}'>";
if ($x['rev2line'] == '') print '&nbsp;';
else print htmlspecialchars($x['rev2line']);
print "</span>";
}
else
{
print $x['rev2lineno'];
}
print "\n";
}
print '</pre>';
printf ("</div>");
}
print '</div>';
}
?> ?>
</table>
</div> </div>
</div> <!-- code_diff_mainarea --> </div> <!-- code_diff_mainarea -->

View File

@ -305,3 +305,72 @@
margin: 0; margin: 0;
} }
#code_diff_mainarea_result_fulldiffold {
border: none;
//padding-left: 10px;
//background: #F8FAF8;
padding-left: 1px;
}
#code_diff_mainarea_result_fulldiffnew {
border: none;
//padding-left: 10px;
background: #F8F8FA;
padding-left: 1px;
}
#code_diff_mainarea_result_fullview .navigator {
background-color: #7777FF;
color: #FFFFFF;
font-weight: bold;
}
#code_diff_mainarea_result_fullview .navigator a {
color: #FFFFFF;
font-weight: bold;
font-decoration: none;
}
#code_diff_mainarea_result_fullview .diff {
background-position: 2px 50%;
padding: 0;
padding-left:15px;
margin: 0;
}
#code_diff_mainarea_result_fullview .diffadded {
border:1px solid #cdf0cd;
background-color:#ddffdd;
background-image:url(images/bullet_add.png);
background-repeat:no-repeat;
//background-position: 2px 50%;
background-position: 0 50%;
padding: 0;
padding-left:15px;
margin: 0;
}
#code_diff_mainarea_result_fullview .diffdeleted {
border:1px solid #e8d4bc;
background-color:#f8e4cc;
background-image:url(images/bullet_delete.png);
background-repeat:no-repeat;
//background-position: 2px 50%;
background-position: 0 50%;
padding: 0;
padding-left:15px;
margin: 0;
}
#code_diff_mainarea_result_fullview .diffchanged {
border:1px solid #f0f0bc;
background-color:#ffffcc;
background-image:url(images/bullet_yellow.png);
background-repeat:no-repeat;
//background-position: 2px 50%;
background-position: 0 50%;
padding: 0;
padding-left:15px;
margin: 0;
}