summaryrefslogtreecommitdiffabout
authorRagnar Ouchterlony <ragnar@lysator.liu.se>2009-09-15 17:44:37 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2009-09-16 18:17:56 (UTC)
commit207cc34711039329b41345f716bf421a88a6fd0a (patch) (unidiff)
tree5fb56c7e5c105c9045e52abd971013270db23368
parentc358aa3dfebf4fc1f3005dd960aa5c1c020eed76 (diff)
downloadcgit-207cc34711039329b41345f716bf421a88a6fd0a.zip
cgit-207cc34711039329b41345f716bf421a88a6fd0a.tar.gz
cgit-207cc34711039329b41345f716bf421a88a6fd0a.tar.bz2
Polishing of how the side-by-side diff looks.
Aligned all different files, so that all side-by-side tables look the same. Also made sure that the tables take up the whole browser width. Also various changes to the css to make things easier on the eye. Signed-off-by: Ragnar Ouchterlony <ragnar@lysator.liu.se> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.css66
-rw-r--r--ui-diff.c21
-rw-r--r--ui-ssdiff.c20
-rw-r--r--ui-ssdiff.h3
4 files changed, 88 insertions, 22 deletions
diff --git a/cgit.css b/cgit.css
index bf58b8a..3f37165 100644
--- a/cgit.css
+++ b/cgit.css
@@ -603,32 +603,59 @@ table.hgraph div.bar {
603} 603}
604 604
605table.ssdiff {
606 width: 100%;
607}
608
609table.ssdiff td {
610 font-size: 75%;
611 font-family: monospace;
612 white-space: pre;
613 padding: 1px 4px 1px 4px;
614 border-left: solid 1px #aaa;
615 border-right: solid 1px #aaa;
616}
617
605table.ssdiff td.add { 618table.ssdiff td.add {
606 color: black; 619 color: black;
607 background: #afa; 620 background: #cfc;
621 min-width: 50%;
608} 622}
609 623
610table.ssdiff td.add_dark { 624table.ssdiff td.add_dark {
611 color: black; 625 color: black;
612 background: #9c9; 626 background: #aca;
627 min-width: 50%;
613} 628}
614 629
615table.ssdiff td.del { 630table.ssdiff td.del {
616 color: black; 631 color: black;
617 background: #faa; 632 background: #fcc;
633 min-width: 50%;
618} 634}
619 635
620table.ssdiff td.del_dark { 636table.ssdiff td.del_dark {
621 color: black; 637 color: black;
622 background: #c99; 638 background: #caa;
639 min-width: 50%;
623} 640}
624 641
625table.ssdiff td.changed { 642table.ssdiff td.changed {
626 color: black; 643 color: black;
627 background: #ffa; 644 background: #ffc;
645 min-width: 50%;
628} 646}
629 647
630table.ssdiff td.changed_dark { 648table.ssdiff td.changed_dark {
631 color: black; 649 color: black;
632 background: #cc9; 650 background: #cca;
651 min-width: 50%;
652}
653
654table.ssdiff td.lineno {
655 color: black;
656 background: #eee;
657 text-align: right;
658 width: 3em;
659 min-width: 3em;
633} 660}
634 661
@@ -636,3 +663,30 @@ table.ssdiff td.hunk {
636 color: #black; 663 color: #black;
637 background: #ccf; 664 background: #ccf;
665 border-top: solid 1px #aaa;
666 border-bottom: solid 1px #aaa;
667}
668
669table.ssdiff td.head {
670 border-top: solid 1px #aaa;
671 border-bottom: solid 1px #aaa;
672}
673
674table.ssdiff td.head div.head {
675 font-weight: bold;
676 color: black;
677}
678
679table.ssdiff td.foot {
680 border-top: solid 1px #aaa;
681 border-left: none;
682 border-right: none;
683 border-bottom: none;
684}
685
686table.ssdiff td.space {
687 border: none;
688}
689
690table.ssdiff td.space div {
691 min-height: 3em;
638} 692}
diff --git a/ui-diff.c b/ui-diff.c
index 42e81ac..b21c2c1 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -247,6 +247,4 @@ static void header(unsigned char *sha1, char *path1, int mode1,
247 } 247 }
248 html("</div>"); 248 html("</div>");
249 if (use_ssdiff)
250 cgit_ssdiff_header();
251} 249}
252 250
@@ -271,15 +269,17 @@ static void filepair_cb(struct diff_filepair *pair)
271 linediff_fn print_line_fn = print_line; 269 linediff_fn print_line_fn = print_line;
272 270
273 header(pair->one->sha1, pair->one->path, pair->one->mode,
274 pair->two->sha1, pair->two->path, pair->two->mode);
275 if (use_ssdiff) { 271 if (use_ssdiff) {
276 cgit_ssdiff_header(); 272 cgit_ssdiff_header_begin();
277 print_line_fn = cgit_ssdiff_line_cb; 273 print_line_fn = cgit_ssdiff_line_cb;
278 } 274 }
275 header(pair->one->sha1, pair->one->path, pair->one->mode,
276 pair->two->sha1, pair->two->path, pair->two->mode);
277 if (use_ssdiff)
278 cgit_ssdiff_header_end();
279 if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { 279 if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) {
280 if (S_ISGITLINK(pair->one->mode)) 280 if (S_ISGITLINK(pair->one->mode))
281 print_line(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); 281 print_line_fn(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52);
282 if (S_ISGITLINK(pair->two->mode)) 282 if (S_ISGITLINK(pair->two->mode))
283 print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); 283 print_line_fn(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52);
284 return; 284 return;
285 } 285 }
@@ -288,5 +288,5 @@ static void filepair_cb(struct diff_filepair *pair)
288 cgit_print_error("Error running diff"); 288 cgit_print_error("Error running diff");
289 if (binary) 289 if (binary)
290 html("Binary files differ"); 290 print_line_fn(" Binary files differ", 20);
291 if (use_ssdiff) 291 if (use_ssdiff)
292 cgit_ssdiff_footer(); 292 cgit_ssdiff_footer();
@@ -335,7 +335,12 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
335 cgit_print_diffstat(old_rev_sha1, new_rev_sha1); 335 cgit_print_diffstat(old_rev_sha1, new_rev_sha1);
336 336
337 if (use_ssdiff) {
338 html("<table summary='ssdiff' class='ssdiff'>");
339 } else {
337 html("<table summary='diff' class='diff'>"); 340 html("<table summary='diff' class='diff'>");
338 html("<tr><td>"); 341 html("<tr><td>");
342 }
339 cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix); 343 cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix);
344 if (!use_ssdiff)
340 html("</td></tr>"); 345 html("</td></tr>");
341 html("</table>"); 346 html("</table>");
diff --git a/ui-ssdiff.c b/ui-ssdiff.c
index 3591ab4..8215051 100644
--- a/ui-ssdiff.c
+++ b/ui-ssdiff.c
@@ -107,8 +107,8 @@ static void print_ssdiff_line(char *class, int old_line_no, char *old_line,
107 html("<tr>"); 107 html("<tr>");
108 if (old_line_no > 0) 108 if (old_line_no > 0)
109 htmlf("<td class='%s'>%d </td><td class='%s'>", class, 109 htmlf("<td class='lineno'>%d</td><td class='%s'>",
110 old_line_no, class); 110 old_line_no, class);
111 else 111 else
112 htmlf("<td class='%s_dark'> </td><td class='%s_dark'>", class, class); 112 htmlf("<td class='lineno'></td><td class='%s_dark'>", class);
113 113
114 if (old_line) { 114 if (old_line) {
@@ -121,8 +121,8 @@ static void print_ssdiff_line(char *class, int old_line_no, char *old_line,
121 121
122 if (new_line_no > 0) 122 if (new_line_no > 0)
123 htmlf("<td class='%s'> %d </td><td class='%s'>", class, 123 htmlf("<td class='lineno'>%d</td><td class='%s'>",
124 new_line_no, class); 124 new_line_no, class);
125 else 125 else
126 htmlf("<td class='%s_dark'> </td><td class='%s_dark'>", class, class); 126 htmlf("<td class='lineno'></td><td class='%s_dark'>", class);
127 127
128 if (new_line) { 128 if (new_line) {
@@ -250,9 +250,15 @@ void cgit_ssdiff_line_cb(char *line, int len)
250} 250}
251 251
252void cgit_ssdiff_header() 252void cgit_ssdiff_header_begin()
253{ 253{
254 current_old_line = 0; 254 current_old_line = 0;
255 current_new_line = 0; 255 current_new_line = 0;
256 html("<table class='ssdiff'>"); 256 html("<tr><td class='space' colspan='4'><div></div></td></tr>");
257 html("<tr><td class='head' colspan='4'>");
258}
259
260void cgit_ssdiff_header_end()
261{
262 html("</td><tr>");
257} 263}
258 264
@@ -261,4 +267,4 @@ void cgit_ssdiff_footer()
261 if (deferred_old || deferred_new) 267 if (deferred_old || deferred_new)
262 cgit_ssdiff_print_deferred_lines(); 268 cgit_ssdiff_print_deferred_lines();
263 html("</table>"); 269 html("<tr><td class='foot' colspan='4'></td></tr>");
264} 270}
diff --git a/ui-ssdiff.h b/ui-ssdiff.h
index a0b1efe..64b4b12 100644
--- a/ui-ssdiff.h
+++ b/ui-ssdiff.h
@@ -6,5 +6,6 @@ extern void cgit_ssdiff_print_deferred_lines();
6extern void cgit_ssdiff_line_cb(char *line, int len); 6extern void cgit_ssdiff_line_cb(char *line, int len);
7 7
8extern void cgit_ssdiff_header(); 8extern void cgit_ssdiff_header_begin();
9extern void cgit_ssdiff_header_end();
9 10
10extern void cgit_ssdiff_footer(); 11extern void cgit_ssdiff_footer();