--- ../gitweb/gitweb.cgi 2005-08-25 19:25:11.000000000 +0800 +++ gitweb.cgi 2005-08-26 17:56:41.000000000 +0800 @@ -40,6 +40,53 @@ #my $projects_list = $projectroot; my $projects_list = "index/index.aux"; +# custom stuff - refactored navbar +sub git_navbar($$$$) { + my $project = shift; + my $head = shift; + my $curSection = shift; + my $extraLinks = shift; + + my $sumLink = $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary"); + my $slogLink = $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog"); + my $logLink = $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log"); + my $comLink = $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit"); + my $comdifLink = $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff"); + my $treeLink = $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree"); + my $snapLink = $cgi->a({-href => "$snapshots_url?tree=$project&commit=HEAD"}, "latest snapshot"); + + if ($curSection eq "summary") { + $sumLink = "summary"; + } + elsif ($curSection eq "shortlog") { + $slogLink = "shortlog"; + } + elsif ($curSection eq "log") { + $logLink = "log"; + } + elsif ($curSection eq "commit") { + $comLink = "commit"; + } + elsif ($curSection eq "commitdiff") { + $comdifLink = "commitdiff"; + } + elsif ($curSection eq "tree") { + $treeLink = "tree"; + } + + my $retVal = "
\n" . + $sumLink . + " | " . $slogLink . + " | " . $logLink . + " | " . $comLink . + " | " . $comdifLink . + " | " . $treeLink . + " | " . $snapLink . + "
$extraLinks
\n" . + "
\n"; + return $retVal; +} + # input validation and dispatch my $action = $cgi->param('a'); if (defined $action) { @@ -941,15 +988,7 @@ } git_header_html(); - print "
\n" . - "summary". - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") . - "

\n" . - "
\n"; + print git_navbar($project, $head, "summary", ""); print "
 
\n"; print "\n" . "\n" . @@ -1087,15 +1126,7 @@ sub git_tag { my $head = git_read_hash("$project/HEAD"); git_header_html(); - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "
\n" . - "
\n" . - "
\n"; + print git_navbar($project, $head, "tag", ""); my %tag = git_read_tag($hash); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($tag{'name'})) . "\n" . @@ -1126,15 +1157,7 @@ sub git_tags { my $head = git_read_hash("$project/HEAD"); git_header_html(); - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "
\n" . - "
\n" . - "
\n"; + print git_navbar($project, $head, "tags", ""); my $taglist = git_read_refs("refs/tags"); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . @@ -1185,15 +1208,7 @@ sub git_branches { my $head = git_read_hash("$project/HEAD"); git_header_html(); - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "
\n" . - "
\n" . - "
\n"; + print git_navbar($project, $head, "branches", ""); my $taglist = git_read_refs("refs/heads"); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . @@ -1263,15 +1278,7 @@ my $base = $file_name || ""; git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . "
\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "
\n" . - "
\n"; + print git_navbar($project, $hash_base, "blob", $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain")); print "
" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "
\n"; @@ -1331,15 +1338,7 @@ my $base = ""; if (defined $hash_base && (my %co = git_read_commit($hash_base))) { $base_key = ";hb=$hash_base"; - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash_base"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash_base"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | tree" . - "

\n" . - "
\n"; + print git_navbar($project, $hash_base, "tree", ""); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; @@ -1493,38 +1492,31 @@ $page = 0; } git_header_html(); - print "
\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . - " | log" . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "
\n"; + my $navExtra = ""; my $limit = sprintf("--max-count=%i", (100 * ($page+1))); open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; if ($hash ne $head || $page) { - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "HEAD"); + $navExtra .= $cgi->a({-href => "$my_uri?p=$project;a=log"}, "HEAD"); } else { - print "HEAD"; + $navExtra .= "HEAD"; } if ($page > 0) { - print " ⋅ " . + $navExtra .= " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1), -accesskey => "p", -title => "Alt-p"}, "prev"); } else { - print " ⋅ prev"; + $navExtra .= " ⋅ prev"; } if ($#revlist >= (100 * ($page+1)-1)) { - print " ⋅ " . + $navExtra .= " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1), -accesskey => "n", -title => "Alt-n"}, "next"); } else { - print " ⋅ next"; + $navExtra .= " ⋅ next"; } - print "
\n" . - "
\n"; + print git_navbar($project, $hash, "log", $navExtra); if (!@revlist) { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . @@ -1593,6 +1585,7 @@ @difftree = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); git_header_html(); + # git_navbar omitted here - commitdiff link a bit weird o_O print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . @@ -1773,16 +1766,7 @@ mkdir($git_temp, 0700); git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . - "
\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent"}, "plain") . - "
\n"; + print git_navbar($project, $hash_base, "blobdiff", $cgi->a({-href => "$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent"}, "plain")); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; @@ -1825,15 +1809,7 @@ close $fd or die_error(undef, "Reading diff-tree failed."); git_header_html(); - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . - " | commitdiff" . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "
\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent"}, "plain") . "\n" . - "
\n"; + print git_navbar($project, $hash, "commitdiff", $cgi->a({-href => "$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent"}, "plain")); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; @@ -1967,15 +1943,7 @@ die_error(undef, "Unknown commit object."); } git_header_html(); - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . - "

\n" . - "
\n"; + print git_navbar($project, $hash, "history", ""); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; @@ -2051,15 +2019,7 @@ $pickaxe_search = 1; } git_header_html(); - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary;h=$hash"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . - "

\n" . - "
\n"; + print git_navbar($project, $hash, "search", ""); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . @@ -2180,38 +2140,31 @@ $page = 0; } git_header_html(); - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | shortlog" . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "
\n"; my $limit = sprintf("--max-count=%i", (100 * ($page+1))); open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; + my $navExtra = ""; if ($hash ne $head || $page) { - print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD"); + $navExtra .= $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD"); } else { - print "HEAD"; + $navExtra .= "HEAD"; } if ($page > 0) { - print " ⋅ " . + $navExtra .= " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p", -title => "Alt-p"}, "prev"); } else { - print " ⋅ prev"; + $navExtra .= " ⋅ prev"; } if ($#revlist >= (100 * ($page+1)-1)) { - print " ⋅ " . + $navExtra .= " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n", -title => "Alt-n"}, "next"); } else { - print " ⋅ next"; + $navExtra .= " ⋅ next"; } - print "
\n" . - "
\n"; + print git_navbar($project, $hash, "shortlog", $navExtra); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . "
\n";
description" . escapeHTML($descr) . "