From 5fc888924c2d798d00a80431c109397a97e85ab2 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 27 Jan 2015 13:01:33 +0000 Subject: [PATCH] enhanced the full diff view slightly --- codepot/src/codepot/controllers/code.php | 3 +- codepot/src/codepot/views/code_diff.php | 123 ++++++++++++++++++++++- codepot/src/css/code.css | 69 +++++++++++++ 3 files changed, 191 insertions(+), 4 deletions(-) diff --git a/codepot/src/codepot/controllers/code.php b/codepot/src/codepot/controllers/code.php index 5415b2e2..63d82f97 100644 --- a/codepot/src/codepot/controllers/code.php +++ b/codepot/src/codepot/controllers/code.php @@ -262,7 +262,7 @@ class Code extends Controller { $data['message'] = 'DATABASE ERROR'; $this->load->view ($this->VIEW_ERROR, $data); - } + } else if ($project === NULL) { $data['message'] = @@ -395,6 +395,7 @@ class Code extends Controller $data['revision1'] = $rev1; $data['revision2'] = $rev2; $data['file'] = $file; + $data['fullview'] = $full; $this->load->view ($this->VIEW_DIFF, $data); } } diff --git a/codepot/src/codepot/views/code_diff.php b/codepot/src/codepot/views/code_diff.php index 505709c2..460817f9 100644 --- a/codepot/src/codepot/views/code_diff.php +++ b/codepot/src/codepot/views/code_diff.php @@ -91,6 +91,21 @@ $this->load->view ( $this->lang->line('Blame')); 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) { @@ -115,9 +130,10 @@ $this->load->view ( ?>
-'; /* print '
';	
 	print_r ($file['content']);
@@ -237,8 +253,109 @@ $this->load->view (
 			print '';
 		}
 	}
+
+	print '
'; +} +else +{ + print '
'; + + if (empty($file['content'])) + { + print htmlspecialchars ($this->lang->line('MSG_NO_DIFF')); + } + else + { + print ("
"); + + print ""; + + print "
";
+
+		foreach ($file['content'] as $x)
+		{
+			if (array_key_exists('rev1line', $x)) 
+			{
+				$diffclass = array_key_exists('rev1diffclass', $x)? $x['rev1diffclass']: 'diff';
+				print "";
+				if ($x['rev1line'] == '') print ' ';
+				else print htmlspecialchars($x['rev1line']);
+				print "";
+			}
+			else
+			{
+				print $x['rev1lineno'];
+			}
+			print "\n";
+		}
+		printf ("
"); + print ''; + + + print ("
"); + + print ""; + + print "
";
+		foreach ($file['content'] as $x)
+		{
+			if (array_key_exists('rev2line', $x)) 
+			{
+				$diffclass = array_key_exists('rev2diffclass', $x)? $x['rev2diffclass']: 'diff';
+
+				print "";
+
+				if ($x['rev2line'] == '') print ' ';
+				else print htmlspecialchars($x['rev2line']);
+				
+				print "";
+			}
+			else
+			{
+				print $x['rev2lineno'];
+			}
+			print "\n";
+		}
+
+		print '
'; + printf ("
"); + } + print '
'; +} ?> - +
diff --git a/codepot/src/css/code.css b/codepot/src/css/code.css index a0ce28b7..b95c0f7e 100644 --- a/codepot/src/css/code.css +++ b/codepot/src/css/code.css @@ -305,3 +305,72 @@ 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; +}