gitweb: Add navigation to select side-by-side diff
Add to the lower part of navigation bar (the action specific part) links allowing to switch between 'inline' (ordinary) diff and 'side by side' style diff. It is not shown for combined / compact combined diff. Signed-off-by: Kato Kazuyoshi <kato.kazuyoshi@gmail.com> Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kato Kazuyoshi committed
Oct 31, 2011 at 00:36 UTC
6ae683c0f4298a25e845d3018bccd346663ad9bb
1 file changed
+23
gitweb/gitweb.perl
+23
@@ -7164,6 +7164,7 @@ sub git_blobdiff {
7164
my $formats_nav =
7165
$cgi->a({-href => href(action=>"blobdiff_plain", -replay=>1)},
7166
"raw");
7167
+ $formats_nav .= diff_style_nav($diff_style);
7168
git_header_html(undef, $expires);
7169
if (defined $hash_base && (my %co = parse_commit($hash_base))) {
7170
git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
@@ -7221,6 +7222,27 @@ sub git_blobdiff_plain {
7222
git_blobdiff('plain');
7223
}
7224
7225
+# assumes that it is added as later part of already existing navigation,
7226
+# so it returns "| foo | bar" rather than just "foo | bar"
7227
+sub diff_style_nav {
7228
+ my ($diff_style, $is_combined) = @_;
7229
+ $diff_style ||= 'inline';
7230
+
7231
+ return "" if ($is_combined);
7232
+
7233
+ my @styles = (inline => 'inline', 'sidebyside' => 'side by side');
7234
+ my %styles = @styles;
7235
+ @styles =
7236
+ @styles[ map { $_ * 2 } 0..$#styles/2 ];
7237
+
7238
+ return join '',
7239
+ map { " | ".$_ }
7240
+ map {
7241
+ $_ eq $diff_style ? $styles{$_} :
7242
+ $cgi->a({-href => href(-replay=>1, diff_style => $_)}, $styles{$_})
7243
+ } @styles;
7244
+}
7245
+
7246
sub git_commitdiff {
7247
my %params = @_;
7248
my $format = $params{-format} || 'html';
@@ -7250,6 +7272,7 @@ sub git_commitdiff {
7272
$cgi->a({-href => href(action=>"patch", -replay=>1)},
7273
"patch");
7274
}
7275
+ $formats_nav .= diff_style_nav($diff_style, @{$co{'parents'}} > 1);
7276
7277
if (defined $hash_parent &&
7278
$hash_parent ne '-c' && $hash_parent ne '--cc') {