gitweb: More per-view navigation bar links
Navigation bars in various views were empty or missed important items that should have been there, e.g. getting a snapshot in tree view or log of ancestry in commit view... This feeble patch attempts to consolidate that. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
Petr Baudis committed
Sep 22, 2006 at 03:19 UTC
cae1862a3b55b487731e9857f2213ac59d5646d1
1 file changed
+38
-4
gitweb/gitweb.perl
+38
-4
@@ -2441,6 +2441,9 @@ sub git_blame2 {
2441
$cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
2442
"blob") .
2443
" | " .
2444
+ $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
2445
+ "history") .
2446
+ " | " .
2447
$cgi->a({-href => href(action=>"blame", file_name=>$file_name)},
2448
"head");
2449
git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
@@ -2507,6 +2510,9 @@ sub git_blame {
2510
$cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
2511
"blob") .
2512
" | " .
2513
+ $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
2514
+ "history") .
2515
+ " | " .
2516
$cgi->a({-href => href(action=>"blame", file_name=>$file_name)},
2517
"head");
2518
git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
@@ -2682,6 +2688,10 @@ sub git_blob {
2688
" | ";
2689
}
2690
$formats_nav .=
2691
+ $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
2692
+ hash=>$hash, file_name=>$file_name)},
2693
+ "history") .
2694
+ " | " .
2695
$cgi->a({-href => href(action=>"blob_plain",
2696
hash=>$hash, file_name=>$file_name)},
2697
"plain") .
@@ -2717,6 +2727,9 @@ sub git_blob {
2727
}
2728
2729
sub git_tree {
2730
+ my ($ctype, $suffix, $command) = gitweb_check_feature('snapshot');
2731
+ my $have_snapshot = (defined $ctype && defined $suffix);
2732
+
2733
if (!defined $hash) {
2734
$hash = git_get_head_hash($project);
2735
if (defined $file_name) {
@@ -2740,7 +2753,23 @@ sub git_tree {
2753
my $base = "";
2754
my ($have_blame) = gitweb_check_feature('blame');
2755
if (defined $hash_base && (my %co = parse_commit($hash_base))) {
2743
- git_print_page_nav('tree','', $hash_base);
2756
+ my @views_nav = ();
2757
+ if (defined $file_name) {
2758
+ push @views_nav,
2759
+ $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
2760
+ hash=>$hash, file_name=>$file_name)},
2761
+ "history"),
2762
+ $cgi->a({-href => href(action=>"tree",
2763
+ hash_base=>"HEAD", file_name=>$file_name)},
2764
+ "head");
2765
+ }
2766
+ if ($have_snapshot) {
2767
+ # FIXME: Should be available when we have no hash base as well.
2768
+ push @views_nav,
2769
+ $cgi->a({-href => href(action=>"snapshot")},
2770
+ "snapshot");
2771
+ }
2772
+ git_print_page_nav('tree','', $hash_base, undef, undef, join(' | ', @views_nav));
2773
git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base);
2774
} else {
2775
undef $hash_base;
@@ -2885,17 +2914,22 @@ sub git_commit {
2914
my ($ctype, $suffix, $command) = gitweb_check_feature('snapshot');
2915
my $have_snapshot = (defined $ctype && defined $suffix);
2916
2888
- my $formats_nav = '';
2917
+ my @views_nav = ();
2918
if (defined $file_name && defined $co{'parent'}) {
2919
my $parent = $co{'parent'};
2891
- $formats_nav .=
2920
+ push @views_nav,
2921
$cgi->a({-href => href(action=>"blame", hash_parent=>$parent, file_name=>$file_name)},
2922
"blame");
2923
}
2924
+ if (defined $co{'parent'}) {
2925
+ push @views_nav,
2926
+ $cgi->a({-href => href(action=>"shortlog", hash=>$hash)}, "shortlog"),
2927
+ $cgi->a({-href => href(action=>"log", hash=>$hash)}, "log");
2928
+ }
2929
git_header_html(undef, $expires);
2930
git_print_page_nav('commit', defined $co{'parent'} ? '' : 'commitdiff',
2931
$hash, $co{'tree'}, $hash,
2898
- $formats_nav);
2932
+ join (' | ', @views_nav));
2933
2934
if (defined $co{'parent'}) {
2935
git_print_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);